From 097262c9401668bf90ce0a6de56127cbc0d88f95 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 18 Aug 2026 03:26:41 +0200 Subject: [PATCH] Replan leases around changed topology --- crates/ghostlight-dungeon/src/resolution.rs | 108 ++++++++++++++---- .../ghostlight-multiresolution-agency.md | 6 + notes/fresh-workspace-handoff.md | 9 ++ state/map.yaml | 4 +- 4 files changed, 105 insertions(+), 22 deletions(-) diff --git a/crates/ghostlight-dungeon/src/resolution.rs b/crates/ghostlight-dungeon/src/resolution.rs index d601c3d..f6aa87a 100644 --- a/crates/ghostlight-dungeon/src/resolution.rs +++ b/crates/ghostlight-dungeon/src/resolution.rs @@ -576,7 +576,7 @@ pub fn plan_cover(campaign: &Campaign, demand: ResolutionDemand) -> Result, + graph: &DerivedAgencyGraph, scoring: &ScoringCache, demand: &ResolutionDemand, mandatory: &BTreeSet, @@ -729,11 +730,10 @@ fn preserve_previous_cover( }) else { return candidate; }; - if previous - .cells - .iter() - .any(|cell| cell.subject_ids.len() > 1 && !cell.subject_ids.is_disjoint(mandatory)) - { + if previous.cells.iter().any(|cell| { + cell.subject_ids.len() > 1 + && (!cell.subject_ids.is_disjoint(mandatory) || !connected(graph, &cell.subject_ids)) + }) { return candidate; } let expected: BTreeSet<_> = profiles.keys().cloned().collect(); @@ -1414,21 +1414,44 @@ fn validate_cover_with_graph( .collect(); let mut actual = BTreeSet::new(); for cell in cells { - if cell.subject_ids.is_empty() - || cell.subject_ids.iter().any(|id| !actual.insert(id.clone())) - || (cell.subject_ids.len() > 1 && !connected(graph, &cell.subject_ids)) - || cell.id != cell_id(&cell.subject_ids, &cell.mode) - || (cell.mode == SimulationCellMode::Cohesive - && classify_and_score( - campaign, - &campaign.agency_profiles, - &scoring, - &cell.subject_ids, - demand, - ) - .0 != SimulationCellMode::Cohesive) + if cell.subject_ids.is_empty() { + return Err(anyhow!("resolution cell {} is empty", cell.id)); + } + if let Some(duplicate) = cell + .subject_ids + .iter() + .find(|id| !actual.insert((*id).clone())) { - return Err(anyhow!("resolution cover contains an invalid cell")); + return Err(anyhow!( + "resolution subject {duplicate} appears in more than one cell" + )); + } + if cell.subject_ids.len() > 1 && !connected(graph, &cell.subject_ids) { + return Err(anyhow!( + "resolution cell {} is disconnected in the current agency graph", + cell.id + )); + } + if cell.id != cell_id(&cell.subject_ids, &cell.mode) { + return Err(anyhow!( + "resolution cell {} does not match its subjects and mode", + cell.id + )); + } + if cell.mode == SimulationCellMode::Cohesive + && classify_and_score( + campaign, + &campaign.agency_profiles, + &scoring, + &cell.subject_ids, + demand, + ) + .0 != SimulationCellMode::Cohesive + { + return Err(anyhow!( + "resolution cell {} claims collective agency without current cohesive authority", + cell.id + )); } } if actual != expected { @@ -2800,6 +2823,51 @@ pub(crate) mod tests { ); } + #[test] + fn lease_cannot_preserve_a_cell_disconnected_by_current_topology() { + let mut value = campaign(4, 2); + let demand = default_demand(&value, "topology changed beneath the lease"); + let profiles = value.agency_profiles.clone(); + let scoring = ScoringCache::new(&value, &profiles); + let stale_groups = [ + BTreeSet::from(["faction-0000".into(), "faction-0002".into()]), + BTreeSet::from(["faction-0001".into(), "faction-0003".into()]), + ]; + let stale_cells = stale_groups + .into_iter() + .map(|subject_ids| { + let (mode, merge_loss) = + classify_and_score(&value, &profiles, &scoring, &subject_ids, &demand); + SimulationCell { + schema: "ghostlight.simulation_cell.v1".into(), + id: cell_id(&subject_ids, &mode), + mode, + subject_ids, + merge_loss, + rationale: "previously connected partition".into(), + lease_until_world_revision: value.revision + 5, + lease_until_strategic_tick: value.strategic_tick_count + 2, + detail_focus_subject_id: None, + } + }) + .collect::>(); + value.resolution_cover = Some(ResolutionCover { + schema: "ghostlight.resolution_cover.v1".into(), + campaign_id: value.id, + world_revision: value.revision, + resolution_epoch: value.resolution_policy.resolution_epoch, + configured_budget: 2, + effective_budget: 2, + mandatory_overage: 0, + cells: stale_cells.clone(), + demand: demand.clone(), + }); + + let cover = plan_cover(&value, demand).unwrap(); + validate_cover(&value, &cover.demand, &cover.cells).unwrap(); + assert_ne!(cover.cells, stale_cells); + } + #[test] fn rivals_at_budget_one_form_an_arena_not_a_false_collective() { let mut value = campaign(2, 1); diff --git a/docs/architecture/ghostlight-multiresolution-agency.md b/docs/architecture/ghostlight-multiresolution-agency.md index c8f488d..ceece90 100644 --- a/docs/architecture/ghostlight-multiresolution-agency.md +++ b/docs/architecture/ghostlight-multiresolution-agency.md @@ -563,6 +563,12 @@ either control only when its value actually differs, so repeated strategic ticks preserve the previous cover, leases, and churn history. Stress runs may select cell budget and provider parallelism independently. +A lease preserves a cut, not invalid topology. Before reusing a previous cover, +the partitioner revalidates every multi-subject cell against the current agency +graph. Migration, relation changes, fission, or activation can therefore break +a leased cell and force replanning immediately. Cover validation reports empty, +duplicate, disconnected, content-ID, and false-cohesion failures separately. + The run also exposes the next authority gap. Institution postures, population migration, clocks, and history changed canonically, but most Gestalt activities remain attributed attempts recorded as events. Over many ticks this can repeat diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 4ee5908..4e94053 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -262,6 +262,15 @@ profiles. Rerun the long budget-one case before treating its cache or churn numbers as the lease-preserving baseline; its agency/fairness result remains valid. +The first lease-preserving budget-4 run committed two waves, then deterministically +failed every pulse because migration had changed graph adjacency while an old +leased cell remained. The old harness's redundant epoch churn had hidden this. +`preserve_previous_cover` now rejects any previous multi-subject cell that is +disconnected in the current derived graph and falls back to the fresh candidate. +A regression constructs a still-leased formerly connected cover whose groups +are disconnected under the current graph. Validation now names the exact cover +fault instead of returning one generic invalid-cell message. + Do not call setting-wide material agency finished yet. Most population output is still an attributed `gestalt_activity` attempt stored as history. The long run became repetitive around ferry loading and shelter requests because no diff --git a/state/map.yaml b/state/map.yaml index 89bea77..c6f73b1 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -267,6 +267,6 @@ data_flow: - If state grows faster than understanding, cut it back. current_status: - summary: GhostlightDungeon production remains on the verified Starfire release. Multiresolution pressure proves a strict refugee callback, nested multi-destination diaspora, 24-of-24 low-budget fairness with rejected-pulse recovery, and the 1/4/8/32 scale matrix. It also exposed and fixed redundant resolution controls that were manufacturing epochs and discarding leases. Production state remains untouched. - next_action: Rerun lease-preserving long profiles at budgets 1, 4, and 8 with independent provider parallelism, then map strategic outcome ownership after attributed cell attempts. Preserve Interpreter non-authority while allowing validated offscreen work to change typed resources, bargains, relationships, obligations, and pressures atomically. + summary: GhostlightDungeon production remains on the verified Starfire release. Multiresolution pressure proves the callback, nested diaspora, fairness, and scale matrix. Lease-preserving pressure exposed two hidden faults now cut: redundant controls manufactured epochs, and migrated topology could leave a disconnected leased cell alive. Production state remains untouched. + next_action: Rerun lease-preserving long profiles at budgets 4 and 8 with independent provider parallelism. Require covers to survive valid leases and replan immediately around migration-broken adjacency. Then map strategic outcome ownership after attributed cell attempts without granting Interpreter outcome authority. gestalt_population: Gestalt Personas own shared population baselines; persistent member deltas own named individuality; WorldKernel materialization and approval-gated fission preserve lineage and identity. Presence projection is limited to nearby active leaves and exact-location dormant members. Simulation cells are derived covers only.