Skip to content

fix(prescan): do not gate the remote-ref leg on a local discover: block - #473

Merged
github-actions[bot] merged 2 commits into
mainfrom
fix/prescan-remote-plugin-primaries
Aug 30, 2026
Merged

github-actions[bot] merged 2 commits into
mainfrom
fix/prescan-remote-plugin-primaries

Conversation

@atrawog

@atrawog atrawog commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

prescanDeclaredPluginWords returned early when the root manifest carried no discover:
block — and that early return skipped prescanRemotePluginManifests with it. The remote leg
reads @github plugin refs and has nothing to do with local discovery, so a project that
pins a plugin remotely and discovers nothing locally never prescanned that plugin at all.

Symptom: the plugin's plugin: primary: never reached the parse, so the scalar shorthand
was rejected —

node "probe-pod": plan[0] plugin verb "punktfunk" takes a MAP input
(it declares no primary field for the scalar shorthand)

— for a candy that declares exactly that field. And the failure is not local to the
offending step: it fails the whole document parse, so one bed's authoring takes the project
down with it.

The local discover walk stays conditional. Only the remote leg is lifted out from behind the
early return, so a malformed discover: block now still gets the remote leg instead of
losing both.

Closes #471.

How tested

Two projects, identical except for the presence of a discover: block. Both pin the same
plugin by @github ref and both author the scalar shorthand:

candy:
    - '@github.com/opencharly/plugin-punktfunk/candy/plugin-punktfunk:v2026.241.1930'
plan:
    - check: scalar sugar
      punktfunk: health

Before (current main):

project charly box validate
no discover: block fails — "declares no primary field for the scalar shorthand"
with discover: block exit 0

After this change: both exit 0.

=== A: NO discover block (the failing case) ===
exit=0
=== B: WITH discover block (must not regress) ===
exit=0

The mechanism was confirmed by instrumenting the prescan rather than inferred. In arm A the
remote leg was never entered at all; in arm B it was, and registered the primary:

DBG remote-leg enter  baseDir=…/primA3 hasRef=true
DBG remote-leg manifest=…/plugin-punktfunk@main/candy/plugin-punktfunk/charly.yml
DBG registerPluginPrimary word=punktfunk field=method

(the instrumentation was reverted before committing; the diff is the 8-line change only)

No regressions:

$ GOWORK=off go test ./...        EXIT=0   (2 packages ok, 0 failures)
$ GOWORK=off go vet ./...         (clean)
$ gofmt -l charly/plugin_prescan.go   (clean)

Regression test (second commit)

The first revision shipped without one and was correctly blocked under B12. The behaviour
under test is routing — does the remote leg run at all — and the leg's only observable
effect went through a network fetch, so the fix adds the seam that makes it testable:
resolveRemotePluginRepo is now a package var wrapping the CanonicalRef call. The test
substitutes a local directory holding a fake plugin candy and asserts its declared primary
registers.

It fails without the fix, with exactly the regression:

--- FAIL: TestPrescanRemoteLegRunsWithoutDiscoverBlock
    plugin_prescan_remote_test.go:75: the remote leg never ran:
      a root manifest with no discover: block skipped it
FAIL

and passes with it:

--- PASS: TestPrescanRemoteLegRunsWithoutDiscoverBlock (0.00s)
ok  github.com/opencharly/charly/charly

Verified by reverting only the control-flow change (len(doc.Discover) == 0 restored) with
the test in place, then restoring it — so the test is demonstrably coupled to the fix rather
than passing incidentally.

Rulebook compliance

  • R0 (skills) — /charly-internals:plugin (the prescan/connect ordering contract),
    /charly-internals:go, /charly-internals:git-workflow.
  • R1 (RCA) — root-caused by instrumentation, not inference: the leg was proven never to
    be entered, and the gate was traced to the len(doc.Discover) == 0 early return. An
    earlier hypothesis of mine (that the regex or the version-less CanonicalRef was at fault)
    was disproved by the same trace.
  • R2 (no split) — the cause is fixed here; nothing deferred.
  • R3 (no duplication) — the existing prescanRemotePluginManifests is reused; no second
    remote-ref path is introduced.
  • R4 (no workarounds) — the gate is corrected rather than callers being told to add a
    discover: block they do not otherwise need.
  • R4a (fix the product first) — this IS the product fix; the candy-side workaround
    (authoring the map form) was what users were doing instead.
  • R5 (hard cutover) — the old control flow is replaced, not supplemented.
  • R6 (git safety) — feature branch, no force-push, no hook bypass; instrumentation
    reverted via git checkout before staging, and the committed diff is 8 lines.
  • R7 (prove the gate) — full go test ./..., go vet, gofmt, the committed
    regression test with its negative control, plus the before/after binary pair above.
  • R9 (deployed binary) — the fix is in the charly binary itself; both arms were run
    against binaries built from this tree, not an installed charly.
  • R10 (fresh disposable proof) — N/A — a parse-time fix with no deployment surface; the
    A/B fully observes it.
  • RDD — the risky assumption (that the remote leg was running and failing) was tested
    before any code changed, and turned out to be false.
  • ADE / SDD — N/A — no candy content, no schema or generated code.
  • Concurrency mandate — N/A — one control-flow change.
  • Architecture gate / placement — correct: prescan ordering is kernel, and the change
    stays inside the existing prescan.

Change classification

  • Change class: bug fix in the parse-time plugin prescan, plus its regression test and
    the one-line seam the test needs.
  • Verification gate: go test ./... + go vet + gofmt on the final tree, plus a
    before/after A/B with real binaries against a real remote plugin ref.
  • Attribution tier: fully tested and validated — the module gate passed on the final
    tree and the changed path was executed live in both arms, with output retained above.

Assisted-by: Claude Code claude-opus-5 (fully tested and validated)

prescanDeclaredPluginWords returned early when the root manifest carried no
discover: block, which skipped prescanRemotePluginManifests with it. The remote leg
reads @github plugin refs and has nothing to do with local discovery, so a project
that pins a plugin remotely and discovers nothing locally never prescanned that
plugin at all.

The visible symptom: its `plugin: primary:` never reached the parse, so the scalar
shorthand was rejected with "takes a MAP input (it declares no primary field for the
scalar shorthand)" - for a candy that declares exactly that field. The failure is not
local to the offending step either: it fails the whole document parse.

The local discover walk stays conditional; only the remote leg is lifted out from
behind the early return. A malformed discover: block now still gets the remote leg
rather than losing both.

Closes #471.

Claude-Session: https://claude.ai/code/session_016fnPmYiC6ZkqXSi6D8PAP6
@github-actions

Copy link
Copy Markdown
Contributor

Review — BLOCK

Head SHA: e518a54f61ee6cf307dddea383e48873504e40c4 (branch: PR #473)

Change class: code change — Go bug fix in the parse-time plugin prescan (charly/plugin_prescan.go, 8 additions / 1 deletion).

Security screen: PASS — no scope mismatch (single control-flow change matches the summary), no secrets/exfiltration, no weakened guardrails, no supply-chain changes. The change stays inside the existing prescan; placement is CORRECT (prescan is kernel).

Blocks

  1. B12 — new behavior ships with NO test that would fail without it. The change makes the remote-ref leg (prescanRemotePluginManifests) run even when the root manifest has no discover: block — a genuinely new behavior. The diff adds this new code path with no test or hook in the diff, and the body explicitly admits it: "No unit test, and why … There is no seam to stub that in a hermetic test." The rule is strict: "a change whose new behavior has NO test that would FAIL without it BLOCKS (cross-check from diff: if new code is added with no test/hook in the diff, flag it)." The A/B manual run against a real binary is evidence, not committed coverage — it does not satisfy the "ships the check/test coverage" requirement. The body's "no seam" argument is a testability rationale, not a rulebook exception. The author must add a regression test (or a testable seam) in the diff that fails without this change.

Verdict: BLOCK


ollama/deepseek-v4-flash — pi-review-action.

View action run

Adds the regression test the fix was missing, plus the seam it needs.

The behaviour under test is routing - does the remote-ref leg run when the root
manifest carries no discover: block - and the leg's only observable effect went
through a network fetch. resolveRemotePluginRepo is now a package var wrapping the
CanonicalRef call, so a test substitutes a local directory and asserts the declared
words register.

The test fails without the fix with "the remote leg never ran: a root manifest with
no discover: block skipped it", which is the exact regression.

Claude-Session: https://claude.ai/code/session_016fnPmYiC6ZkqXSi6D8PAP6
@github-actions

Copy link
Copy Markdown
Contributor

Review — PASS

Head SHA: c63870b09ad9 (branch: PR #473)

Security screen: PASS — no scope mismatch (control-flow fix + test seam + regression test all match the summary), no secrets/exfiltration, no weakened guardrails, no supply-chain changes.

Checklist: All applicable rules PASS or NA.

Comment intake: The single prior comment (github-actions BLOCK on B12 — "no test that would fail without it") is stale-superseded: the second commit (c63870b09ad9) adds charly/plugin_prescan_remote_test.go, which stubs resolveRemotePluginRepo and asserts the remote leg runs and registers the primary when no discover: block is present. The test is genuinely coupled to the fix — without the control-flow change the early return skips the leg and resolved stays false, so it fails. The body's pasted negative-control output is internally consistent with the diff.

Placement: CORRECT — the change stays inside the existing prescan (kernel); the resolveRemotePluginRepo package var is a test seam, not a new layer. No alias files, no new sdk imports, no schema/generated-code changes (SDD/ADE N/A).

Verdict: PASS


ollama/deepseek-v4-flash — pi-review-action.

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) August 30, 2026 07:11
@github-actions
github-actions Bot merged commit 711b762 into main Aug 30, 2026
3 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Aug 30, 2026
@aitrawog
aitrawog deleted the fix/prescan-remote-plugin-primaries branch September 25, 2026 19:06
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.

plugin.primary: is ignored for an @github-pinned candy, so scalar shorthand fails the parse for new out-of-tree verbs

1 participant