interplane.Get Omega
Read in your language

aien-sovereign-core-mv

AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.

Brought by drakestapleton

branch main Branches Tags History

aien-sovereign-core-mv / docs / plans / compaction / INVENTORY-397.md

81 lines · 7962 bytes Raw Blame History Source

Context compaction hardening (aien-sovereign-core#397): inventory and test matrix

Owner: campaign session 1ea888, 2026-10-10. Branch fix/context-compaction-safety-397. Motus (PyPI lithosai-motus 0.4.3, memory/compaction_*.py) was read for ideas only: keep tool call and result together, store originals before summarizing, mark summaries as derived. No Python enters this repo.

1. Entry points and state ownership (verified by reading the code)

SiteWhat it doesCompaction?
crates/aien-cli/src/main.rs, interactive loop (loop { after the banner), after each user turn and after each assistant turnthe only production caller of ContextCompactor::compact_if_needed; the message list is a Vec<serde_json::Value> of {role, content}; the whole list is written to basecamp/sessions/<session_id>.json after every turnyes, this PR
crates/aien-cli/src/main.rs, single-shot (session-single-*) and auto-goal-* modesbuild their own short message lists; never call the compactorno
crates/aien-cli/src/hooks.rs AgentHook::on_compaction / run_on_compactionhook slot; no hook implements it and nothing calls run_on_compactionno (unchanged)
crates/aien-cli/src/client.rs stream_turnsends role and content only; extra fields on a message (derived, authority) are ignored by the wirereads the list
crates/aien-cli/src/client.rs extract_tool_callsthe tool-call grammar (<tool_call> JSON, or a fenced JSON block); reused by the compactor to recognise an assistant tool requestshared
crates/aien-runtime/src/context.rs ContextComposer, ContextRevisionimmutable tokenized revisions for the scheduler; a different object (token ids, not chat messages); not touchedno
compose daemon (crates/aien-runtime/src/spine.rs)its own Cortex journal and record marks; not a chat transcriptno
aegis-runtime/src/agent.rsread for the issue's "parallel compaction" question: at aegis-runtime main on 2026-10-10 there is no compaction routine there (grep compact finds nothing); AEGIS is out of release v1 (Drake, aien-architecture#190)no

Tool results in this loop are role: user messages whose content starts with <tool_response name="..."> (the tokenizer refuses a tool role). The compose daemon's approval waits never pass through this loop today; the approval marker the compactor protects (a tool result whose parsed JSON body has status equal to approval_pending, requires_approval or pending) is a documented convention for the day they do. The words in prose, in an assistant message or in any other field do not count.

2. What changed (crates/aien-cli/src/compaction.rs)

3. Test matrix (cargo test -p aien-cli compaction)

Acceptance point (issue)Before (main, 1 test)After (24 tests)
tool request + results retained or compacted as one groupnot testedtool_group_is_atomic_and_originals_reconstruct
pending tool call protectednot testedpending_tool_call_in_tail_is_protected
interrupted or detached tool responsenot tested (would be recapped)detached_tool_result_refuses
multi-tool turn with missing resultnot testedhistorical_incomplete_group_refuses
approval-waiting trace stays intactnot testedapproval_wait_protects_everything_after_it
original bytes reconstructable, digests verifyimpossible (originals discarded)tool_group_is_atomic_and_originals_reconstruct, oversized_result_in_tail_is_truncated_and_recoverable
compaction refuses without durable recordnono_store_refuses_lossy_compaction, store_write_failure_leaves_list_untouched
restart and replay reproduce the transcriptnoreplay_after_restart_rebuilds_two_compactions
hostile tool text cannot forge authoritynohostile_tool_text_cannot_forge_authority_in_recap, hostile_user_and_assistant_text_is_neutralised_in_recap, sanitize_line_strips_markup_control_and_length, approval_marker_counts_only_as_a_parsed_tool_result_status
tampering detectednotampered_record_is_rejected, recap_naming_another_transcript_is_rejected, replay_refuses_missing_or_empty_store
no secret in compaction output; originals kept protectednosecrets_are_redacted_in_recap_and_stubs_but_kept_in_record, vault_redactor_strips_known_patterns, secret_straddling_the_oversized_cut_is_redacted (redaction runs before every cut)
budgets enforced with mixed contentno (non-string content counted as 0)mixed_content_counts_toward_budget, estimate_is_conservative_against_known_counts, still_over_budget_is_reported_when_protected_tail_exceeds_max
recap of a recap loses nothingnorecap_of_recap_keeps_earlier_lines_and_pointer
semantics not only sizesize onlythe tests above assert structure, protection and reconstruction

4. Limits (stated, not hidden)