Repository navigation
chore(agents): rule 73 becomes a blocking check, Stop test gate on, Codex hook config validated - #2790
Conversation
… Code and Codex; Codex hook validation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
Merging this PR will not alter performance
Comparing Footnotes
|
…opts[i], receivers, generics, load-then-modify, truthiness forms, switch, anchored opt-out)
…files only, validated rule paths, quoted paths) and close Stop-gate test gaps
…hook moves to sam/codex-rule-delivery-hook (Codex sessions in SAM do not run repository hooks)
|
@coderabbitai review |
Action not completed
|
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* refactor(api): move cron expression parsing into packages/cron First slice of the apps/api/src/services split (seam map: SAM idea 01M7HXHPQ46H3YK0GC9Q2QHAFF). services/cron-utils.ts moves unchanged to packages/cron; its unit test moves with it. The ten worker importers and six worker tests import @simple-agent-manager/cron instead of the old path. No re-export is left behind. Wiring: apps/api dependency, CI path filters, runtime-boundary scope, build order in CLAUDE.md, rule 08 and the local-development guide, a package AGENTS.md, regenerated rule indexes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(agents): regenerate cron package rule index after #2790 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(quality): scan packages/cron in ast-checks; record review evidence Review follow-ups for the cron package move: the API AST checks scanned cron-utils.ts before the move, so they now scan packages/cron/src as they do the other worker packages. AGENTS.md says who consumes the package, and the task file records the evidence and the rule 51 decision. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * task: archive extract-cron-package Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(sonar): keep the moved cron test out of copy/paste analysis SonarCloud counts packages/cron/tests/unit/cron-utils.test.ts as new code after the move, and its repeated test blocks (102 lines, unchanged from the old path) failed the new-code duplication gate. Tests are excluded from CPD by policy (sonar-project.properties); automatic analysis needs the exact path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(agents): trim cron additions to stay inside the launch-context budget Claude Code launch context reached 210,107 bytes against the 210,000 ceiling after rebasing onto main. Shorten the CLAUDE.md structure line and drop cron from the rule 08 diagram, where it implied the worker module packages depend on it; both build-order sentences still list cron. Net launch addition is now 68 bytes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Raphaël Titsworth-Morin <raphael@raphaeltm.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>



