Skip to content

Share command reading and policy across provider packages - #78

Merged
erickb336 merged 2 commits into
mainfrom
codex/shared-command-policy
Oct 7, 2026
Merged

erickb336 merged 2 commits into
mainfrom
codex/shared-command-policy

Conversation

@erickb336

Copy link
Copy Markdown
Owner

First focused split from #75, based on main ea9f728 after #72 and #73 merged.

Claude keeps the same command rules in a complete plugin. Command parsing, program resolution, executable-text filtering, and T199's expanded-word rule now live in sage-core. Both provider bundles can use one implementation through the public core entry point. No dependency is added.

Merge/push approval, file rules, mode phrases, lead limits, and the Codex runtime remain outside this PR.

Behavior and scope

  • All 146 existing hook tests keep their assertions. The owner approved a fixture-only correction: copy the complete plugin before breaking the state tool. The full suite exposed the same incomplete-copy problem in the launcher fallback fixture; it now copies the missing core directory while preserving its release metadata. Both fixtures keep every assertion unchanged.
  • Required command modules that cannot load now cause a command refusal. Review caught and closed an extraction regression that could otherwise allow a protected GitHub API write. A new test covers four missing files, main/child actors, Sage on/off, and four command tools.
  • T199 stays before the Git checks. Expanded program/subcommand words are refused; ordinary argument braces and globs retain their behavior. Its tests remain unchanged.
  • The provider supplies its state-tool path for harmless-text classification.
  • No Claude-owned issue is implemented. Follow-up command changes belong in packages/sage-core/command-reader.mjs and packages/sage-core/command-policy.mjs. Provider event handling stays in the Claude hook. Claude work on overlapping rules must account for these moved functions.

Validation

Fake ps, pgrep, and kill were first on PATH for every test run. Test command strings went only to parsers or hook inputs, never to a real shell.

Command Last result
npm run build built 108 files
npm run check all checks pass
node --test --test-name-pattern='missing command modules|the merge check refuses a merge when it cannot run' scripts/sage-hook.test.mjs tests 2; pass 2; fail 0
node --test scripts/launcher.test.mjs tests 17; pass 17; fail 0
npm test tests 471; pass 471; fail 0
git diff --check Exit 0

Main-failure proof used a detached worktree from origin/main (ea9f728), with only the two test files copied over. With fake process tools first on PATH:

node --test --test-name-pattern='missing command modules|shared command extraction' scripts/sage-hook.test.mjs scripts/providers.test.mjs

Result: tests 3; pass 0; fail 3. Main lacks the shared APIs and the new module-load refusal. The missing-module test also failed against the extraction before the fix, with no refusal for the protected API command.

The two shared API tests check pipe relationships, program input, parsing failures, T199 refusals, ordinary controls, and the provider's state-tool path in isolated copies of both bundles. Independent review found no remaining issue after the fix.

Seen, not fixed / not verified

The parser's existing limitations remain. This extraction does not implement #69, #70, #58, or automatic Codex command enforcement. Native shell execution and a live Claude session were not tested. The broad lifecycle draft and its dependency advisory remain separate in #75.

@erickb336 erickb336 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex review at 4d6155be3d3dbbe241688ce43654ffeede83466d: no remaining blocking findings. The owner requested this review because Claude usage is exhausted; the owner will merge.

Independent code/security review confirmed that program resolution, shell parsing, T199 expansion checks, and runnable-text classification preserve the original behavior. Required command-module failures produce a denial before mode and actor gates. QA confirmed both isolated provider bundles and all 64 missing-module combinations. Existing test assertions remain unchanged; the authorized fixture corrections supply the complete plugin.

Review found one nonblocking trailing blank line in the shared source and generated copies. Commit 4d6155b removes it through the source and build; the reviewer confirmed that the correction changes no logic.

Fresh validation of the corrected tree, with fake process tools first on PATH:

  • npm run build: built 108 files.
  • npm run check: all checks pass.
  • npm test: tests 471; pass 471; fail 0.
  • git diff --check ea9f728: exit 0.

The missing-module regression was rerun on detached main ea9f728: tests 1; pass 0; fail 1, because main returns no denial. The PR body records the separate shared-API red proof.

No live Claude session or native shell execution was tested. Existing parser limitations and queued policy issues remain outside this extraction. This is a Codex review of our work, with separate code/security and QA passes; it is not an external maintainer approval. Local checks are complete; the new CI run must pass before merge.

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