Skip to content

fix(loaderkit): guard the namespace fold against a cyclic graph — one path-scoped NamespaceAncestors (#352) - #353

Merged
github-actions[bot] merged 4 commits into
mainfrom
fix/namespace-walk-cycle-guard
Oct 9, 2026
Merged

github-actions[bot] merged 4 commits into
mainfrom
fix/namespace-walk-cycle-guard

Conversation

@aitrawog

@aitrawog aitrawog commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

plugin.providers: and plugin.requires: both name a #PluginCapability, but only the providers: path had its class vocabulary checked. spec#216 made the CUE pattern's class segment structural — retiring the CUE-side check on both paths — which would have left requires: with no vocabulary check anywhere. This PR moves the check into the one shared reporter, so both paths share one taxonomy (R3) and requires: names an undeclared class instead of calling a correct word malformed.

What changes:

  • candy/plugin-box/validate_rules.go — one reportCapabilityFault shared by both paths.
  • candy/plugin-box/validate_parity_test.go — TestPluginRequiresClassVocabulary covers both directions.
  • charly.yml — one check: step in check-box-local witnessing the requires: arm.
  • The fixture rename workflow:lobster → zzznotaclass:lobster is required, not incidental: workflow joined the known vocabulary (schema/candy.cue:559), so the old fixture went red on main, and nothing surfaced it because this repo has no ci.yml (#38).

Fresh branch off origin/main; supersedes #37, which the verdict counter auto-closed. The pre-change ref here is simply origin/main, which retires the proof-binding findings the old thread kept producing.

How tested

R7 — the coverage fails without the change. Reverting validate_rules.go to origin/main, with a cmp identity check so the revert cannot be a silent no-op:

$ git show origin/main:candy/plugin-box/validate_rules.go > candy/plugin-box/validate_rules.go
$ go test . -run TestPluginRequiresClassVocabulary -count=1
--- FAIL: TestPluginRequiresClassVocabulary (0.00s)
    validate_parity_test.go:150: an undeclared class in requires: must be named; got: candy "myplugin": missing required `plan:` list …
    validate_parity_test.go:153: the requires: message must enumerate the known classes; got: … same ADE message …
    validate_parity_test.go:166: a malformed requires: capability must keep the grammar message; got: … same …
FAIL	rc=1
$ <restore> && go test . -run TestPluginRequiresClassVocabulary -count=1
ok  	rc=0

The reverted output contains no capability diagnostic at all, so the assertions can only fail — the test cannot pass vacuously on the old code.

The two renamed-fixture tests were red on main, measured:

$ <pristine origin/main worktree, 9f62ec8> go test . -run 'TestPluginCapabilityFaultsAreDistinct|TestPluginCapabilityDiagnosticWording' -count=1
--- FAIL: TestPluginCapabilityFaultsAreDistinct   splitPluginCapability("workflow:lobster") = fault 0 …
--- FAIL: TestPluginCapabilityDiagnosticWording   an unknown class must be reported as such; got: …
FAIL	rc=1

The module gates at this head:

$ gofmt -l .        # clean        $ go build ./...   rc=0        $ go vet ./...   rc=0
$ go test ./...     # all green except one host-local failure, below
$ go test ./... | grep FAIL
--- FAIL: TestCandyProjectDir (0.00s)      # deploykit — not this change's

That failure reproduces identically on a pristine origin/main worktree, and its mechanism is host state: candyProjectDir walks up for an enclosing project, the test's "orphan" lives under t.TempDir() (which resolves under /tmp here), and /tmp/charly.yml — another session's leftover from 2026-10-07 — is found. CI's go job is green on this very head, which places the failure on the host, not the tree. Filed as #366; the stray file was not deleted (removing someone else's scratch to turn a test green is the workaround R4 forbids).

R10 — the change-class bed ran green. A worktree-local binary was built with this branch's plugin compiled in from its local checkout, and the repo's own witness ran against it:

$ ./scripts/bootstrap-charly.sh --dev-plugin plugin-box=<worktree>   → bin/charly 2026.282.1710 (DEV BUILD)
$ bin/charly -C <worktree> check run check-box-local
[deploy-add] PASS  [bring-up-members] PASS  [check-live] PASS  [update] PASS  [cleanup] PASS  [cleanup-members] PASS
PASS (steps=6)

summary.yml binds it: driver_version: 2026.282.1710, driver_size: 52920818, and ok: true on all six steps. The new step fired — check-live.log: [box-capability-unknown-class-in-requires] exit=0 — and it declares a valid provider plus an invalid requires: class with a control expected to stay silent, so it cannot pass vacuously.

Filed issues

  • #38 — no ci.yml in this repo: gofmt/vet/test/golangci-lint run nowhere on a PR here. An ad-hoc lint finds 6 pre-existing errcheck findings, none in this diff.
  • #366 — TestCandyProjectDir asserts an absolute where the property is relative; it fails on any host with a charly.yml above TMPDIR.

Rulebook compliance

  • R1 — the need traced to spec#216; the bed failure and the red deploykit test were both root-caused rather than labelled "pre-existing"; the earlier thread's findings were fixed, not argued with.
  • R2/R3 — nothing deferred; one reporter for both paths, so the taxonomy cannot fork.
  • R4 — no workaround: no suppressed lint, no raised threshold, no relocated state directories when the bed was blocked.
  • R5 — one capability-fault reporter survives; the retired named-child shape is irrelevant here.
  • R6 — session worktree, append-only review commits, no force-push, no direct push to main.
  • R7/R8 — proven above at the message level, in the unit test and in the bed step.
  • R9 — CalVer-stamped worktree-local build, invoked through its own bin/, never installed.
  • R10 — check-box-local ran on this tree: steps=6, all ok: true.

Change classification

Code and configuration — a new validation rule, its tests, and one bed step. Not breaking in the wire sense; it intentionally widens what charly box validate rejects on the requires: path, which is the point. Tier: fully tested and validated — the change-class gate passed on the final tree, and the changed paths ran live in both the unit tests and the bed.

Agent: issue-ledger-fanout, bed-venues — the original change (superseded PR #37)
Agent: org-triage-2026-10-09 — re-cut onto a fresh main, gates and R10 re-run here
Assisted-by: DSH DeepSeek deepseek-v4.1-flash (fully tested and validated)

…e path-scoped NamespaceAncestors

ProjectCandiesScanned folded uf.Namespaces by recursing UNGUARDED, so a namespace that reaches
itself up the CURRENT path -- the intentional `main<->sub` mutual import, and before
opencharly/spec#202 also the self-mount of a same-repo subdirectory import -- died with
`fatal error: stack overflow` (measured live on a project carrying a resolved pod target, whose
leg runs this scan; #352).

The rule it needed already existed, re-derived at five other call sites, so it now lives ONCE as
loaderkit.NamespaceAncestors (namespace_walk.go): a PATH-SCOPED ancestor stack, NEVER a global
pointer set, because the loader mounts the SAME *spec.UnifiedFile at multiple namespace paths BY
DESIGN (a diamond import reached as `a.c` AND `b.c` via reference-mount pointer identity, or one
repo mounted at `arch` + `cachyos.arch`) and a global set records only the first path in
map-iteration order, silently dropping every later alias.

Every loaderkit walk now uses it -- StampDeployDescents, captureNamespaceLevels,
capturePluginKindsSeen, restorePluginKindsSeen, projectCandiesScanned -- and
ResolveProjectSeams.FillNamespacedBoxes carries the type across the seam, so a plugin
implementing that leg inherits the semantics rather than re-deriving them.

Tests: TestProjectCandiesScanned_TerminatesOnACyclicNamespaceGraph (the regression -- it aborts
the package with `fatal error: stack overflow` before this change) and
TestNamespaceAncestors_IsPathScopedNotGlobal (the rule itself).

Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

Review — BLOCK

Head SHA: 94ff72d8c44df4719157aea2d5ff51e71898c6f3 (branch: fix/namespace-walk-cycle-guard)

Change class: sdk library code (loaderkit namespace-walk mechanism) + a breaking exported-seam signature.

Blocks

  1. A1 / R1 / R5 — the body contradicts the diff (and itself) on the migration count. The body's R3 row claims "five inline copies deleted", the Summary claims the guard was "already re-derived at five other call sites", and the new comment at loaderkit/namespace_walk.go:~18 asserts the subtlety "was re-derived at six call sites". The CURRENT diff removes exactly four inline guards — stampDescents (loaderkit/descent_stamp.go), captureNamespaceLevels, capturePluginKindsSeen, restorePluginKindsSeen (loaderkit/materialize_wire.go) — and the fifth walk, projectCandiesScanned, had none (the body's own table says NONE — stack overflow). Three different counts (5 / 5 / 6) are stated where the tree ships 4, so the shipped comment is a false claim about the tree it lives in, and the prose contradicts the body's own table. Fix: correct every count to four (namespace_walk.go, the R3 row, and the Summary sentence) before merge.

  2. B10 / B14(d) — the centralization ("now exists once") claim has no pasted search. The R2/R3 rows assert a complete inventory of every namespace-graph walk in the org and that the guard now exists exactly once, but the body never pastes the executed grep that would substantiate it. A sweep/centralization claim requires the real command and its real output; the listed go test/vet/build/gofmt output does not cover it. Paste the actual search (command + output) proving no remaining inline map[*spec.UnifiedFile]bool guard survives in loaderkit (and, for the red proof, the full reproduction command rather than the elided python3 - <<'EOF' stub).

Verdict: BLOCK


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

aitrawog added a commit that referenced this pull request Oct 8, 2026
…heckable

Review round 1 fixes, every finding of the BLOCK, in one commit.

A1: the body asserted "one commit on a feat/ branch" while the branch is
fix/name-uninitialized-submodule. The claim is corrected to the branch actually used;
fix/ is the prefix this repository uses for fixes (cf. #353, #359).

B14(d)/R2: the sibling claim - "no other loader carries the same defect" - was
asserted without a pasted command. The commands and their real output are now in the
body, including the one hit that does exist (exec/ResolveHome, unrelated to import
resolution) rather than a claim of an empty result.

Also, from the review's non-blocking notes: uninitializedSubmodule did not use its
walker receiver, so it is now a plain function.

Gates re-run on this tree: go test ./... 14 packages ok; gofmt clean; go vet rc=0;
cross-compile amd64/arm64/arm/386 all ok; the four targeted tests pass.

Assisted-by: dsh deepseek-v4.1-flash (analysed on a live system)
github-actions Bot pushed a commit that referenced this pull request Oct 8, 2026
…a missing file (#361)

* fix(loaderkit): name an uninitialized submodule instead of reporting a missing file

A namespaced import whose target is a declared submodule directory that exists but holds
nothing - the ordinary state of a fresh `git worktree` - resolved to the directory, had
the unified file name appended, and failed with a bare ENOENT. On an older engine the
same tree surfaced it as `json: unsupported value: encountered a cycle via
map[string]*spec.UnifiedFile`. Neither reading named the cause, and because the umbrella
pre-commit hook calls `charly task ...` from a session worktree, it silently blocked every
umbrella PR from the sanctioned place (opencharly/charly#847).

The walk now reports the cause it can prove: the directory is empty AND its containing
repository declares it as a submodule path in .gitmodules. The message names the
submodule and the command that fixes it. Anything else - a populated directory, an
undeclared directory, a non-NotFound error - is left untouched so the ordinary not-found
path still works for a genuinely wrong ref.

Three negative cases are covered beside the positive one.

Assisted-by: dsh deepseek-v4.1-flash (syntax check only)

* fix(loaderkit): drop the unused receiver and make the sibling claim checkable

Review round 1 fixes, every finding of the BLOCK, in one commit.

A1: the body asserted "one commit on a feat/ branch" while the branch is
fix/name-uninitialized-submodule. The claim is corrected to the branch actually used;
fix/ is the prefix this repository uses for fixes (cf. #353, #359).

B14(d)/R2: the sibling claim - "no other loader carries the same defect" - was
asserted without a pasted command. The commands and their real output are now in the
body, including the one hit that does exist (exec/ResolveHome, unrelated to import
resolution) rather than a claim of an empty result.

Also, from the review's non-blocking notes: uninitializedSubmodule did not use its
walker receiver, so it is now a plain function.

Gates re-run on this tree: go test ./... 14 packages ok; gofmt clean; go vet rc=0;
cross-compile amd64/arm64/arm/386 all ok; the four targeted tests pass.

Assisted-by: dsh deepseek-v4.1-flash (analysed on a live system)

* fix(loaderkit): name the submodule-search depth bound

Review round 2, both findings, one commit.

A1: the body asserted "one commit" while the branch carries two. The assertion is removed
rather than corrected to a number: the branch carries the fix commit and its review-round
fix commits, and the org lands by squash - a count would be stale again the moment this
commit lands, which is the exact defect this campaign already measured once.

R4/B8: submoduleRoot's ancestor search was bounded by a bare literal 4. It is now
maxSubmoduleSearchDepth, with the reason it is four rather than any other number: a
gitlink lives directly under the repo that declares it, or one level deeper in nested
layouts, so four covers every org layout while keeping the search from climbing to the
filesystem root on a path that is not in a submodule at all. The bound decides whether
the named-cause error fires, so it is not a detail.

Gates: go test ./loaderkit/ ok; gofmt clean; go vet rc=0; go build ./... rc=0.

Assisted-by: dsh deepseek-v4.1-flash (analysed on a live system)
…UR functions, not six

The shipped comment in namespace_walk.go claimed the path-scoped subtlety "was re-derived at
six call sites". Measured on main it was re-derived as a LOCAL guard in exactly four
functions: `git grep -n 'ancestors\[' loaderkit` returns stampDescents,
captureNamespaceLevels, capturePluginKindsSeen and restorePluginKindsSeen, and nothing else.
A third count (five) appeared in the PR body. The comment now names the four, so the claim
carries its own evidence instead of a number the reader has to take on faith.

Assisted-by: dsh deepseek-v4.1-flash (fully tested and validated)
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

validator INCONCLUSIVE — no review verdict was produced (not a BLOCK; no code finding)

The gate could not obtain a review verdict on this run, so it produced no code finding. This is not a BLOCK and the PR is not being rejected — but the required check stays RED on purpose: unreviewed code must never merge.

  • class: empty completion (the token budget was spent on reasoning before any answer; not retryable)
  • Verdict class: infra (does NOT count toward AI_REVIEW_AUTO_CLOSE_AFTER)
  • review exit code: 1
  • in-job retries: none — the gate REPORTS the class instead of papering over it (R3)

Root cause (measured in this run). The engine's own terminal line names the class: the model used the shared max_tokens budget on reasoning and produced no answer (opencharly/plugin-review#12). A re-run with the same bounds reproduces it.

Measured in this run (the engine's own lines):

request — reasoning_effort="low" max_tokens=262144 attempt_timeout=15m0s idle=3m0s sampling=(temperature=1 top_p=0.95 frequency_penalty=0.5 presence_penalty=1) context_bytes=(system=35327 user=27466) files=7 comments=1
inconclusive: the model produced no answer and this is not retryable (LLM: empty completion (no content, no tool calls; finish_reason="length"; the model emitted only 491649 byte(s) of reasoning and no answer — the output token budget was exhausted before any answer; this is NOT retryable with the same max_tokens/reasoning_effort)); raise AI_REVIEW_MAX_TOKENS (currently 262144) so the reasoning budget leaves room for the answer, or lower AI_REVIEW_REASONING_EFFORT

Durable remedy.

  1. raise AI_REVIEW_MAX_TOKENS so reasoning leaves room for the answer, or lower AI_REVIEW_REASONING_EFFORT;
  2. do not re-run with unchanged bounds — the class is deterministic (R3).

Thread policy. This is a clear infrastructure failure (the provider/GitHub, not the engine) — it is EXCLUDED from the auto-close count, so this thread is NOT closed on it. Fix any BLOCK findings and re-run, or open a clean PR from scratch once the provider/runner condition is resolved.

A run that produced no verdict keeps this required check RED: unreviewed code must never merge.

Full diagnostics: this run's evidence artifact + job log (not embedded here — embedding a runaway log would feed it into the next review and deepen the collapse).

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

Review — PASS

Head SHA: c0c1c172736d4671ef1faed7a45748fee4d6123e (branch: fix/namespace-walk-cycle-guard)

Security screen: PASS — no scope mismatch, no secrets/egress, no weakened guardrail, no supply-chain change; the seam-signature change is documented as the cutover's consumer leg.

Checklist: All applicable rules PASS or NA.

Comments considered:

  • Comment 6045483293 (github-actions[bot], prior BLOCK at 94ff72d8) — stale-superseded. Both of its findings are resolved against the CURRENT state: (1) the count contradiction (5/5/6) is gone — the shipped comment in loaderkit/namespace_walk.go now states FOUR, and the body's summary/table/R3 row agree with the four inline guards actually removed (stampDescents, captureNamespaceLevels, capturePluginKindsSeen, restorePluginKindsSeen); (2) the centralization claim now ships the executed grep -rn 'map\[\*spec.UnifiedFile\]bool' loaderkit/ + git grep -n 'ancestors\[' origin/main output (one surviving line = the type's own def), and the red proof is a real Go reproduction (cp/git show/cmp/go test), not the elided stub.

Verdict: PASS


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) October 9, 2026 17:58
@github-actions
github-actions Bot merged commit a036b79 into main Oct 9, 2026
6 of 7 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant