Skip to content

fix: prevent supervision from recording invented PR URLs - #3637

Closed
kunchenguid wants to merge 18 commits into
mainfrom
fm/fm-supervision-pr-url-hallucination-r1
Closed

kunchenguid wants to merge 18 commits into
mainfrom
fm/fm-supervision-pr-url-hallucination-r1

Conversation

@kunchenguid

@kunchenguid kunchenguid commented Sep 3, 2026 •

Copy link
Copy Markdown
Owner

Intent

Captain (2026-09-03): supervision reported a 404 GitHub URL for the clean-slate backpass PR. Fix it so supervision can NEVER present or record an invented forge URL.

Observed incident: captain-facing supervision outcomes for backpass-target-clean-slate-r1 used https://github.com/karpathy/backpass/pull/108 (404). The REAL PR was kunchenguid/backpass#108 (merged). The fleet already had the real URL on that same wake (worker status done: PR https://github.com/kunchenguid/backpass/pull/108 checks green, brief supersede of the kunchenguid #107, clone origin kunchenguid/backpass.git) - so this was NOT a missing-context problem. Supervision assembled owner/repo from world knowledge (the famous Karpathy/backpass association) instead of copying the URL from the durable record; it even started to type the correct kunchenguid URL once ("Correcting URL") then used karpathy again, and kept using karpathy even after MAIN mirrored the correct URL.

What Changed

  • Require PR and merge-request registration to resolve on the forge within a bounded timeout and match worker-reported URLs when present.
  • Reject supervision outcomes containing noncanonical or unrecorded forge references, allowing only URLs copied from durable task records.
  • Update supervision guidance, documentation, and regressions for fail-closed GitHub and GitLab URL handling.

Risk Assessment

✅ Low: The change consistently enforces provenance at registration and outcome storage boundaries, with fail-closed live resolution, bounded lookups, and behavioral regression coverage.

Testing

Repository inspection, targeted supervision and PR-security tests, and an end-to-end CLI evidence check confirmed that invented and encoded forge URLs are refused without persistence while the worker-recorded URL is stored and presented; the worktree remained clean.

Evidence: End-to-end supervision PR URL provenance transcript

Source: End-to-end supervision PR URL provenance transcript

END-USER CHECK: supervision outcome URL provenance gate
Worker durable status:
done: PR https://github.com/kunchenguid/backpass/pull/108 checks green

1. Attempt captain outcome with incident 404 URL:
error: refusing to record an outcome carrying the pull request URL https://github.com/karpathy/backpass/pull/108, which is not in this task's durable records; copy the URL from the worker's own status line or the recorded PR instead of composing one
exit=1
durable_rows_after_refusal=0 (store not created)

2. Attempt percent-encoded invented route marker:
error: refusing to record an outcome carrying the pull request URL https://github.com/karpathy/backpass/%70ull/108, which is not in this task's durable records; copy the URL from the worker's own status line or the recorded PR instead of composing one
exit=1

3. Copy the real URL from the worker status:
1
exit=0

Captain-facing unread durable outcome:
{"seq":1,"epoch":1788440163,"task":"backpass-target-clean-slate-r1","wake":"","verdict":"captain","summary":"Clean-slate PR ready: https://github.com/kunchenguid/backpass/pull/108","silent":false,"statusEndpoint":71,"statusIdent":"strong:16777235:629666861:1788440163.614411520"}

Persisted URL checks:
real_url_rows=1
invented_owner_rows=0

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 2 issues found → auto-fixed (13) ✅
  • 🚨 bin/fm-pr-lib.sh:317 - The durable guarantee is bypassed after upgrade because every syntactically valid existing pr= value is treated as “live-verified” without provenance. A legacy pr=https://github.com/karpathy/backpass/pull/108 therefore authorizes a new outcome carrying that invented URL. Separately, an invented unread outcome stored before this change is delivered directly by reconcileUnreadOutcomes without the new append gate. Define an authorized migration/fail-closed policy for legacy metadata and unread outcomes; the remedy needs user authorization because trustworthy provenance may require new durable state or discarding/quarantining existing records.
  • 🚨 bin/fm-pr-lib.sh:335 - The fast path skips any text without ://, so PR github.com/karpathy/backpass/pull/108 is ready is accepted, stored, and presented despite containing an invented forge URL. Detect bare GitHub pull and GitLab merge-request paths as malformed forge references and refuse them rather than treating them as URL-free prose.

