Cut spec for ghostlight Google sign-in, pending admission to Weksa's mind

Weksa's ghostlight-verse campaign does not list GameCult/Heimdall, so Huginn
refused the spec (RepoNotInCampaign). It is kept here until Self adds the repo
and admits it as ghostlight-verse:cut_spec:cut-heimdall-ghostlight-google.r1;
Hands deletes this file in the cut.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-12-02 23:10:26 +01:00
commit 22a7f41454

View file

@ -0,0 +1,241 @@
{
"kind": "cut_spec",
"value": {
"campaign": "ghostlight-verse",
"cut": "heimdall-ghostlight-google",
"revision": 1,
"title": "Heimdall: ghostlight admits Google, honours the Dungeon's invite grant, and stops gating on the Discord role",
"repo": "GameCult/Heimdall",
"branch": "ghostlight/google-sign-in",
"base": "2bcb2ca4e7fb640e07deae42302b0919a62e5bc4",
"depends_on": [],
"first": [
"Work in the existing worktree F:\\Projects\\Heimdall-wt-ghostlight-google on branch ghostlight/google-sign-in (from origin/main 2bcb2ca). Read AGENTS.md; follow its state/evidence conventions for the closing evidence line.",
"Read docs/service-contract.md 'Invite grant' (about line 264) and src/app.ts startOAuthFlow gates (about lines 832-846): the grant mechanism already exists for bifrost. This cut extends it to ghostlight and threads it through the private command plane; it adds no invite records to Heimdall.",
"Delete first: AppProfile.requiredEntitlementPolicyKind (app-profiles.ts:41-47, set only by ghostlight at :203) and requireEntitlementPolicyIfProfileDemandsIt (private-command-plane.ts:385-407) with its two call sites (:236 refresh, :272 begin). A caller-sent policy stays accepted and optional as for every other app.",
"Heimdall ruling heimdall-body:ruling:bifrost-google-invitation-link-only forbids attaching Google to an existing account by an invitation path. This cut does not: the grant only mints a new account for a sub no account holds and never attaches (contract text at :264-274). Do not widen that.",
"Open the Heimdall PR on Forgejo only when Self says so; the brief for this mapping pass forbids it, Hands' own brief decides."
],
"deletes": [
{
"path": "src/app-profiles.ts",
"lines": 8,
"note": "requiredEntitlementPolicyKind field and its doc comment; ghostlight's requiredEntitlementPolicyKind line"
},
{
"path": "src/private-command-plane.ts",
"lines": 22,
"note": "requireEntitlementPolicyIfProfileDemandsIt and its two awaits"
},
{
"path": "tests",
"lines": 30,
"note": "tests that pin 'ghostlight authentication/refresh requires its caller-owned discord_role_access policy' are deleted or inverted (a ghostlight begin without policy now starts)"
}
],
"keeps_moves": [
"The grant gates in startOAuthFlow (app caller of this slug, sign_in only, mayGrantFirstLogin) and the callback mint under first_login_grant are unchanged.",
"Bifrost's profile, its grant and its Google link flow are unchanged.",
"The private-plane attempt handle (trustedBrowserAttemptId, never body-supplied) is the ghostlight browser binding and is unchanged.",
"Discord stays a ghostlight identity provider; a Discord policy a caller still sends is evaluated by nobody for ghostlight (entitlementSources empty) and is harmless."
],
"adds": [
"ghostlight profile: identityProviders ['discord','google']; entitlementSources []; startRequiresAppCaller: true; mayGrantFirstLogin: true; profileVersion '2026-12-02'.",
"ghostlight app_access: anyOf [identityFacts.authenticated] (as streampixels viewer_access at :147), summary 'Heimdall authenticated this identity for Ghostlight; who may play is the Dungeon's account catalog'. campaign_play summary/localRequirement: 'Ghostlight combines a Heimdall sign-in with its own account catalog and campaign ownership'.",
"beginAuth reads payload.firstLoginGrant: absent/null -> none; exactly 'invite' -> passed to startOAuthFlow input.firstLoginGrant; any other value -> throw 'Auth begin payload is incomplete.' (same refusal shape as a bad provider). startOAuthFlow's existing gate then decides."
],
"file_changes": [
{
"location": {
"path": "src/app-profiles.ts",
"line": 195,
"end_line": 218,
"symbol": "ghostlightProfile"
},
"change": "As in adds: providers, entitlementSources [], startRequiresAppCaller, mayGrantFirstLogin, app_access on identity.authenticated, summaries, profileVersion. Import identityFacts is already present."
},
{
"location": {
"path": "src/private-command-plane.ts",
"line": 260,
"end_line": null,
"symbol": "beginAuth"
},
"change": "Thread firstLoginGrant into the startOAuthFlow input; drop the policy-demand await."
},
{
"location": {
"path": "src/private-command-plane.ts",
"line": 221,
"end_line": null,
"symbol": "refreshAuth"
},
"change": "Drop the policy-demand await; policy remains optional and passed through when present."
},
{
"location": {
"path": "schemas/heimdall.auth_begin_command.v1.schema.json",
"line": 1,
"end_line": null
},
"change": "provider enum gains google; entitlementPolicy leaves required; add firstLoginGrant {enum:['invite']}."
},
{
"location": {
"path": "schemas/heimdall.auth_refresh_command.v1.schema.json",
"line": 1,
"end_line": null
},
"change": "entitlementPolicy optional if it is required there."
},
{
"location": {
"path": "docs/service-contract.md",
"line": 190,
"end_line": null
},
"change": "startRequiresAppCaller: 'Bifrost and Ghostlight'; mayGrantFirstLogin (about :264): 'bifrost and ghostlight'; Google (about :289): admitted to bifrost and ghostlight; private-plane begin accepts firstLoginGrant 'invite'."
},
{
"location": {
"path": "docs/app-profiles/ghostlight.md",
"line": 1,
"end_line": null
},
"change": "Providers Discord and Google; access rule: Heimdall authenticates, app_access is identity.authenticated, admission is the Dungeon's catalog and one-time invites (ruling dungeon-owns-accounts); a first Google sign-in mints a Heimdall account only under the Dungeon's grant; no Discord role policy; refresh re-evaluates nothing app-specific."
}
],
"reads": [
{
"location": {
"path": "src/app.ts",
"line": 832,
"end_line": null,
"symbol": "startOAuthFlow"
},
"why": "the app-caller and grant gates the private plane now reaches with a grant"
},
{
"location": {
"path": "src/app.ts",
"line": 2034,
"end_line": null
},
"why": "callback: requires_link + first_login_grant mints and audits account_minted_by_grant"
},
{
"location": {
"path": "tests/google-link.test.ts",
"line": 1,
"end_line": null
},
"why": "the bifrost grant tests to mirror for ghostlight over the private plane"
},
{
"location": {
"path": "tests/caller-identity-soul.test.ts",
"line": 23,
"end_line": null
},
"why": "private-plane ghostlight fixtures (ghostlightSecret, runtime ids)"
}
],
"authority_map": {
"owner": "The Dungeon's account catalog (catalog.cc) owns admission: an identity plays if an account holds it, or if it redeems a live one-time Dungeon invite, consumed in the write that creates the account. Heimdall owns authentication only: it proves which external identity signed in and names the Heimdall account (claim sub) that identity belongs to.",
"inputs": [
"Dungeon: the invite the browser presents at begin, its catalog, the Heimdall-verified claim at complete",
"Heimdall: the app-authenticated begin (ghostlight secret over the private plane), the provider's OIDC/OAuth answer, the signed state"
],
"outputs": [
"Dungeon -> Heimdall: firstLoginGrant 'invite' on a begin whose browser presented an invite the catalog holds live",
"Heimdall -> Dungeon: a claim aud=ghostlight with app_access for every authenticated identity",
"Dungeon: an account row, the spent invite, an app session"
],
"derived_state": [
"Heimdall's first_login_grant is no longer an invite: it is derived from the Dungeon's live invite at begin and is notification-only (it lets Heimdall mint an auth account for a Google sub no account holds)",
"ghostlight app_access is no longer an admission gate: it is derived from identity.authenticated; the Dungeon's app_access checks become claim-shape checks that cannot refuse an authenticated sign-in",
"the invite bound to an attempt in AuthGuard is a copy of what the browser presented at begin, memory-only, living no longer than the begin cookie"
],
"forbidden_writers": [
"Heimdall's Discord role policy (requiredEntitlementPolicyKind, entitlementSources discord) no longer decides who enters the Dungeon",
"Heimdall holds no invite records for ghostlight and never decides who is invited",
"the complete body no longer carries an invite; only the begin-bound invite reaches catalog.sign_in",
"no public (secretless) ghostlight OAuth start: startRequiresAppCaller"
],
"shared_paths": [
"Google, Discord and any later provider begin through one auth_begin -> HeimdallClient::begin -> heimdall.auth.begin path; the grant decision is the same catalog read for every provider",
"every sign-in, first or returning, any provider, ends in one catalog.sign_in"
],
"deletion_line": "Delete before adding: Heimdall's requiredEntitlementPolicyKind field and requireEntitlementPolicyIfProfileDemandsIt; the Dungeon's DiscordGate, its two env names and the policy on begin and refresh; the complete body's invite field."
},
"verification": {
"builds": [
"pnpm typecheck && pnpm test in the worktree (vendor/CultLib built as AGENTS.md says); report the pre-existing odin-publication failure separately if it still appears"
],
"tests": [
{
"name": "ghostlight google first sign-in under grant",
"pins": "private-plane begin {provider google, firstLoginGrant invite} -> 201 state with first_login_grant; callback with an unheld sub mints one account and audits account_minted_by_grant {provider google, appSlug ghostlight}; the completion's claim carries app_access"
},
{
"name": "ghostlight google first sign-in without grant",
"pins": "same begin without firstLoginGrant -> callback refuses identity_not_linked and mints nothing"
},
{
"name": "returning google identity",
"pins": "a sub an account already holds signs in with or without the grant to that same account; the grant attaches nothing"
},
{
"name": "discord without policy",
"pins": "private-plane ghostlight discord begin with no entitlementPolicy starts (no throw); refresh without policy refreshes; claim carries app_access"
},
{
"name": "public ghostlight start refused",
"pins": "POST /v1/oauth/google/start and /v1/oauth/discord/start for appSlug ghostlight without x-heimdall-app-secret -> 401 app_auth_required"
},
{
"name": "bad grant value",
"pins": "private-plane begin with firstLoginGrant 'yes' is refused before any attempt row or state is minted"
},
{
"name": "other apps unchanged",
"pins": "repixelizer/streampixels public starts unchanged; firstLoginGrant from repixelizer still 400 first_login_grant_refused"
}
],
"negative": [
{
"pattern": "requiredEntitlementPolicyKind|requireEntitlementPolicyIfProfileDemandsIt",
"scope": "src, tests, docs: zero hits"
},
{
"pattern": "discord_role_access",
"scope": "src/app-profiles.ts: zero hits (the policy kind itself stays in contracts and the Discord evaluator)"
},
{
"pattern": "invite",
"scope": "src/store/**: no new table, column or row for ghostlight invites"
}
],
"operator": [
"Deploy is cut ops-google-sign-in's runbook section, after this merges to Heimdall main; not part of this cut."
]
},
"estimate": {
"lines_added": 140,
"lines_removed": 70,
"dependencies_added": [],
"dependencies_removed": [],
"formats_added": [],
"formats_removed": [],
"targets_added": [],
"targets_removed": []
},
"rulings": [
"ghostlight-verse:ruling:weksa-owns-dungeon-google-sign-in",
"ghostlight-verse:ruling:dungeon-owns-accounts"
],
"questions": [
"ghostlight-verse:question:heimdall-ghostlight-google-twitch-sign-in"
]
}
}