Skip to content

fix: harden child compaction journal writes - #13

Merged
sambitcreate merged 1 commit into
mainfrom
feature/compaction-hardening
Aug 9, 2026
Merged

sambitcreate merged 1 commit into
mainfrom
feature/compaction-hardening

Conversation

@sambitcreate

Copy link
Copy Markdown
Owner

Summary

  • contain child-agent Pi journal append failures without rejecting an otherwise completed child response
  • retain the failed message batch and report the journal error through an injectable, testable hook
  • add an injected append-failure regression
  • register the compaction-core suite in both the coverage lifecycle and the instrumented coverage command

Root cause

The primary chat loop already wrapped Pi journal flushes, but the child loop cleared its pending batch and directly awaited the append. A write rejection therefore discarded the retryable batch and failed the child task after the provider had completed successfully. The compaction suite was also absent from the coverage path.

Impact

Child-agent completions now remain usable if the in-memory Pi journal append fails, while compaction stops safely for that child. Coverage runs now execute and measure the compaction-core suite.

Validation

  • npm run type-check
  • npx eslint main/services/subagents/child-agent-runtime.ts main/services/subagents/agent-compatibility.test.ts
  • npm run test:compaction (7 passed)
  • npx tsx --test main/services/subagents/agent-compatibility.test.ts (27 passed)
  • npm run test:subagents:phase6b (90 passed)
  • npx tsx --test --experimental-test-coverage main/services/pi-compaction-core.test.ts
  • npm run build:electron

@sambitcreate
sambitcreate marked this pull request as ready for review August 9, 2026 15:37

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — one commit hardening child-agent Pi journal writes against append failures, plus coverage registration.

  • Journal flush resilience — the child compaction loop now wraps appendSessionMessages in a flushPiMessages try/catch that retains the failed message batch and reports the error through an injectable onPiJournalError hook, matching the primary chat loop pattern in llm-client.ts:1599-1614.
  • Injectable SubagentRuntimeRegistryOptions — appendPiMessages and onPiJournalError are constructor-injectable test seams, defaulting to the real appendPiMessages and writeDevLog for production. The constructor signature change is additive and backward compatible.
  • Regression test — validates that a child completion survives an injected journal failure, the assistant message remains in agent.state.messages, the error hook fires exactly once, and the registry cleans up.
  • Coverage registration — test:compaction added to pretest:coverage and pi-compaction-core.test.ts added to the test:coverage file list.

Pullfrog  | View workflow run | Using DeepSeek Pro | 𝕏

@sambitcreate
sambitcreate merged commit 1e87729 into main Aug 9, 2026
2 checks passed
@sambitcreate
sambitcreate deleted the feature/compaction-hardening branch August 9, 2026 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant