Provision reusable batches of single-use invites
This commit is contained in:
parent
64f5f992cf
commit
164605be85
6 changed files with 59 additions and 12 deletions
|
|
@ -129,6 +129,8 @@ struct ProviderParallelismRequest {
|
|||
struct AuthState {
|
||||
schema: String,
|
||||
unused_invite_hashes: BTreeSet<String>,
|
||||
#[serde(default)]
|
||||
provisioned_invite_hashes: BTreeSet<String>,
|
||||
session_hashes: BTreeSet<String>,
|
||||
#[serde(default)]
|
||||
session_campaigns: BTreeMap<String, uuid::Uuid>,
|
||||
|
|
@ -163,6 +165,21 @@ impl AuthOwner {
|
|||
}
|
||||
}
|
||||
|
||||
fn provision_invite_hashes(state: &mut AuthState, supplied: &BTreeSet<String>) -> bool {
|
||||
let new_hashes: BTreeSet<String> = supplied
|
||||
.difference(&state.provisioned_invite_hashes)
|
||||
.cloned()
|
||||
.collect();
|
||||
if new_hashes.is_empty() {
|
||||
return false;
|
||||
}
|
||||
state.unused_invite_hashes.extend(new_hashes);
|
||||
state
|
||||
.provisioned_invite_hashes
|
||||
.extend(supplied.iter().cloned());
|
||||
true
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
tracing_subscriber::fmt()
|
||||
|
|
@ -194,22 +211,31 @@ async fn main() -> anyhow::Result<()> {
|
|||
.filter(|s| !s.is_empty())
|
||||
.map(str::to_owned)
|
||||
.collect();
|
||||
if invite_tokens.len() != 2 {
|
||||
if invite_tokens.is_empty() || invite_tokens.len() > 128 {
|
||||
return Err(anyhow::anyhow!(
|
||||
"GhostlightDungeon requires exactly two unused invite tokens"
|
||||
"GhostlightDungeon requires between 1 and 128 distinct invite tokens"
|
||||
));
|
||||
}
|
||||
let supplied_invite_hashes: BTreeSet<String> = invite_tokens
|
||||
.iter()
|
||||
.map(|token| secret_hash(token))
|
||||
.collect();
|
||||
std::fs::create_dir_all(runtime_root.join("service"))?;
|
||||
let auth_store = CampaignStore::open(runtime_root.join("service/auth.cc"))?;
|
||||
let (auth_row, auth_state) = match auth_store.load::<AuthState>("auth_state.v1", "primary")? {
|
||||
Some(existing) => existing,
|
||||
Some((row, mut state)) => {
|
||||
if !provision_invite_hashes(&mut state, &supplied_invite_hashes) {
|
||||
(row, state)
|
||||
} else {
|
||||
let next_row = auth_store.replace(&row, "ghostlight.auth_state.v1", &state)?;
|
||||
(next_row, state)
|
||||
}
|
||||
}
|
||||
None => {
|
||||
let state = AuthState {
|
||||
schema: "ghostlight.auth_state.v1".into(),
|
||||
unused_invite_hashes: invite_tokens
|
||||
.iter()
|
||||
.map(|token| secret_hash(token))
|
||||
.collect(),
|
||||
unused_invite_hashes: supplied_invite_hashes.clone(),
|
||||
provisioned_invite_hashes: supplied_invite_hashes,
|
||||
session_hashes: BTreeSet::new(),
|
||||
session_campaigns: BTreeMap::new(),
|
||||
session_campaign_ids: BTreeMap::new(),
|
||||
|
|
@ -2486,6 +2512,7 @@ mod tests {
|
|||
let auth_state = AuthState {
|
||||
schema: "ghostlight.auth_state.v1".into(),
|
||||
unused_invite_hashes: BTreeSet::new(),
|
||||
provisioned_invite_hashes: BTreeSet::new(),
|
||||
session_hashes: BTreeSet::new(),
|
||||
session_campaigns: BTreeMap::new(),
|
||||
session_campaign_ids: BTreeMap::new(),
|
||||
|
|
@ -2841,6 +2868,7 @@ mod tests {
|
|||
let auth_state = AuthState {
|
||||
schema: "ghostlight.auth_state.v1".into(),
|
||||
unused_invite_hashes: BTreeSet::new(),
|
||||
provisioned_invite_hashes: BTreeSet::new(),
|
||||
session_hashes: BTreeSet::from(["left".into(), "right".into()]),
|
||||
session_campaigns: BTreeMap::from([
|
||||
("left".into(), left.id),
|
||||
|
|
@ -2899,6 +2927,7 @@ mod tests {
|
|||
let original = AuthState {
|
||||
schema: "ghostlight.auth_state.v1".into(),
|
||||
unused_invite_hashes: BTreeSet::from(["invite".into()]),
|
||||
provisioned_invite_hashes: BTreeSet::from(["invite".into()]),
|
||||
session_hashes: BTreeSet::new(),
|
||||
session_campaigns: BTreeMap::new(),
|
||||
session_campaign_ids: BTreeMap::new(),
|
||||
|
|
@ -2935,6 +2964,24 @@ mod tests {
|
|||
assert_eq!(owner.row, row);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invite_provisioning_adds_new_hashes_without_resurrecting_consumed_ones() {
|
||||
let mut state = AuthState {
|
||||
schema: "ghostlight.auth_state.v1".into(),
|
||||
unused_invite_hashes: BTreeSet::new(),
|
||||
provisioned_invite_hashes: BTreeSet::from(["consumed".into()]),
|
||||
session_hashes: BTreeSet::new(),
|
||||
session_campaigns: BTreeMap::new(),
|
||||
session_campaign_ids: BTreeMap::new(),
|
||||
};
|
||||
let supplied = BTreeSet::from(["consumed".into(), "fresh".into()]);
|
||||
|
||||
assert!(provision_invite_hashes(&mut state, &supplied));
|
||||
assert_eq!(state.unused_invite_hashes, BTreeSet::from(["fresh".into()]));
|
||||
assert!(!provision_invite_hashes(&mut state, &supplied));
|
||||
assert_eq!(state.unused_invite_hashes, BTreeSet::from(["fresh".into()]));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn campaign_selection_reloads_stale_auth_without_losing_concurrent_state() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
|
|
|
|||
|
|
@ -771,7 +771,7 @@ Live model allocation:
|
|||
|
||||
The daemon serves the embedded browser bundle on TCP 8831. Firewall scope is
|
||||
Starfire's private LAN and `10.77.0.0/24`; there is no public listener or
|
||||
Yggdrasil web gateway. Two single-use invites establish separate HttpOnly
|
||||
Yggdrasil web gateway. Provisioned single-use invites establish separate HttpOnly
|
||||
sessions. Campaigns remain single-player in the MVP. This is a product-scope
|
||||
constraint, not a WorldKernel identity: the intended post-solo extension maps
|
||||
multiple authenticated members to distinct player-controlled actors while all
|
||||
|
|
|
|||
|
|
@ -228,7 +228,7 @@ stake prose alone never impersonates world mutation.
|
|||
- optional operator inspector for evidence, topology, state versions, model receipts, rejected proposals, and private spoiler traces.
|
||||
- Do not expose model chain-of-thought or secrets.
|
||||
- Serve the embedded web bundle on TCP `8831`. Firewall access is limited to Starfire’s private LAN and `10.77.0.0/24`; no public listener or Yggdrasil web gateway is added.
|
||||
- Use two single-use invite links that establish separate HttpOnly sessions. Campaigns are single-player; simultaneous co-op is outside the MVP.
|
||||
- Use provisioned single-use invite links that establish separate HttpOnly sessions. Campaigns are single-player; simultaneous co-op is outside the MVP.
|
||||
- Run `GhostlightDungeon` as a normal detached process under the Starfire operator account. Record its PID, executable, and logs; explicit start, stop, health, release, and rollback scripts own lifecycle. ACL the runtime root to administrators and that operator account.
|
||||
- Read the DeepSeek key from stdin during setup, protect it with machine-scoped DPAPI plus file ACLs, and never place it in source, arguments, logs, or environment projections.
|
||||
- Build immutable release directories from the exact Git commit, switch the active release through the guarded junction, and record provenance in CultCache plus the immutable release manifest. Process restart is explicit; Windows service installation and automatic boot recovery are outside this MVP by operator choice.
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
2
web/dist/index.html
vendored
2
web/dist/index.html
vendored
|
|
@ -1,5 +1,5 @@
|
|||
<!doctype html>
|
||||
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>GhostlightDungeon</title> <script type="module" crossorigin src="/assets/index-B_0anyiQ.js"></script>
|
||||
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>GhostlightDungeon</title> <script type="module" crossorigin src="/assets/index-DT1ZfEs6.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-B7Qh0xAi.css">
|
||||
</head>
|
||||
<body><header><p class="eyebrow">STARFIRE / PRIVATE VERSE</p><h1>GhostlightDungeon</h1><p id="status" role="status" aria-live="polite">Reading the world…</p></header><main>
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ function showAuthenticationGate() {
|
|||
gate.append(
|
||||
node("h2", "Private campaign laboratory"),
|
||||
node("p", message),
|
||||
node("p", "Open one of the two single-use tester invitations on this device. The resulting session stays separate from the other player's campaigns.", "quiet"),
|
||||
node("p", "Open a single-use tester invitation on this device. The resulting session stays separate from every other player's campaigns.", "quiet"),
|
||||
);
|
||||
host.replaceChildren(gate);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue