Retain inherited Guardian instructions in standalone forks (#43478)

## Why

A standalone root forked from a worker needs its inherited user instructions for Guardian review, including after compaction. Parent input counters belong to a different thread, and omitted parent answers may have restricted an inherited authorization.

## What changed

- Adopt inherited user instructions into thread-owned retained context for standalone roots, recovering surviving checkpoint messages when needed.
- Keep inherited instructions before local evidence without sharing local acceptance counters, and preserve that distinction during reconciliation and rollback.
- Mark parent verified answers as incomplete and treat recovered checkpoint instructions as incomplete excerpts.

## Testing

Add coverage for standalone forks from copied history and truncated checkpoints, retention through compaction and resume, inherited/local ordering collisions, and rollback scope.

GitOrigin-RevId: bf716e224a1d29d6c528ef0dd7cdb118a413a08c
This commit is contained in:
felixxia-oai authored and copyberry committed 2026-09-07 13:58:57 +00:00
1 parent aa12ab45df
commit 16ff14c266
19 files changed
+646 -131

No files matched your search

@@ -339,7 +339,10 @@ impl Session {
)
.unwrap_or(u64::MAX);
let mut history = ContextManager::with_guardian_context_mode(self.guardian_context_mode);
let mut history = ContextManager::with_guardian_context_mode(
self.guardian_context_mode,
&turn_context.session_source,
);
let mut saw_legacy_compaction_without_replacement_history = false;
if let Some(checkpoint) = base_compaction
&& let Some(items) = &checkpoint.compacted.replacement_history
+4 -1
View File
@@ -1267,7 +1267,10 @@ impl Session {
let mut state = SessionState::new_with_auto_compact_window_ids(
session_configuration.clone(),
initial_auto_compact_window_ids,
guardian_context_mode,
ContextManager::with_guardian_context_mode(
guardian_context_mode,
&session_configuration.session_source,
),
);
state.base_instructions_provenance = base_instructions_provenance.clone();
let managed_network_requirements_configured = config
+4 -3
View File
@@ -8786,9 +8786,10 @@ where
);
let mut state = SessionState::new(session_configuration.clone());
state.history = ContextManager::with_guardian_context_mode(GuardianContextMode::from_features(
&config.features,
));
state.history = ContextManager::with_guardian_context_mode(
GuardianContextMode::from_features(&config.features),
&session_configuration.session_source,
);
let (environment_manager, resolved_turn_environments) =
resolved_environments_for_configuration(&session_configuration, &default_environments)
.await;