Skip to content

Share file restrictions and mode phrases across provider packages - #82

Merged
erickb336 merged 8 commits into
mainfrom
codex/shared-file-mode-policy
Oct 7, 2026
Merged

erickb336 merged 8 commits into
mainfrom
codex/shared-file-mode-policy

Conversation

@erickb336

Copy link
Copy Markdown
Owner

Third focused lifecycle split from #75, based on main c1cd496 after #80 and #81 merged.

Mode-phrase recognition and the chief's direct-edit decision now live in the public core API. Claude still classifies prompt origin, changes session state, and supplies the actor and operation. Logbook path checks remain in its hook.

Scope and compatibility

  • The mode phrases, owner restrictions, off precedence, and chief edit refusal keep their existing behavior in a complete plugin.
  • A missing mode module clears cached autopilot before tool dispatch. Missing file rules refuse edits in active Sage mode; missing transitive core modules retain the existing command refusal.
  • Claude converts saved sage flags with Boolean at its adapter boundary. This preserves the old handling of truthy saved values such as 1 and "on" and avoids an exception that could permit an edit.
  • Existing hook tests remain unchanged. One launcher fixture adds only a copy of its required core directory. Its assertions and release metadata stay unchanged, following the fixture-only correction approved for the split work.
  • No role limits, runtime integration, new dependencies, or Claude-owned issue work. Follow-up phrase changes belong in packages/sage-core/mode-policy.mjs; the direct-edit decision belongs in packages/sage-core/file-policy.mjs. Provider prompt framing and logbook path checks stay in the Claude hook.

Validation

Fake ps, pgrep, and kill were first on PATH for every test run. Fixtures use temporary saved state and logbook folders. Test commands reached parsers or hook inputs only.

Command Last result
npm run build built 118 files
npm run check all checks pass
node --test scripts/providers.test.mjs scripts/launcher.test.mjs tests 35; pass 35; fail 0
npm test tests 479; pass 479; fail 0
git diff --exit-code origin/main -- scripts/sage-hook.test.mjs scripts/sage.test.mjs Exit 0; hook tests unchanged
git diff --check origin/main Exit 0

Four new shared-policy tests fail on detached origin/main (c1cd496) with only the provider test file copied over: tests 4; pass 0; fail 4. Main lacks the shared APIs and new module-failure handling. Run the cases with node --test --test-name-pattern='shared file and mode extraction' scripts/providers.test.mjs.

The saved-flag cases extend the new file-policy test. They exercise the real hook subprocess across four file tools with truthy and falsey saved flags. The added case failed on this extraction before repair at Edit with sage=1, with no refusal. All 24 compatibility cases pass on main, confirming that the fix restores prior behavior.

Independent review found no remaining issues after the saved-flag repair.

Not verified

A live Claude or Codex session and automatic Codex enforcement are outside this extraction.

…sh-policy

# Conflicts:
#	packages/sage-claude/hooks/command-policy.mjs
#	packages/sage-claude/hooks/sage-hook.mjs
#	packages/sage-core/command-policy.mjs
#	packages/sage-core/index.mjs
#	plugins/sage-codex/core/command-policy.mjs
#	plugins/sage-codex/core/index.mjs
#	plugins/sage/core/command-policy.mjs
#	plugins/sage/core/index.mjs
#	plugins/sage/hooks/command-policy.mjs
#	plugins/sage/hooks/sage-hook.mjs
#	scripts/providers.test.mjs
…e-policy

# Conflicts:
#	packages/sage-claude/hooks/sage-hook.mjs
#	packages/sage-core/index.mjs
#	plugins/sage-codex/core/index.mjs
#	plugins/sage/core/index.mjs
#	plugins/sage/hooks/sage-hook.mjs
#	scripts/providers.test.mjs

@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 of commit 7f78dafcbcd31bd8429cd39f0c8fb1321fd4e403: no remaining findings.

Independent review checked mode phrases, owner checks, off precedence, saved-state compatibility, missing-module refusal, and unchanged existing hook/state tests. The launcher fixture only copies the newly required core directory; its assertions remain unchanged.

Build and check pass. The full suite passes: 479 tests, 479 pass, 0 fail. All four new test groups fail on detached main c1cd496 with only the test file copied over. Live provider sessions and automatic Codex enforcement were not tested in this extraction.

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