Repository navigation
fix: prevent supervision from recording invented PR URLs - #3637
Closed
kunchenguid wants to merge 18 commits into
Closed
kunchenguid wants to merge 18 commits into
kunchenguid wants to merge 18 commits into
Conversation
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.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (3): Last reviewed commit: "no-mistakes(ci): Fixed both failures. Le..." | Re-trigger Greptile |
…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
… 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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
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 existingpr=value is treated as “live-verified” without provenance. A legacypr=https://github.com/karpathy/backpass/pull/108therefore authorizes a new outcome carrying that invented URL. Separately, an invented unread outcome stored before this change is delivered directly byreconcileUnreadOutcomeswithout 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://, soPR github.com/karpathy/backpass/pull/108 is readyis 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 legacypr=value is accepted as live-verified provenance, and pre-existing unread outcome rows bypass the append gate and are delivered directly byreconcileUnreadOutcomes. Thus a legacy inventedpr=https://github.com/karpathy/backpass/pull/108can 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 lowercasegithub.1485827954.workers.dev/...; concrete references such aswww.github.com/karpathy/backpass/pull/108orGitHub.com/karpathy/backpass/pull/108produce no extracted reference, so append succeeds and presents an invented forge location without error. Make the shared extractor recognize common case-insensitive andwww.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 legacypr=value as verified provenance, while pre-existing unread outcome rows bypass the new append gate and are delivered byreconcileUnreadOutcomes. Thus a legacy inventedpr=https://github.com/karpathy/backpass/pull/108can 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 asreview //github.com/karpathy/backpass/pull/108yields no references, sofm_pr_outcome_text_copiedreturns 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 writingpr=; 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 legacypr=is trusted without provenance, while pre-existing unread outcomes bypass the append gate and are delivered byreconcileUnreadOutcomes. 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/108produces 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 asdone: [PR](https://github.com/kunchenguid/backpass/pull/108)contains a canonical forge URL, but token unwrapping leavesPR](https://..., parsing emits an!reference, and the status reader discards it.fm-pr-check.shtherefore 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 afterfm_pr_poll_retirement_recover_oneandfm-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 containinghttps://github.com/karpathy/backpass/pull/%31%30%38produces 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_copiedstops 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 lowercasehttps://. 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/requestendpoint 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 containinggithub.1485827954.workers.dev:443/karpathy/backpass/pull/108therefore produces no extracted reference, passesfm_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 containinghttps://github.com./karpathy/backpass/pull/108does not parse canonically and_fm_pr_ref_shapedalso misses it, sofm_pr_outcome_text_copiedreturns 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 asdocs//api/pull/request is failingis 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 livegh,gh-axi, andglabcalls have no execution bound. A stalled network or CLI can therefore block PR registration and the supervision event indefinitely. Use the repository's sharedfm_run_timedboundary 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)becomesMR](//gitlab/group/repo/-/merge_requests/9)after unwrapping; its route prefix neither begins with//nor contains a dot or://, so_fm_pr_ref_shapedmisses 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/108contains a percent-encodedpullroute, but the detector recognizes only literal case variants of/pull/. Parsing fails, shape detection also fails,fm_pr_outcome_text_copiedsees 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 base3d2a08b2097dd24f9ce03fdafe6501e39b79dbd0../bin/fm-test-run.sh tests/fm-branch-supervision.test.sh./bin/fm-test-run.sh tests/fm-pr-check-security.test.shManually invokedbin/fm-branch-outcome.sh appendwith the incident's invented URL, a percent-encoded variant, and the worker-recorded real URL, then invokedunreadand inspected persisted outcome state.git status --shortafter evidence cleanup✅ **Document** - passed
✅ No issues found.
🔧 **Lint** - 1 issue found → auto-fixed ✅
🔧 Fix: Fix explicit empty shell variable initialization
✅ Re-checked - no issues remain.
✅ **Push** - passed
✅ No issues found.