Skip to content

Phase 1: route every Pi history append through admission #52

Description

@johnnygreco

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

  • Every named origin is admitted before live context and JSONL.
  • Denied raw text is absent; replacements are persisted and emitted.
  • Assistant deny/replacement preserves tool calls and does not poison the next turn.
  • Immediate/deferred bash and all custom-message delivery paths are covered.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions