Repository navigation
feat(sbx): sbx up --cortex loads the project's CLAUDE.md - #629
Conversation
With Cortex v0.9.3+, up installs Cortex's moca-sandbox script and writes the agent configuration without the Read deny that stops CLAUDE.md loading (rossoctl#568). Without the flag, up is unchanged. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Hai Huang <[email protected]>
…list Nothing calls it yet; sbx up --cortex and doctor will. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Hai Huang <[email protected]>
…ool denies The record keeps cortex: true, so a later up keeps the mode; denies an earlier up added are taken back, and the developer's own stay. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Hai Huang <[email protected]>
…octl#568) Before anything is created, up checks Cortex's agentop is v0.9.3 or later and installs its moca-sandbox script; the agent configuration is then written without the local-tool denies, whose Read deny stopped CLAUDE.md loading. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Hai Huang <[email protected]>
In place of the local-tool denies, it checks the script is installed and loaded, and says what to do when it is not. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Hai Huang <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Hai Huang <[email protected]>
…x mode Found in the live run: in a Cortex-mode repo it said every local tool was denied. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Hai Huang <[email protected]>
install.sh --ref=main installs an agentop that prints 'agentop main-<sha7>', which up --cortex refused as not a version. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Hai Huang <[email protected]>
…rtex The moca-sandbox install edits the shared ~/.cortex and reloads its proxy, so a conflict in the repo's agent configuration now stops up before it runs, as up's help promises. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Hai Huang <[email protected]>
pdettori
left a comment
There was a problem hiding this comment.
Review of sbx up --cortex — agentop integration, Cortex-mode agent config, doctor check, docs.
Author: huang195 (MEMBER — maintainer)
Areas reviewed: TypeScript (src + tests), Docs, Security
Agent/IDE config (.claude/.vscode): none — the code writes .claude/settings.json at runtime (existing up behavior); no repo config files changed
Commits: 9 commits, all signed-off: yes
CI status: passing (14/14)
Verified:
agentop.tsspawns the external binary viaexecFilewith fixed literal args — no injection surface; timeouts andmaxBufferbound hangs and output size;script list --jsonoutput is parsed defensively and fails closed.- Deny removal in Cortex mode drops only items moca's own manifest recorded; hand-written denies survive, and the deny container is removed only when
upcreated it. - Ordering: the agent-config conflict check and the agentop version/install both run before anything is created, bound or pushed — a repository cannot end up with un-denied local tools and no Cortex blocking in place.
- The mode is sticky via
cortex: true, validated strictly; a malformed record fails safe to the strict (deny) checks. - 35 new tests cover the version matrix, install failure, migration, doctor rows, and flag misuse.
One note: the first bullet under "Known gaps" (install running before the agent-config conflict check) is fixed by c7d34ba — the conflict check now runs first, with a test. Consider updating the PR description.
Assisted-By: Claude Code
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Summary
Clean, well-bounded change. up --cortex keeps every Cortex step (version check, script install) after the agent-config dry run and before anything is created, bound, or pushed. The deny migration only takes back items the record says up added, and goes through dropAt's guards. Cortex mode is read only from a validated record. Without the flag nothing changes. Checked against rossoctl/cortex#1507 / v0.9.3: the agentop --version format, the script list --json field contract (scripts[], state, scripts, loaded, notStarted), and the installed state semantics all match, and the slot is installed fail_closed. Accepting main-<sha> builds is safe: a pre-#1507 main build has no script install, so up stops at the install.
Only nits below, plus two for the description and docs:
- The first "Known gap" in the PR description (the install touches
~/.cortexbefore the conflict check) is out of date. c7d34ba moved the dry run ahead of the install, and sbx-up-cortex.test.ts covers that ordering. - SBX0 §6.1's
doctorrow still says the config "denies every local tool". You already listed this; a short Cortex-mode qualifier would close it.
Author: huang195 (MEMBER, maintainer)
Areas reviewed: TypeScript (mocactl sbx: agent-config, agentop, cli, doctor, sync), tests, docs/specs
Agent/IDE config (.claude/.vscode): none
Commits: 9 commits, all signed-off: yes
CI status: passing
| say(c, `Cortex could not install ${MOCA_SANDBOX}: ${got.message}`); | ||
| return SBX_EXIT.failed; | ||
| } | ||
| if (got.message) c.io.err(got.message); |
There was a problem hiding this comment.
nit: agentop's install output goes to the terminal raw, while everything else in cmdUp goes through say() and sanitizeRemote. You already list it as a known gap. A one-line fix closes it:
if (got.message) c.io.err(sanitizeRemote(got.message));|
|
||
| **Before anything is created, bound or pushed** (where `up` already checks the agent configuration): | ||
|
|
||
| 1. **agentop.** `agentop --version` must answer `agentop vX.Y.Z` with `X.Y.Z` at least `0.9.3`, or `agentop dev…`. |
There was a problem hiding this comment.
nit: The spec has drifted from the code here. agentopProblem also accepts agentop main-<sha> (c64c75b), and the error up prints is sbx up --cortex: agentop is vX; Cortex mode needs v0.9.3 or later; install it with: … (sync.ts:342), not the quoted line. Please bring step 1 in line with the code.
|
|
||
| ## 8. Testing | ||
|
|
||
| vitest, in the existing files, through the harness's fake exec (`test/helpers/sbx.ts`): |
There was a problem hiding this comment.
nit: This says the tests go "in the existing files", but they landed in four new files: sbx-agentop, sbx-agent-config-cortex, sbx-up-cortex, sbx-doctor-cortex. Please update the list.
Problem
sbx updenies Claude Code's 17 local tools in.claude/settings.json, so the agent works only through the sandbox.Readdeny also stops Claude Code loading the project's ownCLAUDE.md. An allow rule can't carve an exception out of a deny (sbx up's agent config: the CLAUDE.md steering never loads (Read deny), and stale deny names warn on every startup #568).CLAUDE.md(its coding rules, commands, conventions) still never reaches the agent.What this does
mocactl sbx up --cortexlets Cortex keep the agent off local tools instead of a deny list:upchecksagentop --versionis v0.9.3 or later (dev andmain-<sha>builds accepted), then runsagentop script install moca-sandbox. Either failing stopsupwith nothing created, bound or pushed.permissions.denyentries. The server, allow rule,enabledMcpjsonServers,opencode.jsonand the rules block are unchanged.cortex: truein.sbx/agent-config.json, so a later plainupkeeps it. Denies an earlierupadded are taken back, and the developer's own denies stay.sbx doctorskips the deny check in Cortex mode and adds acortexcheck: the script is installed and loaded, with a fix named for each failure.sbx rmis unchanged. Cortex's install stays, since other repos may use it.Without
--cortex, nothing changes and agentop is never run. moca does not depend on Cortex.The Cortex side shipped in v0.9.3: the moca-sandbox script (rossoctl/cortex#1495) and
agentop script install(rossoctl/cortex#1507). In sessions that carrymcp__sandbox__*tools, the script:blocked__<name>;Design:
docs/specs/2026-10-27-sbx-up-cortex-design.md. SBX0 §6.3 and the user guide are updated.Testing
sbx-*files pass:sbx-agentop,sbx-agent-config-cortex,sbx-up-cortex,sbx-doctor-cortex.tsc --noEmiton mocactl is clean, and the repo's prettier 3.9.10 is clean.make typecheck/make lintweren't run locally (no pnpm or built pi-fork on this laptop).CredentialsOverlay×2,LeaveTurnOverlayandOnboardingOverlay. They fail the same way on untouched main, and pass rerun file by file.up --cortexinstalled the script (1/1 loaded) and wrote settings with no deny;CLAUDE.md's rule, it had no local Bash, and a localtouchnever happened;doctorpassed;rmtook back all five files and.sbx/, and deleted the sandbox.Known gaps
up --cortexinstalls the script, which changes~/.cortex, before the agent-config conflict check. A conflict then stopsupafter Cortex was already touched. The install is idempotent and inert outside sandbox sessions.sanitizeRemote.upin a Cortex-mode repo names--cortexin its errors, and a migration guard failure printsrmadvice.doctorrow still says the config denies every local tool. The user guide doesn't say how to leave the mode:sbx rm, then a plainup.Readdeny added by hand in Cortex mode isn't flagged bydoctor.upprints a note saying it must.Assisted-By: Claude (Anthropic AI) [email protected]