Summary
Stream A of the agent-context work (SAM task 01M7HX013ZBS5KJAXB0H707DEJ; plan, reviews and probe reports on idea 01M7H32EK6S4E31EHWVSJSENR5). Raphaël asked for all three parts on 2026-11-16 (chat 749fad59). Outcome per part:
sam/codex-rule-delivery-hookOne PR: the parts share
check-agent-context-budget.ts,agent-hook-config.ts, the CI step and filter, and one test entry point; none changes deployed code.1. Rule 73: blocking check, then out of launch context
scripts/quality/go-optional-fields/(Go standard library,go/ast). Options value: a param or receiver whose struct type ends inOpts/Options/Opt/Patch/Override(s), a variadic of one or namedopts,opts[i], and locals bound from them (aliases, generics, embedded fields resolved). Reports a non-string scalar field (bool, int, float,time.Duration, named type over one) written onto existing state, directly or via an expression (!o.F,T(o.F)) or a replacing struct literal (*r = R{F: o.F}), when no enclosingif/case/early-return checks it was supplied (field mention orHasF-style presence flag; else/default branches andif o.F != r.Fdo not count), or when the only check is its own truthiness (if o.F,o.F > 0, alsoif o.F { r.F = true }). Writes onto locals the function builds are construction, unless the local is loaded, passed to a call, address-taken or written through.//sam:optional-field-ok <reason>opts out (reason required, anchored to the statement).workspace_routing.go(a1c1d00^) yields exactly one finding,runtime.Lightweight, and none for its 13 guarded strings.main_test.gopins every shape with// wantannotations, including all the variants a Go review of the first version found (it reported 3 HIGH:opts[0].Fand load-then-modify missed, any variadic struct treated as options; all fixed). Deleting each of seven guards reddens its fixture.pnpm quality:go-optional-fields.patch.x ?? false, spreads) are 46 sites today and the ones inspected are creation defaults. SQL override layer (NOT NULL DEFAULToverride column): not checkable without a declared registry of which table overrides which; stays judgment text, scoped to**/*.sql.paths: **/*.go, **/*.ts, **/*.tsx, **/*.sql(coversapps/api/src/db/migrationsand the TS Durable Object migrations) and an "Enforcement" section; removed fromlaunchRules. Claude Code launch context 214.5 KB on main -> 204.8 KB (ceiling 220,000 -> 210,000; the procedure added to the always-loaded routing rule costs 1.7 KB of the 11.4 KB). It now loads on first access to any Go/TS/TSX/SQL file instead..tsfile (the same tool call, so the first write itself precedes it);--observed"model matches the session". C2 (01M7HYQVK025M14GN4QG9G8WTF): loaded on the Read of0200_skills_optional_agent_type.sql, before any edit (Claude Code requires a Read before Edit);--observedmatches. The mechanical part is caught by the blocking check whichever comes first..claude/rules/00-rule-routing.md, "Taking a Rule Out of Launch Context".2. Codex rule delivery: experiment run, not good, not shipped
additionalContext, deny-once before the first write, log, generated lookup with a--checkstaleness gate, Node built-ins only), tested, then security-reviewed and hardened.CODEX_HOMEunset; the vm-agent-written~/.codex/config.tomlhas no trust entry for the repository and no hook-trust records, and Codex runs project hooks only for trusted projects and trusted hook definitions. (Round 1, 01M7HXMSG7M18TYKAEKHTBZEF0, was inconclusive:.gitignorehad kept.codex/hooks/out of the commit, which probe C2 caught; fixed, and--checknow judges hook scripts and generated files by what git can see.) A nested trustedcodex exec(01M7HY7P831WQG19HADM5JS85X) could not complete ("failed to load workspace requirements").sam/codex-rule-delivery-hook(f3b156c). Making them live needs the vm-agent to trust repository hooks: a security-design decision put to Raphaël (idea 01M7J0TXAHGRY8CWA7Y7SJZAK0).checkCodexHookConfigvalidates Codex hook entries against the current schema (events, matcher groups, handler fields, timeouts, skippedprompt/agenthandlers,[features] hooks = false); the flat[[hooks.Stop]]entry that held no handler is removed and would now fail--check.3. Test-quality Stop gate, fixed and switched on (Claude Code)
.claude/hooks/verify-test-quality.sh->.claude/hooks/verify-test-quality.mjs(Node built-ins), enabled in.claude/settings.json.origin/main, preferred over a stale localmain), staged, unstaged and untracked changes seen;packages/project-data/src/doand the worker packages covered;stop_hook_activeno longer bypasses findings; no pipes (no exit 141); output only{}or{"decision":"block","reason":...}. After the security review: fails open if its state cannot be saved, reads regular files under 1 MB only, hashes long session ids.untested-boundary-changeflagged 2 of 80 (4 of 300); one false positive (pure move refactor(api): split tts, ai-token-budget and agent-loop (L3, pure move) #2733), one plausible (fix: stop stale project sockets from disabling chunk merging #2774) -> feedback (continues the turn once per session and finding set).shallow-testflagged 0 of 300 -> block, at most 3 times.Validation
pnpm quality:agent-tooling:test(110 tests),pnpm quality:go-optional-fields(Go table tests + whole-repo run),pnpm quality:agent-context-budget --check, CI wiring tests (22)pnpm lint(exit 0 earlier on this branch; focused ESLint on every changed TS/MJS file at the head)pnpm typecheck: not run to completion locally (workspace restarts);scripts/qualityis outside the turbo typecheck. Focused stricttscon the changed files: no new errors (one pre-existing--observedargument line, unchanged from main)pnpm test: not run; no package or app code changed. The affected suites are the script tests above, which CI runs in Code Quality ChecksStaging Verification (REQUIRED for all code changes — merge-blocking)
N/A: no deployed code changes. The diff is agent hook scripts (
.claude/hooks/), repository quality tooling (scripts/quality/), the CI workflow, rules andAGENTS.mdfiles. Nothing underapps/*/src,packages/*/srcorpackages/vm-agentchanges, so no Worker, web bundle or VM agent changes on deploy. The hooks were verified in real harness sessions instead (probes above).Staging Verification Evidence
N/A: tooling-only; see the harness probes in Summary.
UI Compliance Checklist (Required for UI changes)
N/A: no UI changes.
UI Screenshot Evidence
N/A: no UI changes.
End-to-End Verification (Required for multi-component changes)
Data Flow Trace
Stop gate: Claude Code Stop event ->
.claude/settings.jsonhandler ->verify-test-quality.mjs:run->changedFiles(git merge base, diff, ls-files) ->evaluate->decide(+.tmp/stop-gate/<session>.json) -> stdout JSON. Rule 73:pathsfrontmatter ->agent-instructions.ts:InstructionModel.loadsOnAccess-> generated indexes; Claude CodeInstructionsLoadedlog ->--observed.Untested Gaps
Codex: no repository hook runs in SAM Codex sessions (see part 2); tracked in idea 01M7J0TXAHGRY8CWA7Y7SJZAK0.
Post-Mortem (Required for bug fix PRs)
N/A: not a bug fix. (The Stop gate never ran because of a malformed entry; history in idea 01M7H8SDG77AE0FH39QXW3NPYX.
agent-hook-config.tsnow also checks Codex entries and that hook scripts are in the repository.)Specialist Review Evidence (Required for agent-authored PRs)
needs-human-reviewlabel added and merge deferred to humanopts[i].F, missed load-then-modify, variadic false positive) and the MEDIUMs fixed in 0854ed5 / 6085038; reviewer fixtures now pinned intestdata/CodeRabbit Review Evidence (Required for agent-authored PRs)
CodeRabbit Notes
No review. Requested with the
coderabbit-reviewlabel when the PR was marked ready (11:12:18Z); the request workflow (run 43855669453) succeeded and CodeRabbit replied at 11:15:39Z "Action not completed: Review rate limited", which ends the wait (policy 73ed7a68). Its earlier 10:36Z comment was the automatic "Review skipped: auto reviews are disabled" when the draft was opened.Exceptions (If any)
Agent Preflight (Required)
Classification
External References
Official documentation, fetched 2026-11-16: Codex hooks https://developers.openai.com/codex/hooks (event/matcher-group/handler shape, trust model, SessionStart sources, PreToolUse tool coverage, additionalContext spill limit, Stop output contract); Codex config schema https://developers.openai.com/codex/config-schema.json (HooksToml, MatcherGroup, HookHandlerConfig, HookStateToml); Claude Code hooks https://code.claude.com/docs/en/hooks (Stop decision control, handler fields). Context7 not used: the official pages above are the primary sources.
Codebase Impact Analysis
.claude/hooks/verify-test-quality.mjs(new, replaces.sh),.claude/settings.json(Stop entry),.codex/config.toml(broken flat Stop entry removed; no hooks),scripts/quality/agent-hook-config.ts(Codex validation, script existence),check-agent-context-budget.ts(hook findings judged by git-visible files),agent-rule-index.ts(backticked wildcard scopes),agent-context-budget.json(73 out oflaunchRules, ceiling lowered),go-optional-fields/(new Go module), tests,.github/workflows/ci.yml(filter + three steps),package.json(two scripts),.claude/rules/00-rule-routing.md,.claude/rules/73-...md, generatedAGENTS.mdindexes, newapps/installer/AGENTS.mdandpackages/harness/AGENTS.md. No runtime code in apps/ or packages/ src changes.Documentation & Specs
scripts/quality/README.md(Stop gate with numbers, Codex hooks status, rule-73 check),.claude/rules/00-rule-routing.md(procedure for taking a rule out of launch context),.claude/rules/73-optional-struct-fields-must-not-overwrite-on-absence.md(Enforcement section, scope).Constitution & Risk Check
Principle XI: the Stop gate's modes, block limit and file-size cap are named constants documented with their measurements. Principle X (simplicity): no new dependencies; the hook uses Node built-ins, the checker the Go standard library. Risks: the Stop gate could nag on a false positive (bounded: feedback once; block at most 3 times; fails open if it cannot keep state); rule 73 out of launch context (mitigated by the blocking check, the four-language scope and the fresh-session probes). No SAM policy or knowledge value changed;
launchRuleschanged only for rule 73.🤖 Generated with Claude Code