Trim verbose comments · Entire

Trim verbose comments

Sessions

551356371281View transcript

Changes

2

70 unmodified lines

// piSkillEvents converts the Pi extension's live skill-invocation reports into // agent.SkillEvents. This is Pi's ONLY skill-capture path, and it is captured // live: the embedded extension matches "/skill:" on raw input (before Pi // expands it into a block) and ships the result in the // before_agent_start hook payload. These events flow into state.SkillEvents and // are merged into checkpoint metadata at condensation. // // Deliberately, PiAgent does NOT implement agent.SkillEventExtractor (the // transcript-extraction interface that claude-code uses). The two models are // mutually exclusive on purpose — see TestPiAgent_UsesLiveSkillCaptureNotTranscriptExtraction. // Adding a transcript extractor here would double-count: condensation merges // the extractor output with these live events via mergeSkillEvents, and the // keys cannot dedup cleanly (live events carry their original per-invocation // TurnID, while a re-extraction stamps every event with the current TurnID), // so earlier-turn skills would surface twice in checkpoint metadata. // agent.SkillEvents. This is Pi's only skill-capture path. PiAgent intentionally // does NOT implement agent.SkillEventExtractor: a transcript extractor would // double-count these live events at condensation (see // TestPiAgent_UsesLiveSkillCaptureNotTranscriptExtraction). func piSkillEvents(in []piSkillEventInput) []agent.SkillEvent { if len(in) == 0 { return nil } }

Mcmd/entire/cli/agent/pi/lifecycle.go+4/-14

70 unmodified lines

// TestParseHookEvent_BeforeAgentStart_MultipleSkillEvents locks the live-capture // guarantee for more than one invocation in a single turn: every reported // /skill: must surface as its own SkillEvent. This is the path that backs // invoked-skill capture for ALL live Pi sessions, including entire review // --agent pi. // TestParseHookEvent_BeforeAgentStart_MultipleSkillEvents locks live capture of // every /skill: in a turn (the path backing all live Pi sessions). func TestParseHookEvent_BeforeAgentStart_MultipleSkillEvents(t *testing.T) {

t.Parallel() a := &PiAgent{} }

// TestPiAgent_UsesLiveSkillCaptureNotTranscriptExtraction is an architectural // guard. Pi captures invoked skills LIVE via the extension's input handler // (see piSkillEvents), which is mutually exclusive with the transcript- // extraction model claude-code uses. PiAgent must therefore NOT implement // agent.SkillEventExtractor: condensation merges any extractor output with the // live state.SkillEvents, and the keys cannot dedup cleanly across the // live/transcript boundary (per-invocation vs current TurnID), so adding an // extractor would double-count earlier-turn skills in checkpoint metadata. // // If you are here because this test failed: you likely added an ExtractSkillEvents // method to PiAgent. Don't — Pi already captures invoked skills live. Reconcile // the dedup model first (make skill-event identity stable across the boundary) // before reintroducing transcript extraction. // TestPiAgent_UsesLiveSkillCaptureNotTranscriptExtraction guards Pi's // live-capture model: a transcript extractor would double-count at // condensation (see piSkillEvents). func TestPiAgent_UsesLiveSkillCaptureNotTranscriptExtraction(t *testing.T) {

t.Parallel() if _, ok := agent.AsSkillEventExtractor(NewPiAgent()); ok { t.Fatal("PiAgent implements SkillEventExtractor: Pi uses live skill capture; " + "a transcript extractor would double-count live-captured events at condensation. " + "See piSkillEvents and this test's doc comment.") t.Fatal("PiAgent must not implement SkillEventExtractor: Pi captures skills live; " + "a transcript extractor would double-count at condensation (see piSkillEvents)") } }