Repository navigation
Resolve silo paths from configuration instead of hardcoded directory names - #9
Merged
Merged
Conversation
added 4 commits
August 17, 2026 22:43
The generated nudge script wrote its fire/delivered state to a directory
named by a hardcoded silo path, and listCrons independently re-derived the
same hardcoded path to read it back. The two agreed with each other and
disagreed with the deployment, so on any instance whose agent directories
are not at that exact path:
- run-state written by a fired nudge was invisible to the Scheduler UI,
which is the whole of the DC4 visibility feature; and
- editing a nudge through the app rewrote the script against the same
wrong path, so the per-fire-slot marker that makes delivery idempotent
started over in a second tree beside the first.
Both halves now come from one configured source, the INBOX_ROOT that every
other silo-adjacent module already resolves through. cron-state sits beside
inbox/ inside each agent's directory, so INBOX_ROOT is the correct root and
no new configuration is introduced. Injected through CronDeps like every
other side effect in this module, and resolved lazily so a rejected target
still fails as a bad target rather than as a configuration error.
The root is now a value rather than a literal, so it is also now shell
quoted. It went into the script inside double quotes, where a dollar sign
or a backtick in an operator's path would have expanded.
…missed TASK-434 replaced deny-known-bad with allowlist confinement across safe-fs, attachments and projects, for a reason recorded in safe-fs's header: a substring ban on a silo directory name is a build-era invariant encoded at the wrong layer, and it blocks the production paths the app is meant to serve. review.server.ts was not converted with the others and kept the ban. Two things were wrong with what was left behind. The banned string is a directory name no deployment is obliged to use, so on most instances the check denied nothing while reading like a protection. And resolveReviewRoots ALWAYS appends INBOX_ROOT as an implicit root, so on an instance that did use that name the ban and the root list contradicted each other outright: every read from the one root the panel is guaranteed to have was refused. Containment against realpath'd roots is strictly stronger than a substring test for the traversal and symlink-escape cases the ban was reaching for, so nothing load-bearing goes with it. The tests that asserted the ban are replaced by tests for the property that actually holds the surface: a file inside a silo-shaped root is served, one outside every root is refused, and an escape through an intermediate symlink is refused on the realpath. Records one gap this deliberately does not close. The sandbox live-silo refusal covers the four roots in safe-fs's ROOT_ENV_VARS table, which validateConfiguredRoots vets once at boot, and INBOX_ROOT is in it. Nothing vets REVIEW_ROOTS. The obvious fix lands on the autolink hot path, whose realpath cost is measured by a regression test, so it wants a once-per-request home rather than a per-path syscall.
MC_SANDBOX_ONLY is the half of FND-04 that stops a sandbox configuration being pointed at a live agent silo. README states that rule with no directory in it. The implementation could only ever recognise one: the silo directory name this project ships, joined onto the home directory. On any deployment that keeps its agents anywhere else, the flag was inert. Not weaker, inert: it refused nothing at all, while .env.example described it as a protection and test/setup.ts set it on every test run. A guard that cannot name the thing it is guarding is a comment. MC_LIVE_SILO_ROOT names it. Unset, the default is exactly what the code did before, so no existing instance changes behaviour and no test moves. Set, it points the refusal at whatever a real fleet actually uses. Absolute paths only, validated where it is used rather than at boot, because the variable means nothing unless MC_SANDBOX_ONLY is set too and failing a production start over an unused sandbox setting would be the wrong trade. This also makes the refusal testable for the first time. The one test that covered it returned early unless the machine running it happened to have the default silo directory, which no CI machine does, so it had been passing by skipping. The new cases stand a tmpdir up as the live silo and assert the refusal for real, including the root itself, a sibling sharing its name prefix, the unset-flag no-op, and a blocked inbox write end to end.
…claims When INBOX_ROOT is unset and no --inbox-root is passed, create-agent.sh falls back to this project's default silo layout and says so loudly, which is the right design: an inbox created in the wrong place should be visible when it happens, not the first time a message goes missing. The wording undercut it. It announced the value as "the value from the application's .env.example", and that file ships INBOX_ROOT empty, because there is no default (FND-03). The citation dressed a guess up as a lookup, which is the one thing a warning about guessing must not do. It now says plainly that nothing here knows where the reader's inbox root is and that the value below is a guess. No behaviour change, and the fallback value is deliberately left alone. It is the last of three sources and both of the ones ahead of it already win. Tests now pin that ordering, since the fallback firing over something the operator had configured is the failure that would actually matter, and no test covered it: the existing case passes --inbox-root and never reaches the fallback branch at all.
…atch Dropping the substring ban from this module left MC_SANDBOX_ONLY with nothing to say about REVIEW_ROOTS. safe-fs's ROOT_ENV_VARS table is vetted once at boot and INBOX_ROOT is in it, but REVIEW_ROOTS is a fifth, separately parsed root list that was in no table at all. So with the flag set, an operator could name the live agent silo in REVIEW_ROOTS and read it back through the review API: wider than what the deleted code allowed on the default layout, and a defeat of MC_LIVE_SILO_ROOT on any other one. The module header recorded that as a known gap and deferred it. Naming a hole in a comment does not close it, and it should not have shipped open. The deferral reasoned that the fix wanted a once-per-request home, because the obvious placement - assertNoLiveSiloRoot per root inside assertContained - lands on the autolink path, whose realpath cost linkifyBlockBodies shares across blocks deliberately and a regression test bounds. That reasoning was right about the constraint and wrong about there being no home: root RESOLUTION already happens once per request, not once per path. resolveReviewRoots now vets every root it is about to return, the configured entries and the implicit INBOX_ROOT alike, and throws before any of them reaches a caller. It is memoised on the root list plus the two env vars the refusal reads, so a running instance pays for it once and the autolink path pays a string compare; the perf regression test still measures 4 realpath calls for 3 blocks, unchanged. Only a pass is recorded, so a refusal can never memoise itself into a pass. Boot is covered by the same code under the name validateReviewRoots, called by the root loader beside validateConfiguredRoots, so a sandbox instance pointed at a live silo dies at start with the offending root named rather than looking healthy until someone opens the panel. The per-resolution check is not redundant with it: /api/review is a resource route, and RR7 runs a resource route's own loader only, never the root loader, so on a cold process the boot check alone would not have covered the exact request the finding describes. Two smaller decisions worth stating. A configured root that does not exist yet is vetted where it sits rather than skipped: containment skips it today, but it starts serving the moment the directory appears. And the implicit INBOX_ROOT is vetted here too even though the boot table already carries it, because on that same cold resource-route request the boot table has not run. Tests: eight cases in review.test.ts (silo root itself, a root below it, the read end to end, a not-yet-created entry, the implicit INBOX_ROOT, the boot entry point, a sibling sharing the silo's name prefix, and the unset-flag production cutover), plus one in review-autolink.test.ts pinning that the render path fails CLOSED - no links into a refused silo, and no throw out of a render. All seven refusal cases fail without this change. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…disk The previous commit put the MC_SANDBOX_ONLY live-silo refusal in the right place and then cached its answer in the wrong shape. The memo was keyed on the root list plus MC_SANDBOX_ONLY and MC_LIVE_SILO_ROOT, described in that commit as "everything the answer depends on". It is not. assertNoLiveSiloRoot answers from the FILESYSTEM: it returns early when the silo cannot be realpath'd, and both sides of its containment comparison are realpaths. None of that is a function of the configuration, so no key over the configuration can stand in for it. Codex reproduced the bypass in one process, not in theory. Configure a sandbox instance with MC_LIVE_SILO_ROOT=<tmp>/silo and REVIEW_ROOTS=<tmp>/silo/agents while the silo does not exist. resolveReviewRoots passes, correctly, because there is no silo to resolve, and records that pass. Create silo/agents and private.md afterwards and readReviewFile(private.md) returns the contents, off a pass recorded before the directory existed, with the env and the raw root list byte-for-byte unchanged. Retargeting a symlinked root after a pass is the same bug wearing a different hat. The fix is the shape Codex asked for: memoise only while MC_SANDBOX_ONLY is unset, where the refusal is a no-op and a recorded pass cannot go stale, and re-vet on every resolveReviewRoots() call while the guard is active. The flag is read in vetReviewRoots only to decide how long an answer stays valid, never to decide what the answer is, so assertNoLiveSiloRoot stays the one authority on the refusal itself and the vetting loop still runs at least once for any distinct root list whatever the flag says. The route-level placement is untouched: that half of the last commit was right and the finding said so. The re-vet is bounded at the granularity Codex signed off on, once per root RESOLUTION rather than once per path or per block. Every caller on this surface already resolves once per request: linkifyBlockBodies hoists resolveReviewRoots out of its block loop precisely so the realpath cost is paid per request, and the read entry points call it once each. Tests: two regression cases, the reproduction above through readReviewFile and the symlink-retarget variant Codex named as the same class. Both fail on the parent commit, and the create-after-pass one fails by returning the silo file's contents, not by some incidental difference. The autolink perf regression test needed restating rather than relaxing. It asserted an absolute bound of 4 realpath calls, measured with the memo pre- warmed outside the window, which is no longer a thing that can be pre-warmed. It now measures three blocks against six and asserts the counts are EQUAL, which is the property it was always about (nothing scales with the number of BLOCKS) stated directly instead of encoded as a constant, plus a bound of 8 on the per-call figure so a fixed cost cannot balloon unnoticed. 8 is the vetting of 2 roots, each realpath'd and compared against a realpath'd silo, plus assertContained's 4 paid once for the one distinct candidate. Without the sharing that second half alone would be 4 per block, so the regression the test was written for still fails it. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Owner
Author
|
Folio (independent review, round 3, model-diverse) — 2026-08-18 Re-reviewed through 900ca48. The sandbox-only cache gating closes both stale-filesystem cases: create-after-pass and symlink retargeting are re-vetted on the next resolution, and enabling MC_SANDBOX_ONLY cannot reuse an inactive-state cache entry. I also traced file reads, asset reads, resource routes and autolinking through the guarded resolver, plus the other safe-fs call sites; no equivalent stale-pass path remains. Focused tests, typecheck and boundaries pass. I would approve this if GitHub allowed self-review. |
simon-inkie
added a commit
that referenced
this pull request
Aug 18, 2026
…names (#9) * fix(cron): resolve the nudge state directory from INBOX_ROOT The generated nudge script wrote its fire/delivered state to a directory named by a hardcoded silo path, and listCrons independently re-derived the same hardcoded path to read it back. The two agreed with each other and disagreed with the deployment, so on any instance whose agent directories are not at that exact path: - run-state written by a fired nudge was invisible to the Scheduler UI, which is the whole of the DC4 visibility feature; and - editing a nudge through the app rewrote the script against the same wrong path, so the per-fire-slot marker that makes delivery idempotent started over in a second tree beside the first. Both halves now come from one configured source, the INBOX_ROOT that every other silo-adjacent module already resolves through. cron-state sits beside inbox/ inside each agent's directory, so INBOX_ROOT is the correct root and no new configuration is introduced. Injected through CronDeps like every other side effect in this module, and resolved lazily so a rejected target still fails as a bad target rather than as a configuration error. The root is now a value rather than a literal, so it is also now shell quoted. It went into the script inside double quotes, where a dollar sign or a backtick in an operator's path would have expanded. * fix(review): drop the silo-name substring ban the confinement rework missed TASK-434 replaced deny-known-bad with allowlist confinement across safe-fs, attachments and projects, for a reason recorded in safe-fs's header: a substring ban on a silo directory name is a build-era invariant encoded at the wrong layer, and it blocks the production paths the app is meant to serve. review.server.ts was not converted with the others and kept the ban. Two things were wrong with what was left behind. The banned string is a directory name no deployment is obliged to use, so on most instances the check denied nothing while reading like a protection. And resolveReviewRoots ALWAYS appends INBOX_ROOT as an implicit root, so on an instance that did use that name the ban and the root list contradicted each other outright: every read from the one root the panel is guaranteed to have was refused. Containment against realpath'd roots is strictly stronger than a substring test for the traversal and symlink-escape cases the ban was reaching for, so nothing load-bearing goes with it. The tests that asserted the ban are replaced by tests for the property that actually holds the surface: a file inside a silo-shaped root is served, one outside every root is refused, and an escape through an intermediate symlink is refused on the realpath. Records one gap this deliberately does not close. The sandbox live-silo refusal covers the four roots in safe-fs's ROOT_ENV_VARS table, which validateConfiguredRoots vets once at boot, and INBOX_ROOT is in it. Nothing vets REVIEW_ROOTS. The obvious fix lands on the autolink hot path, whose realpath cost is measured by a regression test, so it wants a once-per-request home rather than a per-path syscall. * feat(safe-fs): let MC_SANDBOX_ONLY name the silo it is protecting MC_SANDBOX_ONLY is the half of FND-04 that stops a sandbox configuration being pointed at a live agent silo. README states that rule with no directory in it. The implementation could only ever recognise one: the silo directory name this project ships, joined onto the home directory. On any deployment that keeps its agents anywhere else, the flag was inert. Not weaker, inert: it refused nothing at all, while .env.example described it as a protection and test/setup.ts set it on every test run. A guard that cannot name the thing it is guarding is a comment. MC_LIVE_SILO_ROOT names it. Unset, the default is exactly what the code did before, so no existing instance changes behaviour and no test moves. Set, it points the refusal at whatever a real fleet actually uses. Absolute paths only, validated where it is used rather than at boot, because the variable means nothing unless MC_SANDBOX_ONLY is set too and failing a production start over an unused sandbox setting would be the wrong trade. This also makes the refusal testable for the first time. The one test that covered it returned early unless the machine running it happened to have the default silo directory, which no CI machine does, so it had been passing by skipping. The new cases stand a tmpdir up as the live silo and assert the refusal for real, including the root itself, a sibling sharing its name prefix, the unset-flag no-op, and a blocked inbox write end to end. * fix(base): stop create-agent citing a file that does not say what it claims When INBOX_ROOT is unset and no --inbox-root is passed, create-agent.sh falls back to this project's default silo layout and says so loudly, which is the right design: an inbox created in the wrong place should be visible when it happens, not the first time a message goes missing. The wording undercut it. It announced the value as "the value from the application's .env.example", and that file ships INBOX_ROOT empty, because there is no default (FND-03). The citation dressed a guess up as a lookup, which is the one thing a warning about guessing must not do. It now says plainly that nothing here knows where the reader's inbox root is and that the value below is a guess. No behaviour change, and the fallback value is deliberately left alone. It is the last of three sources and both of the ones ahead of it already win. Tests now pin that ordering, since the fallback firing over something the operator had configured is the failure that would actually matter, and no test covered it: the existing case passes --inbox-root and never reaches the fallback branch at all. * fix(review): vet REVIEW_ROOTS against the live silo the ban used to catch Dropping the substring ban from this module left MC_SANDBOX_ONLY with nothing to say about REVIEW_ROOTS. safe-fs's ROOT_ENV_VARS table is vetted once at boot and INBOX_ROOT is in it, but REVIEW_ROOTS is a fifth, separately parsed root list that was in no table at all. So with the flag set, an operator could name the live agent silo in REVIEW_ROOTS and read it back through the review API: wider than what the deleted code allowed on the default layout, and a defeat of MC_LIVE_SILO_ROOT on any other one. The module header recorded that as a known gap and deferred it. Naming a hole in a comment does not close it, and it should not have shipped open. The deferral reasoned that the fix wanted a once-per-request home, because the obvious placement - assertNoLiveSiloRoot per root inside assertContained - lands on the autolink path, whose realpath cost linkifyBlockBodies shares across blocks deliberately and a regression test bounds. That reasoning was right about the constraint and wrong about there being no home: root RESOLUTION already happens once per request, not once per path. resolveReviewRoots now vets every root it is about to return, the configured entries and the implicit INBOX_ROOT alike, and throws before any of them reaches a caller. It is memoised on the root list plus the two env vars the refusal reads, so a running instance pays for it once and the autolink path pays a string compare; the perf regression test still measures 4 realpath calls for 3 blocks, unchanged. Only a pass is recorded, so a refusal can never memoise itself into a pass. Boot is covered by the same code under the name validateReviewRoots, called by the root loader beside validateConfiguredRoots, so a sandbox instance pointed at a live silo dies at start with the offending root named rather than looking healthy until someone opens the panel. The per-resolution check is not redundant with it: /api/review is a resource route, and RR7 runs a resource route's own loader only, never the root loader, so on a cold process the boot check alone would not have covered the exact request the finding describes. Two smaller decisions worth stating. A configured root that does not exist yet is vetted where it sits rather than skipped: containment skips it today, but it starts serving the moment the directory appears. And the implicit INBOX_ROOT is vetted here too even though the boot table already carries it, because on that same cold resource-route request the boot table has not run. Tests: eight cases in review.test.ts (silo root itself, a root below it, the read end to end, a not-yet-created entry, the implicit INBOX_ROOT, the boot entry point, a sibling sharing the silo's name prefix, and the unset-flag production cutover), plus one in review-autolink.test.ts pinning that the render path fails CLOSED - no links into a refused silo, and no throw out of a render. All seven refusal cases fail without this change. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix(review): a live-silo pass is not memoisable, it answers from the disk The previous commit put the MC_SANDBOX_ONLY live-silo refusal in the right place and then cached its answer in the wrong shape. The memo was keyed on the root list plus MC_SANDBOX_ONLY and MC_LIVE_SILO_ROOT, described in that commit as "everything the answer depends on". It is not. assertNoLiveSiloRoot answers from the FILESYSTEM: it returns early when the silo cannot be realpath'd, and both sides of its containment comparison are realpaths. None of that is a function of the configuration, so no key over the configuration can stand in for it. Codex reproduced the bypass in one process, not in theory. Configure a sandbox instance with MC_LIVE_SILO_ROOT=<tmp>/silo and REVIEW_ROOTS=<tmp>/silo/agents while the silo does not exist. resolveReviewRoots passes, correctly, because there is no silo to resolve, and records that pass. Create silo/agents and private.md afterwards and readReviewFile(private.md) returns the contents, off a pass recorded before the directory existed, with the env and the raw root list byte-for-byte unchanged. Retargeting a symlinked root after a pass is the same bug wearing a different hat. The fix is the shape Codex asked for: memoise only while MC_SANDBOX_ONLY is unset, where the refusal is a no-op and a recorded pass cannot go stale, and re-vet on every resolveReviewRoots() call while the guard is active. The flag is read in vetReviewRoots only to decide how long an answer stays valid, never to decide what the answer is, so assertNoLiveSiloRoot stays the one authority on the refusal itself and the vetting loop still runs at least once for any distinct root list whatever the flag says. The route-level placement is untouched: that half of the last commit was right and the finding said so. The re-vet is bounded at the granularity Codex signed off on, once per root RESOLUTION rather than once per path or per block. Every caller on this surface already resolves once per request: linkifyBlockBodies hoists resolveReviewRoots out of its block loop precisely so the realpath cost is paid per request, and the read entry points call it once each. Tests: two regression cases, the reproduction above through readReviewFile and the symlink-retarget variant Codex named as the same class. Both fail on the parent commit, and the create-after-pass one fails by returning the silo file's contents, not by some incidental difference. The autolink perf regression test needed restating rather than relaxing. It asserted an absolute bound of 4 realpath calls, measured with the memo pre- warmed outside the window, which is no longer a thing that can be pre-warmed. It now measures three blocks against six and asserts the counts are EQUAL, which is the property it was always about (nothing scales with the number of BLOCKS) stated directly instead of encoded as a constant, plus a bound of 8 on the per-call figure so a fixed cost cannot balloon unnoticed. 8 is the vetting of 2 roots, each realpath'd and compared against a realpath'd silo, plus assertContained's 4 paid once for the one distinct candidate. Without the sharing that second half alone would be 4 per block, so the regression the test was written for still fails it. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> --------- Co-authored-by: Simon <simon@inkie.ink> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
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.
Four sites were flagged as sharing one root cause: a silo directory name written into the code as a literal, where the surrounding code resolves it from configuration. Reading each one, three were real and one was not, and the two that looked like the same bug turned out to be different bugs.
What changed
1.
cron.server.ts- nudge run-state went to a hardcoded directory. The highest-severity of the set, and an outright blocker on the Scheduler against real data. The generated nudge script wrotefired/deliveredstate to a hardcoded path, andlistCronsindependently re-derived the same hardcoded path to read it back. Writer and reader agreed with each other and disagreed with the deployment, so on any instance whose agent directories are not at that exact path, state written by a fired nudge was invisible to the UI, and editing a nudge started a second state tree beside the first - splitting the per-fire-slot marker that makes delivery idempotent.Both halves now resolve from one source, the
INBOX_ROOTevery other silo-adjacent module already uses.cron-state/sits besideinbox/inside each agent's directory, soINBOX_ROOTis the correct root and no new configuration is introduced. Injected throughCronDepslike every other side effect here, and resolved lazily so a rejected target still fails as a bad target rather than as a configuration error.The root is a value rather than a literal now, so it is also shell quoted. Making it configurable puts an operator-supplied path inside the generated script's double quotes, where a
$or a backtick would expand; the old hardcoded literal had no injection surface to begin with, this quoting closes a risk the refactor itself would otherwise have introduced, not one in the code being replaced.2.
review.server.ts- a substring ban the confinement rework missed. Not the same bug as the others. TASK-434 replaced deny-known-bad with allowlist confinement acrosssafe-fs,attachmentsandprojects, for the reason recorded in safe-fs's own header: a substring ban on a silo directory name is a build-era invariant encoded at the wrong layer, and it blocks the very paths production must serve.review.server.tswas not converted with the others.Two things were wrong with what was left. The banned string is a directory name no deployment is obliged to use, so on most instances it denied nothing while reading like a protection. And
resolveReviewRootsALWAYS appendsINBOX_ROOTas an implicit root - so on an instance that did use that name, the ban and the root list contradicted each other outright, and the panel refused every read from the one root it is guaranteed to have.Containment against realpath'd roots is strictly stronger than a substring test for the traversal and symlink-escape cases the ban was reaching for, so nothing load-bearing goes with it. The tests that asserted the ban are replaced by tests for the property that actually holds the surface: a file inside a silo-shaped root is served, one outside every root is refused, and an escape through an intermediate symlink is refused on the realpath.
3.
safe-fs.server.ts-MC_SANDBOX_ONLYcould not name what it was guarding. README states FND-04's other half with no directory in it ("a sandbox configuration may never be pointed at a live agent silo"). The implementation could only ever recognise one directory: this project's default silo name joined onto$HOME.On any deployment keeping its agents elsewhere the flag was not weaker, it was inert - it refused nothing, while
.env.exampledescribed it as a protection andtest/setup.tsset it on every test run.New optional
MC_LIVE_SILO_ROOTnames the silo. Unset, the default is exactly the previous behaviour, so no existing instance changes and no existing test moves. Absolute paths only, validated at point of use rather than at boot, because the variable means nothing unlessMC_SANDBOX_ONLYis also set and failing a production start over an unused sandbox setting would be the wrong trade.This also makes the refusal testable for the first time. The single test covering it returned early unless the machine happened to have the default silo directory - which no CI machine does - so it had been passing by skipping. New cases stand a tmpdir up as the live silo and assert the refusal for real: the root itself, a sibling sharing its name prefix, the unset-flag no-op, and a blocked inbox write end to end.
4.
create-agent.sh- not the reported bug; a false citation instead. The flagged line is a fallback, not a hardcode:--inbox-rootand$INBOX_ROOTboth win ahead of it, and when it does fire it warns loudly and prints where the agent went. That design is right and is left alone.5.
review.server.ts-REVIEW_ROOTSwas vetted by nothing. Held back from the first pass and closed here, on review. Dropping the substring ban leftMC_SANDBOX_ONLYwith nothing to say aboutREVIEW_ROOTS: safe-fs'sROOT_ENV_VARStable is vetted once at boot andINBOX_ROOTis in it, butREVIEW_ROOTSis a fifth, separately parsed root list that was in no table at all. So with the flag set, an operator could name the live silo there and read it back through the review API - wider than the deleted code allowed on the default layout, and a defeat of the newMC_LIVE_SILO_ROOTon any other one. The first pass recorded that in the module header and deferred it. Naming a hole in a comment does not close it.The deferral was right about the constraint and wrong about there being no home for the fix. Per-root
assertNoLiveSiloRootinsideassertContaineddoes land on the autolink path, whose realpath cost a regression test bounds - but root RESOLUTION already happens once per request, not once per path.resolveReviewRootsnow vets every root it is about to return, the configured entries and the implicitINBOX_ROOTalike, memoised on the root list plus the two env vars the refusal reads. A running instance pays once; the autolink path pays a string compare, and that regression test still measures 4 realpath calls for 3 blocks. Only a pass is recorded, so a refusal cannot memoise itself into a pass.Boot is the same code under the name
validateReviewRoots, called by the root loader besidevalidateConfiguredRoots, so a sandbox instance pointed at a live silo dies at start with the root named. The per-resolution check is not redundant with it:/api/reviewis a resource route, and RR7 runs a resource route's own loader only, never the root loader, so on a cold process the boot check alone would not cover the exact request the finding describes.Two smaller calls. A configured root that does not exist yet is vetted where it sits rather than skipped, because it starts serving the moment the directory appears. And the implicit
INBOX_ROOTis vetted here too, even though the boot table carries it, because on that same cold resource-route request the boot table has not run.What was wrong was the wording. It announced the value as "the value from the application's
.env.example", and that file shipsINBOX_ROOTempty because there is no default (FND-03). The citation dressed a guess up as a lookup, which is the one thing a warning about guessing must not do.No behaviour change. Tests now pin the source ordering, since a fallback firing over something the operator had configured is the failure that would actually matter, and nothing covered it - the existing case passes
--inbox-rootand never reaches the fallback branch.6.
review.server.ts- the vetting was right, memoising its answer was not. Second review round. Codex read the commit above and did not stop at the reasoning: it reproduced a live read out of a silo, in one process, against this branch.The memo was keyed on the root list plus
MC_SANDBOX_ONLYandMC_LIVE_SILO_ROOT, described in that commit as "everything the answer depends on". It is not.assertNoLiveSiloRootanswers from the FILESYSTEM: it returns early when the silo cannot be realpath'd, and both sides of its containment comparison are realpaths. None of that is a function of the configuration, so no key over the configuration can stand in for it. The repro, verbatim in shape:MC_SANDBOX_ONLY=1,MC_LIVE_SILO_ROOT=<tmp>/silo,REVIEW_ROOTS=<tmp>/silo/agents, and no silo on disk.resolveReviewRoots()passes - correctly, there is nothing to refuse yet - and records the pass.silo/agents/private.md.readReviewFile(private.md)returns the contents, off a pass recorded before the directory existed, with the env and the raw root list byte-for-byte unchanged.Retargeting or replacing a symlinked root after a pass is the same bug wearing a different hat.
The fix is the shape Codex asked for: memoise only while
MC_SANDBOX_ONLYis unset, where the refusal is a no-op and a recorded pass cannot go stale, and re-vet on everyresolveReviewRoots()call while the guard is active.vetReviewRootsreads the flag only to decide how long an answer stays valid, never to decide what the answer is, soassertNoLiveSiloRootstays the one authority on the refusal itself and the vetting loop still runs at least once for any distinct root list whatever the flag says. Route-level placement untouched.The re-vet is bounded at the granularity Codex signed off on - once per root RESOLUTION, not once per path or per block. Every caller here already resolves once per request:
linkifyBlockBodieshoistsresolveReviewRootsout of its block loop precisely so that cost is per request, and the two read entry points call it once each.Two regression tests: the reproduction above through
readReviewFile, and the symlink-retarget variant. Both fail on the parent commit, and the first fails by returning the silo file's contents rather than by any incidental difference.The autolink perf regression test needed restating rather than relaxing. It asserted an absolute bound of 4 realpath calls, measured with the memo pre-warmed outside the window, and there is no longer anything to pre-warm. It now measures three blocks against six and asserts the counts are EQUAL - the property it was always about (nothing scales with the number of BLOCKS) stated directly instead of encoded as a constant - plus a bound of 8 on the per-call figure so a fixed cost cannot balloon unnoticed. 8 is the vetting of 2 roots, each realpath'd and compared against a realpath'd silo, plus
assertContained's 4 paid once for the one distinct candidate. Without the sharing that second half alone would be 4 per block, so the regression the test was written for still fails it.Deliberately not done
Also worth knowing
assertGitCleaninreview.test.tsandsafe-fs.test.tsallowlists paths likeapp/andtest/, butgit status --porcelainreports repo-root-relative paths, which since the monorepo layout arepackages/deck/app/.... The allowlist therefore matches nothing and the assertion fires on any uncommitted change under the package. Green on a committed tree, so CI is unaffected, but it makes the suite unusable mid-edit. Left alone as unrelated to this change.package.jsonalready documents. Two separate runs each produced one failure (skeleton.test.tson a 5s dynamic-import timeout; one base case), both passing in isolation and on a clean re-run.Checks
pnpm test(base 41, deck 1846 + 11 skipped, 89 files),pnpm typecheck,pnpm check:boundaries(583 modules),pnpm check:dashes,pnpm check:licence,leak-gate --self-test(30 rules),leak-gate(clean, 367 files) all green.leak-gate --messagesreports two findings, both pre-existing on historical commits (2dc627dc14,c95abce7bc) and identical to the pre-change baseline. None of the commits here appear.Re-run in a clean clone after the follow-up commit that closes the
REVIEW_ROOTSgap:pnpm test(base 41, deck 1845 + 11 skipped, 88 files - the 9 new cases included),pnpm typecheck,pnpm check:boundaries(483 modules),pnpm check:dashes,pnpm check:licence,leak-gate --self-test(30 rules),leak-gate(clean, 366 files) all green.leak-gate --messagesstill reports the same two pre-existing findings and nothing from this branch.Re-run in a clean clone after the memoisation fix (section 6): deck
pnpm test1847 passed + 11 skipped across 88 files (2 new cases),pnpm typecheck,pnpm check:boundaries(483 modules, 858 dependencies),leak-gate --self-test(30 rules),leak-gate(clean, 366 files),leak-gate --history(clean, 567 blobs / 447 object paths) all green.leak-gate --messages, run against a clone of this branch alone, reports one finding:c95abce7bc, theCo-authored-bytrailer GitHub's squash-merge UI wrote ontomainwhen PR #1 landed. Byte-identical at the parent commitf209ec1, so this branch introduces nothing - and there is a separate branch already in flight for that rule. The earlier note above says two findings because it was run in a checkout carrying other local branches; the second (2dc627dc14) is not reachable from this branch. Nothing from the commits here appears in either scope.🤖 Generated with Claude Code