Objective
Route every Pi history mutation through one generic admission boundary before it reaches live context or JSONL, including assistant output, summaries, extension messages, and bash output.
Context
Scope
- Pi agent-core: add
beforeAssistantMessageAppend, applied at both finalization sites before context mutation and message_end.
- Pi coding-agent: replace per-kind admission methods with generic
admitMessage(message, {origin, source?}); add MessageOrigin; route user, tool result, assistant, compaction summary, branch summary, extension message, and bash execution append paths through one private helper.
- Preserve ordering after input/template/skill, afterToolCall, and session_before_compact transformations.
- Denials: user/custom/summary/bash fail visibly without append; tool result uses existing protocol-safe marker; assistant replaces text blocks while preserving thinking/tool calls.
- Runtime adapter/Egress Gate: origin-specific hook/envelope mapping and strict adapters with immutable-field validation; Describe advertises every binding.
- Non-goals: whole-context attestation, provider schema redesign, caller identity.
- Backward compatibility: not required.
- Dependencies: Phase 0 merged/accepted on all affected branches.
Implementation Notes
Use the hook/envelope table in the tracker source plan. Images fail closed. Do not add one Pi extension hook per origin; the public Pi surface is the generic admitMessage method plus the necessary agent-core assistant finalization hook.
Acceptance Criteria
Required Validation
- Pi:
npm run check and focused agent/coding-agent tests per Pi AGENTS.md.
- Research:
make check and JS adapter tests.
- Integration: poisoned-session regression scenario.
PR Expectations
Review Pi API minimality separately from adapter/schema correctness. Explicitly report production/test line counts and any append path intentionally excluded.
Objective
Route every Pi history mutation through one generic admission boundary before it reaches live context or JSONL, including assistant output, summaries, extension messages, and bash output.
Context
Scope
beforeAssistantMessageAppend, applied at both finalization sites before context mutation andmessage_end.admitMessage(message, {origin, source?}); addMessageOrigin; route user, tool result, assistant, compaction summary, branch summary, extension message, and bash execution append paths through one private helper.Implementation Notes
Use the hook/envelope table in the tracker source plan. Images fail closed. Do not add one Pi extension hook per origin; the public Pi surface is the generic
admitMessagemethod plus the necessary agent-core assistant finalization hook.Acceptance Criteria
Required Validation
npm run checkand focused agent/coding-agent tests per PiAGENTS.md.make checkand JS adapter tests.PR Expectations
Review Pi API minimality separately from adapter/schema correctness. Explicitly report production/test line counts and any append path intentionally excluded.