4.3 KiB
4.3 KiB
Delegation intent: Hook public surface hardening
Intent
Harden pod::hook so it can be safely used as the public Hook contribution boundary for the feature/plugin registry. Public Hooks must not expose internal llm_worker::Interceptor action types that can inject raw model-visible Item values into request/history paths.
Requirements
- Audit the current public Hook API in
crates/pod/src/hook.rsand its bridge incrates/pod/src/ipc/interceptor.rs. - Replace or wrap public Hook outputs that currently reuse internal interceptor action types with safe public action subsets.
OnPromptSubmitalready usesHookPromptAction; use the same pattern for events that need public actions.- Public Hook APIs must not expose raw
Itemvector injection such asPreRequestAction::ContinueWith(Vec<Item>)orTurnEndAction::ContinueWithMessages(Vec<Item>).
- Preserve internal mechanisms that legitimately need richer
llm_worker::Interceptoractions, but keep them internal and separate from public feature/plugin Hooks. - Preserve current manifest permission policy behavior.
PreToolCalldeny/ask still fails closed through the existing synthetic tool result path.
- Preserve usage tracking behavior.
- Clarify through names/types/tests which Hook events are observation-only and which can cancel/abort/yield/deny.
- Add focused Pod-layer tests for public Hook behavior and short-circuit ordering.
Invariants
- Do not add hidden prompt/context injection paths.
- Do not mutate session history from public Hooks except through already-approved durable host paths.
- Do not expose
llm_worker::Itemor raw history/message vectors through public plugin/feature Hook actions. - Do not implement plugin runtime, feature registry, MCP, or WorkItem tools in this ticket.
- Do not weaken manifest permission enforcement.
- Keep
llm_worker::Interceptorinternal capabilities available where currently required by Pod internals.
Non-goals
- Implementing
plugin-feature-contribution-registry. - Adding new Hook event kinds unless the audit finds a strict safety gap.
- Allowing Hooks to rewrite tool outputs or arbitrary model context.
- Broad refactors of Pod/Worker runtime unrelated to the Hook surface.
Suggested files to inspect
crates/pod/src/hook.rscrates/pod/src/ipc/interceptor.rscrates/pod/src/permission.rscrates/pod/src/pod.rscrates/llm-worker/src/interceptor.rscrates/llm-worker/tests/parallel_execution_test.rs
Known observations from pre-delegation investigation
- Current production Hook use is light:
PermissionHookimplementsHook<PreToolCall>incrates/pod/src/permission.rs.UsageTrackingHookusesPreLlmRequestfromcrates/pod/src/pod.rs.
OnPromptSubmitalready has a safe public subset action:HookPromptAction.PreLlmRequestandOnTurnEndcurrently expose internal action types with rawIteminjection capability.PostToolCallis currently observation + abort only and does not rewrite tool output; keep that conservative unless a strictly bounded explicit transform is justified, which is not expected for this ticket.- Existing
llm-workerinterceptor tests cover some lower-level behavior, but Pod-layer Hook coverage should be improved. cargo test -p pod hook --libpassed during investigation.- Individual relevant
llm-workerinterceptor tests passed, but the fullparallel_execution_testfile had an unrelated timing-sensitive failure (test_parallel_tool_executiontook ~1.37s instead of ~100ms). Do not treat that file-wide failure as a Hook blocker without confirming.
Validation
Run at least:
cargo test -p pod hook --lib- focused Pod Hook tests added/updated by this ticket
cargo test -p pod --libcargo test -p llm-worker --libcargo check --workspace --all-targetscargo fmt --check./tickets.sh doctorgit diff --check
If broader validation fails due to pre-existing unrelated timing flakes, report exact command/output and run focused commands that isolate this change.
Completion report
Report:
- worktree path / branch
- commit hash
- changed files
- public Hook API changes
- internal mechanism separation
- tests added/updated
- validation commands and results
- unresolved risks or follow-up recommendations
- whether the work is ready for external review