🔧 Fix: Reject bare forge references in outcomes
2 errors still open:

  • 🚨 bin/fm-pr-lib.sh:317 - The required guarantee that supervision can “NEVER present or record an invented forge URL” remains bypassable after upgrade: every syntactically valid legacy pr= value is accepted as live-verified provenance, and pre-existing unread outcome rows bypass the append gate and are delivered directly by reconcileUnreadOutcomes. Thus a legacy invented pr=https://github.com/karpathy/backpass/pull/108 can authorize a new outcome, while an unread legacy outcome containing it can be presented immediately. Define an authorized migration or fail-closed policy for legacy metadata and outcomes; the remedy needs user authorization because it may require provenance state or quarantining existing records.
  • 🚨 bin/fm-pr-lib.sh:270 - The bare-reference fix recognizes only lowercase github.com/...; concrete references such as www.github.com/karpathy/backpass/pull/108 or GitHub.com/karpathy/backpass/pull/108 produce no extracted reference, so append succeeds and presents an invented forge location without error. Make the shared extractor recognize common case-insensitive and www. bare GitHub forms and reject them as noncanonical.

🔧 Fix: Reject noncanonical bare GitHub references
2 errors still open:

  • 🚨 bin/fm-pr-lib.sh:317 - The required guarantee that supervision can “NEVER present or record an invented forge URL” remains bypassable after upgrade: lines 317-320 trust every syntactically valid legacy pr= value as verified provenance, while pre-existing unread outcome rows bypass the new append gate and are delivered by reconcileUnreadOutcomes. Thus a legacy invented pr=https://github.com/karpathy/backpass/pull/108 can authorize a new outcome, and an unread legacy outcome containing it can be presented immediately. Define an authorized migration or fail-closed policy; the remedy needs user authorization because it may require provenance state or quarantining existing records.
  • 🚨 bin/fm-pr-lib.sh:270 - The extractor does not recognize protocol-relative GitHub references. An outcome such as review //github.com/karpathy/backpass/pull/108 yields no references, so fm_pr_outcome_text_copied returns success and the invented forge location is stored and presented. Recognize //github.com/.../pull/... as a noncanonical forge reference and refuse it.

🔧 Fix: Reject protocol-relative GitHub references
3 errors still open:

  • 🚨 bin/fm-pr-check.sh:118 - This contradicts the required criterion that supervision can “NEVER present or record an invented forge URL.” Registration verifies only that the supplied URL resolves; it never verifies that it was copied from the task’s pre-existing status. If the status carries feat: let runs target one memory file or skill backpass#108 but supervision composes an unrelated existing GitHub PR URL, lines 118-147 accept it, metadata records it, and that metadata then authorizes the outcome. Enforce provenance against the worker record before writing pr=; ask-user is required because this changes which live PR URLs the registration interface accepts.
  • 🚨 bin/fm-pr-lib.sh:317 - The durable guarantee remains bypassable after upgrade: every syntactically valid legacy pr= is trusted without provenance, while pre-existing unread outcomes bypass the append gate and are delivered by reconcileUnreadOutcomes. A legacy invented URL can therefore authorize new outcomes or be presented immediately. Define an authorized migration or fail-closed policy; the remedy needs authorization because it may require provenance state or quarantining existing records.
  • 🚨 bin/fm-pr-lib.sh:270 - Forge-reference detection remains case-sensitive for path markers. For example, https://github.com/karpathy/backpass/PULL/108 produces no extracted reference, so the append succeeds and stores/presents the invented forge URL. Detect GitHub pull and GitLab merge-request path markers case-insensitively, rejecting noncanonical variants at the shared extractor.

