Let hosts discard noncanonical previews

This commit is contained in:
Meta Vens 2026-08-22 23:33:06 +02:00
commit b2c87b6de1
5 changed files with 124 additions and 0 deletions

View file

@ -1022,6 +1022,7 @@ fn eve_operation_schema(operation: &str) -> Option<&'static str> {
| "session_zero.roster.lock"
| "session_zero.compile"
| "session_zero.compilation_gaps.review"
| "session_zero.preview.discard"
| "session_zero.approve"
| "session_zero.publish" => "ghostlight.session_zero_revision_command.v1",
"session_zero.member.remove" => "ghostlight.session_zero_member_remove.v1",
@ -1353,6 +1354,20 @@ async fn dispatch_eve_product_command(
Err(error) => return invalid_eve_payload(&invocation, error),
}
}
"session_zero.preview.discard" => {
match decode_payload::<SessionZeroRevisionRequest>(&payload) {
Ok(request) => {
discard_session_zero_preview(
Path(session_id.unwrap()),
headers.clone(),
State(state.clone()),
Json(request),
)
.await
}
Err(error) => return invalid_eve_payload(&invocation, error),
}
}
"session_zero.approve" => match decode_payload::<SessionZeroRevisionRequest>(&payload) {
Ok(request) => {
approve_session_zero(
@ -2879,6 +2894,21 @@ async fn review_session_zero_compilation_gaps(
.await
}
async fn discard_session_zero_preview(
Path(session_id): Path<uuid::Uuid>,
headers: HeaderMap,
State(state): State<AppState>,
Json(request): Json<SessionZeroRevisionRequest>,
) -> Response {
session_zero_simple_command(&headers, &state, session_id, |account_hash| {
SessionZeroCommand::DiscardPreview {
actor_account_hash: account_hash,
expected_revision: request.expected_revision,
}
})
.await
}
async fn publish_session_zero(
Path(session_id): Path<uuid::Uuid>,
headers: HeaderMap,

View file

@ -1020,6 +1020,10 @@ pub enum SessionZeroCommand {
actor_account_hash: String,
expected_revision: u64,
},
DiscardPreview {
actor_account_hash: String,
expected_revision: u64,
},
InstallPreview {
expected_revision: u64,
preview: WorldCompilePreview,
@ -2648,6 +2652,23 @@ pub fn session_zero_surface(
&[],
));
}
if member.is_host
&& state.preview.is_some()
&& matches!(
state.status,
SessionZeroStatus::Drafting
| SessionZeroStatus::RosterLocked
| SessionZeroStatus::Review
)
{
children.push(command_control(
"session-zero.discard-preview",
"Discard this preview and continue drafting",
"session_zero.preview.discard",
serde_json::json!({"expected_revision":state.revision}),
&[],
));
}
if member.is_host
&& matches!(
state.status,
@ -2782,6 +2803,7 @@ pub fn session_zero_surface(
eve_command("session_zero.roster.lock", "ghostlight.session_zero_revision_command.v1", &[]),
eve_command("session_zero.compile", "ghostlight.session_zero_revision_command.v1", &[]),
eve_command("session_zero.compilation_gaps.review", "ghostlight.session_zero_revision_command.v1", &[]),
eve_command("session_zero.preview.discard", "ghostlight.session_zero_revision_command.v1", &[]),
eve_command("session_zero.approve", "ghostlight.session_zero_revision_command.v1", &[]),
eve_command("session_zero.publish", "ghostlight.session_zero_revision_command.v1", &[]),
eve_command("app.auth.logout", "ghostlight.app_logout.v1", &[])
@ -3397,6 +3419,26 @@ fn execute(
}
state.status = SessionZeroStatus::Review;
}
SessionZeroCommand::DiscardPreview {
actor_account_hash,
expected_revision,
} => {
require_revision(&state, expected_revision)?;
require_host(&state, &actor_account_hash)?;
if state.preview.is_none() {
return Err(anyhow!("compiled preview is missing"));
}
if matches!(
state.status,
SessionZeroStatus::Compiling
| SessionZeroStatus::Published
| SessionZeroStatus::Archived
) {
return Err(anyhow!("compiled preview cannot be discarded now"));
}
state.approvals.clear();
retire_preview(&mut state);
}
SessionZeroCommand::InstallPreview {
expected_revision,
preview,
@ -4956,6 +4998,7 @@ mod tests {
.unwrap();
assert!(surface.contains("Evidence gaps requiring table approval"));
assert!(surface.contains("Review this exact preview with its evidence gaps"));
assert!(surface.contains("Discard this preview and continue drafting"));
assert!(!surface.contains("Compile campaign preview"));
let reviewing = kernel
@ -5004,6 +5047,50 @@ mod tests {
);
}
#[tokio::test]
async fn host_can_discard_a_noncanonical_preview_without_changing_the_draft() {
let dir = tempdir().unwrap();
let store = CampaignStore::open(dir.path().join("session-zero.cc")).unwrap();
let mut initial = compilable_state();
initial.roster_locked = true;
initial.status = SessionZeroStatus::Drafting;
initial.preview = Some(WorldCompilePreview {
schema: "ghostlight.world_compile_preview.v1".into(),
title: "Retired candidate".into(),
campaign: crate::resolution::tests::campaign(2, 1),
evidence_receipts: vec![],
evidence_coverage: vec![],
gaps: vec!["A material gap".into()],
branch_assumptions: vec![],
requires_approval: true,
});
let original_contract = initial.contract.clone();
let original_character = initial.character_drafts[&initial.host_member_id].clone();
SessionZeroKernel::initialize(&store, &initial).unwrap();
let kernel = SessionZeroKernel::start(store, initial.id);
let discarded = kernel
.command(SessionZeroCommand::DiscardPreview {
actor_account_hash: "account:host".into(),
expected_revision: initial.revision,
})
.await
.unwrap();
assert!(discarded.state.preview.is_none());
assert_eq!(discarded.state.status, SessionZeroStatus::RosterLocked);
assert_eq!(discarded.state.contract, original_contract);
assert_eq!(
discarded.state.character_drafts[&discarded.state.host_member_id],
original_character
);
let surface =
serde_json::to_string(&session_zero_surface(&discarded.state, "account:host").unwrap())
.unwrap();
assert!(surface.contains("Compile campaign preview"));
assert!(!surface.contains("Discard this preview"));
}
#[test]
fn player_surface_projects_the_complete_private_ledger_and_exact_typed_change() {
let mut draft = state();

View file

@ -218,6 +218,9 @@ private goals or resources, populations, clocks, evidence-use rationales,
gaps, and branch assumptions. Relationship-anchor people remain absent from
the shared cast and appear only in their owner's private relationship card.
Privacy is labeled in text and never conveyed only by color.
The host may discard any non-canonical preview through a typed Session Zero
command and continue drafting without changing the contract, characters, or
fictional time. A retained preview never traps the table into reviewing it.
An approved unresolved relationship person crosses world compilation as a
server-owned identity anchor. The shared world compiler never receives that

View file

@ -597,6 +597,9 @@ populations, clocks, evidence lanes, gaps, assumptions, or any other preview
field therefore makes old approvals unusable. The Eve tree visibly lowers the
reviewable world shape. Player JSON excludes institution resources and goals,
and shared cast projection excludes private relationship-anchor people.
The host can discard any non-canonical preview through the SessionZeroKernel;
the command clears only preview state and returns the locked roster to drafting
without editing the contract, character drafts, or fictional time.
Private character relationships now cross compilation through a typed identity
membrane. Exact player references bind to their approved actor IDs. Each

View file

@ -90,6 +90,7 @@ live_architecture:
- SessionZeroKernel is the sole pre-world owner of persistent shared/private negotiation, typed contracts, character drafts, boundaries, decisions, invitations, and approvals. The WorldKernel receives only an unanimously approved brief at atomic publication.
- Approved private relationships cross compilation through exact canonical subject IDs. Player references bind to approved actors; otherwise unresolved named people become stable server-generated relationship anchors. The shared world compiler receives no private subject name, identity handle, or relationship. After public topology validation, a separate private stage owns characterization and placement but cannot emit IDs, relationships, narration, facts, gaps, assumptions, or public changes; Ghostlight attaches the opaque ID and owner-only relationship locally. Omission, ambiguity, unknown placement, or collision rejects the candidate atomically, and links to actors, institutions, Gestalts, or named Gestalt members grant no knowledge or authority.
- Gap-bearing compiler results remain non-canonical exact previews. Host review selection cannot approve them; every active member approval binds shared contract, private character, and the exact world-preview digest. Publication preserves that digest and the accepted evidence gaps and branch assumptions, while the Eve tree visibly renders the player-reviewable world shape without institution-private resources/goals or another player's relationship anchors.
- The host may discard a retained non-canonical preview through the SessionZeroKernel. This clears preview-bound approvals and preview state, then returns the locked roster to drafting without changing the contract, characters, or fictional time.
- A material counter clears its prior typed payload, enters the permitted durable channel, removes acceptance authority, and remains unresolved until a same-epoch DM turn atomically installs a fresh decision. Generated opening and role suggestions are non-material; ignoring them cannot block custom compilation. Transcript-only blank contracts and characters fail locally before world compilation.
- Bounded co-op uses campaign_membership.v1 to bind one to eight authenticated members to exact actors in the existing campaign mailbox. Sequential public actions, actor-filtered surfaces, unanimous time/travel/cell-budget changes, and non-simulatable human actors are implemented; split parties, PvP, private play actions, delegation, late joining, and group lifecycle commands remain unsupported.
- Contract Review reuses Session Zero against an exact world revision. Unanimous publication may amend forward-looking contract and approved actor ledger fields but cannot rewrite custody, location, topology, knowledge, memory, canon, or history. Boundary tightening becomes immediate anonymous aggregate policy; relaxation waits for publication.