Skip to content

fix(core): a revisited scope with a new policy include no longer throws - #767

Merged
sini merged 2 commits into
mainfrom
fix/ctx-seen-supplement
Nov 13, 2026
Merged

sini merged 2 commits into
mainfrom
fix/ctx-seen-supplement

Conversation

@sini

@sini sini commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Since #753, a config can stop evaluating with:

error: 'builtins.elemAt' called with index 0 on a list of size 0
  at nix/lib/aspects/fx/handlers/ctx.nix:43 (ctxSeenHandler, newAspectValues)

Cause. processSingleResolve (policy/schema.nix) sends ctx-seen two lists that the handler indexes in parallel, but they aren't the same length:

  • aspects is the identity keys of includeAspects ++ policyIncludes ++ resolveIncludes;
  • aspectValues is includeAspects alone.

ctxSeenHandler computes the new indices over aspects, then reads aspectValues at the same indices. When a revisited scope brings a new policy or schema include, that index is past the end of aspectValues. The mismatch is older than #753; #753 is the first change that routes non-empty policy or schema includes through a revisit.

Fix. ctx-seen no longer takes values. It dedups keys only and returns newAspectIds; the schema resolve selects the new aspects from includeAspects by key. Policy and schema include keys are still recorded as seen, so dedup is unchanged, and they are still never supplemented. With no second list there's nothing to index past.

Supplementing the policy includes too would be wrong: the supplemental resolution then re-applies them, and a config gets duplicate definitions (a unique option defined three times).

Validation

  • c5.fx-handlers.test-ctx-seen-reports-new-keys: revisits of one scope key report only the keys not yet recorded.
  • CI green on 05a95a2.

ctxSeenHandler indexed aspectValues at every new index of aspects, but
processSingleResolve passes policy and schema include keys in aspects
with no matching value. Since #753 routes those through a revisit, a
new one read past the end of aspectValues. Supplement only the new
indices that carry a value; the keys are still recorded as seen.
@github-actions github-actions Bot added the allow-ci allow all CI integration tests label Nov 13, 2026
…lues

ctx-seen took two parallel lists that were not the same length and paired
them by index. It now takes the keys alone and returns the new ones. The
schema resolve selects the include aspects among them, so a policy or schema
include key has no value to look up.
@sini
sini merged commit c41e625 into main Nov 13, 2026
16 checks passed
@sini
sini deleted the fix/ctx-seen-supplement branch November 13, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

allow-ci allow all CI integration tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant