Skip to content

Prove mutating tool actions before they run#9

Merged
NagyVikt merged 3 commits into
devfrom
agent/agent5/pre-tool-use-mutation-events-2026-05-01-14-58
May 1, 2026
Merged

Prove mutating tool actions before they run#9
NagyVikt merged 3 commits into
devfrom
agent/agent5/pre-tool-use-mutation-events-2026-05-01-14-58

Conversation

@NagyVikt
Copy link
Copy Markdown
Collaborator

@NagyVikt NagyVikt commented May 1, 2026

Automated by Agent 5.\n\nSummary:\n- Emit enriched pre-tool-use context before mutating tool execution.\n- Emit paired post-tool-use context with the same trace_id after execution.\n- Mark orphan mutating post events with missing_pre_tool_use: true.\n\nVerification:\n- npm run build\n- node --test dist/scripts/tests/codex-native-hook.test.js dist/config/tests/codex-hooks.test.js\n- node --test dist/hooks/extensibility/tests/dispatcher.test.js

NagyVikt and others added 3 commits May 1, 2026 15:10
Native hook dispatch now records mutating tool lifecycle context before edit-capable tools execute and pairs the post event by trace id after the tool returns. The trace state is best-effort so write failures warn and continue instead of blocking the tool path.

Constraint: Codex native hooks must stay non-blocking by default when event persistence fails

Rejected: Post-only detection | cannot prove the event preceded the mutation

Confidence: high

Scope-risk: moderate

Tested: npm run build

Tested: node --test dist/scripts/__tests__/codex-native-hook.test.js dist/config/__tests__/codex-hooks.test.js

Tested: node --test dist/hooks/extensibility/__tests__/dispatcher.test.js

Co-authored-by: OmX <omx@oh-my-codex.dev>
The dev branch already introduced the Colony bridge trace store, so the Agent 5 merge keeps one trace source and routes native hook-dispatch logs through that payload before the tool runs. This preserves post-tool missing-pre detection while avoiding a second state file.

Constraint: origin push is disabled in this checkout; PR updates use the fork remote.

Rejected: Keep src/scripts/codex-native-tool-events.ts | it duplicated the merged Colony trace marker path and created competing recordPreToolUseTrace symbols.

Confidence: high

Scope-risk: moderate

Directive: Mutating PreToolUse dispatch must remain before Colony bridge advisory output and before the tool mutation boundary.

Tested: npm run build

Tested: node --test dist/scripts/__tests__/codex-native-hook.test.js dist/config/__tests__/codex-hooks.test.js

Tested: node --test dist/hooks/extensibility/__tests__/dispatcher.test.js

Tested: node --test dist/colony/__tests__/bridge.test.js dist/cli/__tests__/colony.test.js

Tested: git diff --check && git diff --cached --check

Co-authored-by: OmX <omx@oh-my-codex.dev>
Dev moved again with lifecycle replay and runtime-summary work, so this merge preserves the newer repo-relative extracted-path handling while keeping Agent 5 pre/post hook-dispatch proof and missing-pre marking.

Constraint: PR #9 base advanced through PRs #7, #8, and #10 while Agent 5 was open.

Rejected: Prefer old raw-path helper | current dev has normalized repo-relative extraction and lifecycle event tests that should stay authoritative.

Confidence: high

Scope-risk: moderate

Directive: Keep mutating PostToolUse coverage aligned with the PreToolUse mutator matcher plus MCP/OMX parity post hooks.

Tested: npm run build

Tested: node --test dist/scripts/__tests__/codex-native-hook.test.js dist/config/__tests__/codex-hooks.test.js

Tested: node --test dist/hooks/extensibility/__tests__/dispatcher.test.js

Tested: node --test dist/colony/__tests__/bridge.test.js dist/cli/__tests__/colony.test.js dist/colony/__tests__/lifecycle-events.test.js dist/runtime/__tests__/colony-runtime-summary.test.js

Tested: git diff --check && git diff --cached --check

Co-authored-by: OmX <omx@oh-my-codex.dev>
@NagyVikt NagyVikt merged commit 98e5a1f into dev May 1, 2026
8 of 10 checks passed
@NagyVikt NagyVikt deleted the agent/agent5/pre-tool-use-mutation-events-2026-05-01-14-58 branch May 1, 2026 13:36
@github-actions github-actions Bot added the size/L label May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant