Resolve config items on demand so untaken references are never resolved
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- typescript
- Domain
- backend
Research direction
Start by reading the resolver implementation around ConfigItem.resolve(), getDepValue, and resolveEnvValues, then trace the --filter and @import(..., enabled=...) paths. The issue names no file or test, so locate those entry points and inspect tests for conditional references, dependency errors, cache attribution, side effect ordering, and sensitive value checks. Done means requested keys resolve dependencies on demand while static cycle detection and the listed partial load behaviors remain correct.
Written by the indexing model from the issue text.
Description
Follow-up from #1153 (and() / or()).
Problem
Resolver functions short-circuit their own nested function calls (and(false, op(...)) never calls op()), but not item references. and(false, $EXPENSIVE) and if(false, $A, $B) still resolve EXPENSIVE / A, because resolveEnvValues schedules each item only after every key in its dependencyKeys has resolved, and ref() just reads the already-resolved value.
In a full load this costs nothing, since every item resolves anyway. It matters for partial loads, where the unused dependency is otherwise never needed:
--filter: matched items plus their transitive deps- early-resolved
@import(..., enabled=...)conditions
Proposal: resolve items on demand
Switch the graph from a push scheduler to pull-based resolution:
ConfigItem.resolve()memoizes its in-flight promise so concurrent readers share one run (no doubleop()calls)getDepValue(only used byref()) becomes async and awaitsdepItem.resolve()instead of throwing when the dep is unresolvedresolveEnvValuesbecomes aPromise.allover the requested keys; deps are pulled in as they are read, still in parallelearlyResolve()and the transitive-dep expansion used by--filter/@import(enabled=...)go away; those paths resolve just the keys they need- keep static dep collection for cycle detection, type generation, etc. Static cycles stay an error, so a runtime deadlock is impossible (runtime reads are a subset of static edges)
This makes if(), ifs(), remap(), and(), or() and fallback() lazy for references without marking conditional arg positions per function.
Things to handle
- "Dependency X is invalid" would only apply when X is actually read, not when it sits in an untaken branch. Arguably more correct, but error output and some tests change
- each on-demand resolve needs its own resolution context (current item, cache store) so cache hits are attributed correctly
- ordering of side effects (
exec()etc.) may shift; tests relying on order (e.g. theincrementtest resolver) may need updates - partial loads leave more items unresolved; audit code that assumes all deps of a resolved item are resolved (e.g.
checkForSensitiveValuesInsideNonSensitiveOnes)
Related
- #1147 (lazy plugin functions in untaken branches) overlaps, though it also needs the unknown-function check deferred, which this does not cover
- Dominant language
- TypeScript
- Stars
- 4.9k
- Forks
- 140
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 35
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dmno-dev/varlock
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
dmno-dev/varlock#1279 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
dmno-dev/varlock#1100 · 3 comments ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 78/100
dmno-dev/varlock#1278 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
dmno-dev/varlock#1275 · 1 comment ·
Maintainers usually reply within 1 day
-
core:varlock RFC
Difficulty 5/5 Over a week Newbie friendliness 28/100
dmno-dev/varlock#1258 · 1 comment ·
Maintainers usually reply within 1 day
All issues in dmno-dev/varlock
Similar issues
-
documentation good first issue roadmap
Difficulty 1/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
resend/react-email#3876 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
siyuan-note/siyuan#21324 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
himynameisdave/bsky-profanity-counter#59 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100