🔧 Fix: Require worker URL provenance and reject case variants
2 issues (1 error, 1 warning) still open:

  • 🚨 bin/fm-pr-lib.sh:239 - A status such as done: [PR](https://github.com/kunchenguid/backpass/pull/108) contains a canonical forge URL, but token unwrapping leaves PR](https://..., parsing emits an ! reference, and the status reader discards it. fm-pr-check.sh therefore treats the status as carrying no URL and can register a different live PR, violating the required conditional provenance gate. Extract canonical URLs from common surrounding prose or markup at this shared boundary.
  • ⚠️ bin/fm-pr-check.sh:149 - The required provenance check occurs after fm_pr_poll_retirement_recover_one and fm-guard.sh. With a valid pending retirement receipt, an attempted registration using a different live URL first deletes the existing poll artifacts and receipt before refusing, contradicting the requirement that this refusal leave state unchanged. Perform the status-only provenance check before state-mutating recovery and guard operations.

🔧 Fix: Extract wrapped URLs and preserve retirement state
2 issues (1 error, 1 warning) still open:

  • 🚨 bin/fm-pr-lib.sh:286 - The detector requires the segment after /pull/ or /merge_requests/ to begin with an ASCII digit. An outcome containing https://github.com/karpathy/backpass/pull/%31%30%38 produces no reference and is appended unchanged, so an invented forge URL remains recordable without error. At this shared extraction boundary, treat any nonempty segment after a recognized PR/MR route as shaped and let the canonical parser reject it.
  • ⚠️ bin/fm-pr-lib.sh:240 - For [PR](https://github.com/kunchenguid/backpass/pull/108), the first scan emits !PR](https://...) before the embedded scan emits the canonical URL. fm_pr_outcome_text_copied stops at that ! entry, so even a copied, allowed canonical URL cannot be recorded when Markdown-wrapped. Skip printing the wrapper as a separate reference when a canonical embedded URL is successfully extracted, while preserving rejection of embedded decorated URLs.

🔧 Fix: Validate wrapped URLs and encoded forge references
1 error still open:

  • 🚨 bin/fm-pr-lib.sh:242 - The shared extractor scans inside wrappers only for lowercase https://. A summary such as [PR](//github.com/karpathy/backpass/pull/108) is stored successfully because the wrapped token no longer begins with the protocol-relative patterns in _fm_pr_ref_shaped; the exact summary is then presented to the captain. This leaves an invented forge reference reachable despite the stated NEVER invariant. Extract recognized protocol-relative references from wrappers at this shared boundary and preserve their rejection as noncanonical.

🔧 Fix: Detect wrapped forge routes uniformly
2 issues (1 error, 1 warning) still open:

  • 🚨 bin/fm-pr-check.sh:143 - This contradicts the required criterion that supervision can “NEVER present or record an invented forge URL.” When a task status contains no forge URL, this conditional skips provenance enforcement: an agent can supply any unrelated but existing PR, live resolution succeeds, pr= records it, and the outcome gate subsequently treats it as authorized. The changed test explicitly preserves this path. Ask whether registration must require a matching worker-reported URL or another task-binding authority; live existence alone does not prove task provenance.
  • ⚠️ bin/fm-pr-lib.sh:284 - The latest fix broadened detection from host-shaped references to every token containing /pull/<segment> or /-/merge_requests/<segment>. A normal outcome such as “the /pull/request endpoint is failing” is therefore rejected despite containing no forge reference. Because this overreach was introduced by the prior automated fix, revert its route-only wildcard to the minimal host-aware generalized detection while retaining rejection of wrapped protocol-relative GitHub references.

🔧 Fix: Require hosts when detecting forge routes
1 error still open:

  • 🚨 bin/fm-pr-lib.sh:286 - The required invariant says supervision can “NEVER present or record an invented forge URL,” but bare-host detection requires the hostname to be followed immediately by /. An outcome containing github.com:443/karpathy/backpass/pull/108 therefore produces no extracted reference, passes fm_pr_outcome_text_copied, and is recorded without error. Extend the shared host-aware detector to recognize noncanonical host locations with ports (and refuse them through the existing canonical parser).

🔧 Fix: Generalize forge authority detection for ports
1 error still open:

  • 🚨 bin/fm-pr-lib.sh:285 - The claimed NEVER invariant remains reachable because the authority regex requires the final hostname label to be followed immediately by a port or slash. A captain summary containing https://github.com./karpathy/backpass/pull/108 does not parse canonically and _fm_pr_ref_shaped also misses it, so fm_pr_outcome_text_copied returns success and the invented reference is recorded. Recognize trailing-dot host-shaped authorities at this shared detector and let the strict canonical parser refuse them.

🔧 Fix: Fail closed on location-shaped forge routes
2 warnings still open:

  • ⚠️ bin/fm-pr-lib.sh:289 - The location test uses *//*, which treats // anywhere in the prefix as a scheme-relative authority. Consequently ordinary hostless prose such as docs//api/pull/request is failing is rejected even though no location is named. Match only a prefix beginning with //, while retaining the separate scheme and dot cases.
  • ⚠️ bin/fm-pr-check.sh:79 - The newly required live gh, gh-axi, and glab calls have no execution bound. A stalled network or CLI can therefore block PR registration and the supervision event indefinitely. Use the repository's shared fm_run_timed boundary around each forge lookup; selecting the operational timeout is user-visible policy and needs authorization.

🔧 Fix: Bound forge lookups and anchor scheme-relative detection
1 error still open:

  • 🚨 bin/fm-pr-lib.sh:289 - The required invariant that supervision can "NEVER present or record an invented forge URL" remains reachable. [MR](//gitlab/group/repo/-/merge_requests/9) becomes MR](//gitlab/group/repo/-/merge_requests/9) after unwrapping; its route prefix neither begins with // nor contains a dot or ://, so _fm_pr_ref_shaped misses it and outcome append records it without validation. Detect the Markdown target's leading // at this shared extraction boundary before applying the location test.

🔧 Fix: Detect numeric forge routes structurally
1 error still open:

  • 🚨 bin/fm-pr-lib.sh:285 - The required guarantee that supervision can "NEVER present or record an invented forge URL" remains bypassable. For example, https://github.com/karpathy/backpass/%70ull/108 contains a percent-encoded pull route, but the detector recognizes only literal case variants of /pull/. Parsing fails, shape detection also fails, fm_pr_outcome_text_copied sees no reference, and the outcome is stored without provenance validation. Extend detection at this shared boundary to recognize percent-encoded route-marker bytes before applying the canonical gate. Because this broadens the deliberately specified structural rule, the remedy needs user authorization.

🔧 Fix: Detect percent-encoded forge routes
✅ Re-checked - no issues remain.

✅ **Test** - passed

✅ No issues found.

  • Inspected the target commit diff and repository state against base 3d2a08b2097dd24f9ce03fdafe6501e39b79dbd0.
  • ./bin/fm-test-run.sh tests/fm-branch-supervision.test.sh
  • ./bin/fm-test-run.sh tests/fm-pr-check-security.test.sh
  • Manually invoked bin/fm-branch-outcome.sh append with the incident's invented URL, a percent-encoded variant, and the worker-recorded real URL, then invoked unread and inspected persisted outcome state.
  • git status --short after evidence cleanup
✅ **Document** - passed

✅ No issues found.

🔧 **Lint** - 1 issue found → auto-fixed ✅
  • ⚠️ linter found issues (exit code 1)

🔧 Fix: Fix explicit empty shell variable initialization
✅ Re-checked - no issues remain.

✅ **Push** - passed

✅ No issues found.

Supervision reported a 404 GitHub URL for a merged PR whose real URL was
already in the fleet's own records: the owner had been assembled from world
knowledge rather than copied, and nothing mechanical stopped it from being
recorded or published.

Two independent gates now close that:

- bin/fm-pr-check.sh resolves the pull request LIVE on its own forge before
  recording pr=, using the same CLI and addressing its merge poll uses, and
  refuses a URL the forge does not return. gh is authoritative when it
  answers, so a project that resolves to a different canonical URL is refused
  rather than recorded under the name that was typed; gh-axi remains the
  fallback bin/fm-pr-merge.sh already relies on when gh cannot answer.
- bin/fm-branch-outcome.sh refuses to append an outcome whose summary or wake
  reason carries a forge URL that is not already in that task's durable
  records (the worker's status log and the live-verified pr=). Because the
  store is written before delivery, a URL that never reaches it can never be
  published either. bin/fm-pr-lib.sh owns the reference extraction and the
  membership test, so any future publisher gets the same mechanical check.

The supervision prompt and report tool now say to copy the URL rather than
compose one, but the refusals, not the wording, are the fix.

Both halves of the incident are covered behaviorally: a status line carrying
the real URL alongside an invented one, exercised through fm-pr-check and the
outcome append.
@greptile-apps

greptile-apps Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Reviews (3): Last reviewed commit: "no-mistakes(ci): Fixed both failures. Le..." | Re-trigger Greptile

Comment thread bin/fm-pr-lib.sh Resolved
Comment thread bin/fm-branch-outcome.sh Resolved
…now writes versioned PR metadata, legacy unversioned `pr=` values cannot authorize outcome URLs, and all outcome-reading interfaces validate stored URLs before presenting them. Added regression coverage for legacy metadata and unread outcomes. Verified branch supervision, PR security/merge, wake-drain, session-start, shell syntax, diff checks, and full lint
Comment thread bin/fm-branch-outcome.sh Resolved
… forge URLs are now quarantined individually, allowing later valid unread and captain outcomes to replay. Updated behavioral coverage for unread, list, startup replay, and unprocessed paths. Also added fm-pr-lib.sh to the broken-branch fixture, fixing CI’s rejected first offer. Verified branch supervision tests, shellcheck/syntax, diff checks, and the previously failing Pi scenario three times
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