diff --git a/docs/narrative-cut.md b/docs/narrative-cut.md index a54fa683a..557d185a4 100644 --- a/docs/narrative-cut.md +++ b/docs/narrative-cut.md @@ -1,8 +1,12 @@ # Aetheria narrative: target verification and cut map -Status: Imagination pass, 2026-09-29; Q1-Q9 ruled 2026-09-30 (below). No code landed. The ends are owned by -`docs/narrative-target.md` (on `origin/codex/item-provenance`, `53d0f304`). This document owns the means and -the corrections that target needs before anyone cuts against it. +Status: Imagination pass, 2026-09-29; Q1-Q9 ruled 2026-09-30 (below). v2 (2026-09-30, Imagination) amends +Cut 1 to migrate all Ink tag metadata into typed records per the Q2 ruling, maps Cut 4 (quest items) per the Q4 +ruling, adds corrections C12-C15 and forks Q10-Q13 that those rulings raise, and expands the verification +transport note. No code landed. The ends are owned by `docs/narrative-target.md` (on +`origin/codex/item-provenance`, `53d0f304`). This document owns the means and the corrections that target needs +before anyone cuts against it. v2 was written from `origin/codex/item-provenance:docs/narrative-cut.md` at +`da9f51b9`. Anchors. Every `file:line` is against **`b66ba524`** (`origin/codex/fire-control-12` tip, 2026-09-29), unless another SHA is named. The target's own citations were written against `cd846916`. @@ -52,6 +56,10 @@ another SHA is named. The target's own citations were written against `cd846916` 8 behind origin, with uncommitted work. This pass did not touch it. All reads used `git show`/`git grep` against SHAs. +- Update at v2: `origin/codex/item-provenance` is now `da9f51b9`, 5 ahead of `cd846916`. `42edc03a` and + `da9f51b9` add only `docs/narrative-cut.md` (checked with `git diff --stat 53d0f304 da9f51b9`: one file). Cut 0 + therefore cherry-picks 5 doc commits, not 3. None of them conflicts, because neither doc exists on fc12. + **Plan consequence:** fc12 merges to master first. The narrative campaign then branches from that merge. It cherry-picks the 3 doc commits with no conflict, applies the corrections in section 1, and leaves `codex/item-provenance` for the operator to retire (Q9). @@ -97,6 +105,29 @@ Also found, not in the target: extension pattern against longer extensions. That was not probed under Unity. The typed-record cut deletes the globs, so the question dies with them. +### v2 additions: the tag metadata census + +The Q2 ruling moves all tag metadata into typed records, so v2 took a census of every tag in the corpus +(`grep '#'` over every `.ink`/`.ink2` at `b66ba524`, excluding comment lines) and of every consumer of those tags. +Only three files carry any metadata tags: +- `Locations/TestA.ink:1-7`: `constraint`, `type`, `security`, `faction`, `name`, `nameZone`, `turrets`. + This is an engine fixture that moves to `tests/` (Q5 B). +- `Quests/TestQuest.ink:2-3`: the knot-level tags `location` and `required`. Also an engine fixture. +- `ReconStationAlpha.ink:1-3`: `planet`, `constraint`, `trade`. **This is Emily's file.** + +No other Emily file carries a tag of any kind. + +| # | Tag / mechanism | Consumer at `b66ba524` | Finding | +|---|---|---|---| +| C12 | `name` → `LocationStory.Name` (`StoryProcessor.cs:206`) | **None.** No code reads `LocationStory.Name`. The station entity is not named from it (`ZoneGenerator.cs:292-310`). | Dead metadata. Its migration disposition is Q11. | +| C13 | `nameZone` → `zone.Name` (`:219-222`). TestA's comment says named zones are "excluded from being placed together" (`:198` filters `!z.NamedZone`). | `GalaxyZone.NamedZone` (`Galaxy.cs:565`) is **never set true anywhere** (`git grep 'NamedZone *='` finds nothing). The documented exclusion has never worked. | Migrate `ZoneName` and set `NamedZone` in the same write, so the documented rule holds. Alternatively drop both; see the Cut 1 disposition table. | +| C14 | `type` → `LocationStory.Type` (`:212-214`) | `ZoneGenerator.cs:208` builds stations only for `Type == Station`, and assigns `station.Story = i` with `i` indexing that **filtered** array (`:292-306`). `EntitySerializer.cs:77` resolves `pack.Story` against the **unfiltered** `zone.GalaxyZone.Locations`. So an `Asteroid` or `Planet` place listed before a station in the same zone makes that station resolve to the wrong story. Non-station places are also never given an entity. | This is a latent index bug. Only `Station` works end to end. Cut 1 drops `type`: every place is a station until another kind is built. That removes the misalignment by construction. | +| C15 | `constraint`/`select` anchors and `faction` | `ResolveFaction` matches by **name prefix** (`StoryProcessor.cs:97-100`, `StartsWith`). `ResolveZone("home.")` calls `HomeZones.ContainsKey(faction)` with a possibly null faction (`:77-82`), and `Dictionary.ContainsKey(null)` throws. Both selectors throw on an empty candidate list: `RandomSelector` calls `NextInt(0)`, and `OrderedZoneSelector` calls `First()` (`ZoneSelectors.cs:18-22, 45-48`). `DistanceConstraint` silently returns false on a malformed operator (`ZoneConstraints.cs:62-81`). | Typed refs and typed operators delete every one of these string-parsing failure modes. The empty-candidate case becomes an explicit "not placed" result (Cut 2). | + +`planet` and `trade` (RSA) have **no consumer at all**: `ProcessLocation` never reads them. There is a +dock-gated `Trade` menu tab (`MenuPanel.cs:72-79`, `MenuTabButton.RequireDock`), which is a plausible consumer +for `trade`. I did not infer one. See Q11. + ## 2. The standing ruling (preserve verbatim) Already in the target's Open section at `53d0f304`. Carry it forward unchanged: @@ -158,6 +189,8 @@ The answer decides whether quests have progress state, completion, rewards, item ### Q2. Where does quest identity (title and credits) live? +*History (v2): ruled, see Rulings. Cut 1 v2 supersedes option A's shape. There is no `Kind` field; `NarrativeData` is an abstract base with `PlaceData` and `QuestData` documents, and it carries all metadata, not only identity.* + Context: the header needs identity at every surface. Emily's files cannot be edited, so her files cannot carry tags. `GetContentTags` truncates titles at a second colon. Ink tags are prose inside content. A catalog record is typed, lives in `GameData/Aetheria.cc` beside `ItemData`, is editable in CultCache Studio, and can be @@ -185,6 +218,8 @@ Corvus6) is place-shaped. Under the invariant as written, her place text would r ### Q4. What is a quest item for? +*History (v2): ruled "both". Cut 4 is now mapped, and the option text below is history.* + Context: nothing like it exists. Two shapes are natural. (i) A `Provenance` variant (union slot 3, for example `Granted { Quest }`), so a particular lot came from a quest and the inspection header reads it from the lot, as `Brand` does. (ii) A design-level link, where an `ItemData` belongs to a quest, so every instance of that design @@ -248,113 +283,314 @@ Context: that campaign merged on 09-17. The branch now carries only the narrativ - **Recommended: A.** A campaign name pointing at another campaign's doc is a false map. Deleting it is your call. +### Forks raised by the Q2 and Q4 rulings (v2, open) + +Cut 1 assumes the recommendation for Q10 and Q11. Cut 4 assumes the recommendation for Q12 and Q13. A +different ruling rewrites only the named pieces. + +### Q10. "The loader refuses metadata tags", but Emily's RSA carries three and cannot be edited + +Context: the Q2 ruling says Ink carries no metadata tags and the loader refuses them. `ReconStationAlpha.ink:1-3` +has `#planet`, `#constraint` and `#trade`, and the Emily ruling forbids editing it. A strict loader therefore +can never load RSA. Once migrated, the tags are inert, because no code reads tags any more (Cut 1 deletes every +tag reader). The question is only where the refusal lives, and how RSA passes it. +- **A. Refuse at the loader, with a typed acknowledgement.** The loader throws on any global or knot-start tag, + unless the story's record lists that exact tag text in `SupersededTags` (string[]). Authors see the tag in + Studio, next to the typed field that replaced it. For RSA that list is its three lines. For every new story it + is empty. +- **B. Loader ignores tags; a corpus test refuses them.** Runtime never looks at tags. A test fails on a tag + in any shipped story, and carries a named exemption for RSA. +- **C. Strict refusal, and RSA stays unloadable** until you rule otherwise. +- **Recommended: A.** It keeps your words ("the loader refuses them"), puts the exemption in typed state rather + than in test code, and makes the migration visible per record. It is not a mode flag: it names the exact inert + text, and any other tag still throws. + +### Q11. What do `#planet`, `#trade` and `#name` mean? + +Context: the ruling migrates `#planet`, `#constraint` and `#trade`. `constraint` has a live meaning. `planet` +and `trade` have never had a consumer (census, C12-C15). `#name` (TestA only) has no consumer either. Your +standing rule is to ask what a concept is for before specifying it from legacy text. +- **`#planet: ReconStationAlpha`.** A: it is the place's display name, so it becomes the station entity's name, + and `#name` means the same thing. B: RSA should be a planet-type place (not built; see C14). C: drop it. +- **`#trade: disabled`.** A: a `TradeDisabled` bool that hides the dock-gated Trade tab (`MenuPanel.cs:50-52`) + at this place's station. B: drop it. +- **Recommended:** `planet` A, merged with `name` into one `DisplayName` field that names the station entity + (one field for one meaning). `trade` A, because the consumer already exists and the cost is one line at + `MenuPanel.cs:52`. If you'd rather not decide now, record the values in `SupersededTags` only (Q10 A) and add no + fields. No field ships without a consumer. + +### Q12. What triggers a reward grant? + +Context: Q4 ruled rewards are lots with `Granted { Quest }` provenance. Something must decide when a quest +grants. Ink cannot reach the game today: Emily's `pickup(x)`/`drop(x)` (`ReconStationAlpha.ink:39-45`) are pure +Ink functions over Ink variables, not engine calls. +- **A. Typed, per knot.** `QuestData.Rewards` lists `(Knot, what)`. The engine grants when a quest advance + takes that knot's visit count from 0 to at least 1. Ink stays free of engine calls. Studio edits the rewards, + and validation checks every knot path exists. +- **B. Ink calls out.** An `EXTERNAL grant(key)` function, bound by the engine. Game data then lives inside + Ink text, which is the shape the Q2 ruling moved away from. +- **Recommended: A.** It matches the Q2 direction (metadata in typed state). Because Ink's persisted visit + counts (Q7) own "already granted", a reload can never double-grant, and no second ledger is needed. + +### Q13. Where does a reward go when the player's cargo is full? + +Context: grants happen while docked, in the Local tab. `EquippedCargoBay.TryStore` (`Entity.cs:1805-1890`) returns false +when there is no room. +- **A.** Into the docked station's docking bay (`OrbitalEntityPack.DockingBayContents` persists it), so the + player collects it there. +- **B.** The grant is refused and retried on the next advance. This needs "granted" state beyond visit counts, + which is a second owner. +- **C.** The reward is lost. +- **Recommended: A.** It keeps visit counts as the single owner of "granted", and it matches how docked cargo + already persists. + +### Q14. Does RSA's record ship in the catalog now? + +Context: with Q2's record-as-admission rule, a `PlaceData` for RSA in `GameData/Aetheria.cc` places RSA in every +galaxy once Cut 2 revives placement. Its constraint puts it in the entrance zone, which is the tutorial entrance +too. Its content is a Halloween candy-factory story (`trickortreat`, `TheActualFactualFactory`), which does not +obviously belong in the curated opening (Q1 A). +- **A.** The migration is proven with RSA's record as a **test fixture record** (Cut 1 pins it). The shipped + catalog gains RSA only when the content campaign places it. +- **B.** Ship RSA's record now. It appears near the start of every run after Cut 2. +- **Recommended: A.** Migration fidelity and content admission are separate decisions. The content campaign owns + the second. + ## 5. Cut map Status: cut map, nothing landed. It depends on fire-control-12 merging to master (clean per `git merge-tree`). -The cuts are specified on the **recommended** answers (Q1-A, Q2-A, Q3-A, Q5-B, Q6-A, Q7-A, Q8-A). A different -ruling rewrites the named cuts. Cut 1 cannot start before Q1-Q3 are answered. +Q1-Q9 are ruled (2026-09-30), and the cuts follow those rulings. v2 also assumes the recommendations for the +still-open forks: Q10 A, Q11 as recommended, and Q14 A (all in Cut 1), and Q12 A and Q13 A (in Cut 4). A different +ruling on any of them rewrites only the piece that names it. Order: Cut 0, 1, 2, 3, 4. Each cut lands and passes +a Soul pass before the next starts. Branch for all cuts: **Aetheria `codex/narrative-1`** from the fc12→master merge commit (call it `M`). Line anchors are `b66ba524`, and Hands re-anchors them at `M`. The expected drift in these files is none, because master's only extra code parent is already contained in fc12. -**Verification transport (a rake found in this pass).** `ygg-verify.sh` cannot push Aetheria directly. The -repo's Git LFS `pre-push` hook rejects the scp-style remote (`Invalid remote name "ygg:eureka-verify/..."`). -Also, `Aetheria.Shared.csproj` needs CultLib at the pinned `45c2f400` (`Directory.Build.props`), and -`GameData/Aetheria.cc` is an LFS object. The working recipe used here is a scratch snapshot repo built with -`git archive` and pushed through `ygg-verify.sh`. For the test suite, the snapshot must also hold `CultLib/` -(`git -C F:/Projects/CultLib archive 45c2f400`), the smudged catalog (`git show :GameData/Aetheria.cc | -git lfs smudge`), and `-p:SkipCultLibRevisionCheck=true` (the pin is honoured by archiving that exact -revision). Only the Ink-only half of this recipe has been proven. Self should either land it as a stopgap -note or route it to the Idunn verify campaign. Hooks are not to be skipped. +**Verification transport: the Aetheria LFS hook breaks `ygg-verify.sh` (v2, expanded).** + +- **The break (reproduced 2026-09-29).** `ygg-verify.sh` starts with `git -C push ygg:eureka-verify/repos/.git :refs/verify/`. Aetheria has a Git LFS `pre-push` hook (`.git/hooks/pre-push` runs `git lfs pre-push "$@"`, with `filter.lfs.required true`). That hook rejects the scp-style remote: `Invalid remote name "ygg:eureka-verify/repos/Aetheria.git": invalid remote name: "F:\Projects\Aetheria\ygg:eureka-verify\repos\Aetheria.git"`. The push fails before anything reaches Yggdrasil. Skipping the hook (`--no-verify`) is not an option, and editing the running script is not safe (its own EDITING note). +- **Two more obstacles behind it**, even with the push fixed: + - `Aetheria.Shared.csproj` references CultLib and CultMath through `$(CultLibRoot)`, which defaults to `../CultLib` (`Directory.Build.props`). The pins are CultLib `45c2f4006f5f` and CultMath `6d5e2096563a`. `Directory.Build.targets` then runs `git rev-parse HEAD` and `git status --porcelain` in that root. A container clone of Aetheria has no sibling CultLib. + - `GameData/Aetheria.cc` is an LFS object (`git check-attr filter` reports `lfs`). A plain clone or archive yields the pointer, not the catalog, so every test that opens the catalog fails. +- **Workaround: a `git archive` snapshot repo.** The Ink-only form is proven: it ran on Yggdrasil twice on 2026-09-29, exit 0. The full form is specified but not yet run. + 1. `S=/aetheria-verify-; mkdir -p $S/Aetheria $S/CultLib` + 2. `git -C F:/Projects/Aetheria archive | tar -x -C $S/Aetheria`. Pass pathspecs to trim it, for example `Aetheria.Shared Assets/Scripts/ServerShared Assets/Plugins/Ink Assets/Plugins/UniRx GameData tests tools Directory.Build.props Directory.Build.targets`. + 3. `git -C F:/Projects/Aetheria show :GameData/Aetheria.cc | git -C F:/Projects/Aetheria lfs smudge > $S/Aetheria/GameData/Aetheria.cc`. This replaces the pointer with the real catalog. + 4. `git -C F:/Projects/CultLib archive 45c2f4006f5f7dab357426cabd3197e8d0a17f66 | tar -x -C $S/CultLib`, then `mkdir $S/CultMath && git -C F:/Projects/CultLib archive 6d5e2096563a320933b64ddfd6ded8f2e846ac91 packages/cultmath | tar -x -C $S/CultMath`. The two pins differ, and both commits exist in the local CultLib (checked). `CultMathRoot` defaults to `CultLibRoot`, so it must point at its own root. + 5. `cd $S && git init -q -b main && git add -A && git -c user.name=probe -c user.email=probe@local commit -qm "Aetheria + CultLib pin snapshot"`. The snapshot has no LFS hook, so the push succeeds. + 6. `ygg-verify.sh $S HEAD dotnet 'cd Aetheria && dotnet test tests/Aetheria.Shared.Tests -p:SkipCultLibRevisionCheck=true -p:CultMathRoot=$PWD/../CultMath'`. The skip is sound only because step 4 archived exactly the pinned revisions. Record both SHAs in the Hands report. +- **Owner.** This is a stopgap. The Idunn verify campaign owns the durable fix. The snapshot recipe dies when `idunn verify` accepts LFS repos and pinned siblings. Until then, Self should record the recipe beside `ygg-verify.sh`, not in this map. ### Cut 0. Land the corrected target - **Repo/branch:** Aetheria `codex/narrative-1` from `M`. -- **First:** `git cherry-pick 48b4b922 a6d06d0a 53d0f304` (docs only, conflict-free). +- **First:** `git cherry-pick 48b4b922 a6d06d0a 53d0f304 42edc03a da9f51b9` (docs only, conflict-free; the + last two carry `docs/narrative-cut.md`). The v2 text then replaces `docs/narrative-cut.md` in one commit. - **Deletes first:** the target's "Machinery that already exists" section (replaced by section 3), and the "The gap" bullet. -- **Adds:** the section 3 text. The C8 wording fix. An "Open" list pointing at Q1-Q9 and the rulings once - given. This map lands as `docs/narrative-cut.md`, with the status header per the Eureka shape. +- **Adds:** the section 3 text. The C8 wording fix. An "Open" list pointing at the rulings (Q1-Q9) and the + open forks (Q10-Q14). This map lands as `docs/narrative-cut.md`, with the status header per the Eureka shape. - **Verification:** doc-only. Negative: `rg -n "no station hull" docs/narrative-target.md` must return nothing. - **Subtraction:** about -15 / +35 doc lines. No code. -### Cut 1. Story identity is a typed catalog record +### Cut 1. Story identity and all story metadata are typed catalog records; Ink carries none -- **Deletes first:** - - `StoryProcessor.cs:51-52` (`CreateSubdirectory`: the constructor writes to the data directory). - - `StoryProcessor.cs:55-66` (directory glob enumeration of `Locations/*.ink` and `Quests/*ink`). This is the - identity-by-location-and-filename path. - - `StoryProcessor.cs:117` (the dead commented `WriteAllText`). -- **Adds:** - - `Assets/Scripts/ServerShared/Narrative/NarrativeData.cs`: - `[CultDocument("aetheria.narrative","1"), MessagePackObject] class NarrativeData`, with `Title` (string), - `Authors` (string[]), `InkPath` (string, relative to the narrative root) and `Kind` (enum `Place`, - `Quest`). This is a catalog type, so it is authored and read-only in game. - - `AetheriaStores.cs:9`: add `typeof(NarrativeData)` to `CatalogTypes`. - - Validation in `AetheriaStores.Open` next to `:34-47`: an empty `Title`, an empty or blank `Authors`, or an - empty `InkPath` throws, naming the record. This follows the "fails loudly, naming the item" rule already - there. +v2: this cut is rewritten for the Q2 ruling ("start migrating metadata there"). It assumes Q10 A, Q11 as +recommended, and Q14 A. It replaces the v1 Cut 1, which kept placement tags Ink-owned and fixed the tag parser. +Under v2 the parser is deleted, which also closes C4. + +- **Repo/branch:** Aetheria `codex/narrative-1` from `M`. Depends on Cut 0. +- **First (capture before any deletion).** Add `tests/Aetheria.Shared.Tests/NarrativeLegacyCapture.cs` and commit + it alone. It calls the **legacy** `StoryProcessor` directly (Galaxy never does, C1) on a generated tutorial galaxy + and a generated standard galaxy, for seeds 1-20. It records, per seed, the zone index the legacy tag parse + picks for three inputs: `Locations/TestA.ink`, a copy of RSA's three global tags wrapped in a fixture, and one + synthetic fixture exercising `select: DistanceFrom start` with and without `not`. It writes the result to + `tests/Aetheria.Shared.Tests/Fixtures/Narrative/legacy-placement.txt`, a plain seed/zone table that exists only + as test evidence. After the deletions, `MigratedPlacementMatchesLegacy` compares against it. Both TestA and RSA + constrain to distance 0 from the entrance, so RNG order cannot perturb them. The synthetic selector fixture uses + the ordered selector, so it does not depend on RNG either. +- **Deletes first** (lines at `b66ba524`): + - `StoryProcessor.cs:13`: `: IZoneResolver, IFactionResolver`. + - `StoryProcessor.cs:31-32, 51-52`: the folder fields and `CreateSubdirectory`, which writes to disk from a + constructor. + - `StoryProcessor.cs:55-66`: directory glob enumeration, the identity-by-folder-and-file-name path. + - `StoryProcessor.cs:68-100`: `ResolveZone` (string anchors `start`, `end`, `home.`, and a file name), + `ResolveLocation` (placement by file name), and `ResolveFaction` (name **prefix** match, C15). + - `StoryProcessor.cs:117`: the dead commented `WriteAllText`. + - `StoryProcessor.cs:127-143`: the knot-tag parse of `location` and `required`. + - `StoryProcessor.cs:154-155`: the "infinite loop" guard. Cycles are refused statically at store open instead + (below). + - `StoryProcessor.cs:158-195, 202-222`: every global-tag read (`constraint`, `select`, `name`, `faction`, + `security`, `type`, `turrets`, `namezone`). + - `StoryProcessor.cs:227-243`: `GetContentTags`, the only tag parser. + - `Narrative/ZoneConstraints.cs` (all 89 lines) and `Narrative/ZoneSelectors.cs` (all 50 lines). These are + string-argument constructors over resolver interfaces, replaced by typed data plus one evaluator. + - `Enums.cs:177-182` `LocationType`, and `ZoneGenerator.cs:208`'s `.Where(story => story.Type == + LocationType.Station)`. Every place is a station (C14). The index misalignment is gone because the list is + no longer filtered. + - `Galaxy.cs:575-586` `LocationStory`: the fields `FileName`, `Name`, `Security`, `Type` and `Turrets`. + - Fixtures (Q5 B, Q8 A): `git mv GameData/Narrative/Locations/TestA.ink` and `Quests/TestQuest.ink` (with + `.meta`) to `tests/Aetheria.Shared.Tests/Fixtures/Narrative/`, and strip their metadata tags. They are + engine fixtures, not Emily's, so they may be edited. The strip is their migration: the values move into + fixture records. The now-empty `Locations/` and `Quests/` folders go too. This moved here from v1 Cut 2, + because once the loader refuses tags, a tagged fixture could not load. +- **Adds**, in `Assets/Scripts/ServerShared/Narrative/NarrativeData.cs` (catalog types; authored, read-only in + game). The shape follows `ItemData`: an abstract base, one `CultDocument` per concrete kind, and MessagePack + unions as in `Provenance.cs:92-95`. + ```csharp + public abstract class NarrativeData { // base; keys 0-3 shared + [Key(0)] public string Title; + [Key(1)] public string[] Authors; // credit list, never one owner slot + [Key(2)] public string InkPath; // relative to GameData/Narrative + [Key(3)] public string[] SupersededTags; // Q10 A: exact inert tag text the file still carries + } + [CultDocument("aetheria.place", "1"), Inspectable, MessagePackObject] public class PlaceData : NarrativeData { + [Key(4)] public PlacementConstraint[] Constraints; // all must hold + [Key(5)] public ZoneSelection Selection; // null = any candidate, uniformly (today's RandomSelector) + [Key(6)] public CultRecordRef Faction; // unset = the zone's owner (today's default, :207) + [Key(7)] public SecurityLevel Security; // default Open (today's default) + [Key(8)] public int Turrets; + [Key(9)] public string ZoneName; // sets zone.Name AND zone.NamedZone (C13) + [Key(10)] public string DisplayName; // Q11: was #planet / #name; names the station entity + [Key(11)] public bool TradeDisabled; // Q11: hides the Trade tab at this station + } + [CultDocument("aetheria.quest", "1"), Inspectable, MessagePackObject] public class QuestData : NarrativeData { + [Key(4)] public QuestInjection[] Injections; // was knot tags #location / #required + } + [MessagePackObject] public class QuestInjection { + [Key(0)] public string Knot; [Key(1)] public CultRecordRef Place; [Key(2)] public bool Required; + } + [Union(0, typeof(EntranceAnchor)), Union(1, typeof(ExitAnchor)), + Union(2, typeof(FactionHomeAnchor)), Union(3, typeof(PlaceAnchor))] + public abstract class ZoneAnchor { } // was "start" | "end" | "home." | file name + // FactionHomeAnchor { [Key(0)] CultRecordRef Faction } PlaceAnchor { [Key(0)] CultRecordRef Place } + [Union(0, typeof(DistanceFrom)), Union(1, typeof(FactionPresent)), Union(2, typeof(FactionOwns))] + public abstract class PlacementConstraint { [Key(0)] public bool Negate; } // was the "not" prefix + // DistanceFrom { [Key(1)] ZoneAnchor Anchor; [Key(2)] Comparison Op; [Key(3)] int Hops } Comparison { Less, Equal, Greater } + // FactionPresent { [Key(1)] CultRecordRef Faction } FactionOwns { [Key(1)] CultRecordRef Faction } + [Union(0, typeof(NearestTo)), Union(1, typeof(FarthestFrom))] + public abstract class ZoneSelection { [Key(0)] public ZoneAnchor Anchor; } // was "select: [not] DistanceFrom X" + ``` + - `Narrative/Placement.cs`: the one evaluator. It is a pure function, `(Galaxy, PlaceData, resolved places) → + GalaxyZone or NotPlaced(reason)`, switching over the unions the way `ItemManager.Brand` switches over + `Provenance` (`ItemManager.cs:209-214`). An anchor that does not resolve in this galaxy (a faction absent from + it, or an unplaced place) makes its constraint false, and makes a selection `NotPlaced`. An empty candidate set + is `NotPlaced`, never an exception (C15). Cut 2 consumes `NotPlaced`. + - `AetheriaStores.cs:9`: add `typeof(NarrativeData)` to `CatalogTypes`. It is routed by `IsAssignableFrom`, + as `ItemData` is. + - Validation in `AetheriaStores.Open`, next to `:34-47` and in the same "fails loudly, naming the item" form: + - `Title`, `InkPath`, and at least one non-blank `Authors` entry are present. + - Every `CultRecordRef` (`Faction`, `Place`) resolves. + - `Hops >= 0` and `Turrets >= 0`. + - `Injections[].Knot` is non-empty. + - **The `PlaceAnchor` graph is acyclic**, which replaces the deleted runtime guard. - **Per-file changes:** - - `StoryProcessor.cs:41-53`: the constructor takes the catalog's `NarrativeData` records instead of scanning - folders. `ProcessStories` iterates records by `Kind`, in stable key order, so placement is deterministic. - - `StoryProcessor.cs:102-120` `GetStory`: key the compile cache by record key, not by file name. **Include - resolution is per story directory**: construct `AetheriaInkFileHandler` with the Ink file's own directory - (`:15-25`, `:49`, `:112`). This is the probe-proven fix that makes `ReconStationAlpha.ink` load unedited. - - `StoryProcessor.cs:122-150`, `:152-225`: `GalaxyQuest` and `LocationStory` carry - `CultRecordRef Narrative` (`Galaxy.cs:569-586`). A story whose globals include `title` or - `author` is refused, naming the file. This enforces one owner. - - `StoryProcessor.cs:228-243` `GetContentTags`: split on the first `:` only - (`tag.Substring(0, i)`, `tag.Substring(i+1)`). Placement tags stay Ink-owned. Values containing `:` must - survive (C4). - - Catalog content: Hands authors no records for real content until the operator rules what is placeable - (Q1, Q5). The catalog ships with zero `NarrativeData` records, so the pipeline has nothing to place. That is - correct and harmless while `Galaxy.cs:241` stays commented until Cut 2. + - `StoryProcessor.cs:41-53`: the constructor takes the catalog (`CultCache`) and the narrative root. It + compiles records in stable key order: places first, then quests, with places ordered by the `PlaceAnchor` + dependency order. + - `StoryProcessor.cs:102-120` `GetStory(NarrativeData)`: the compile cache is keyed by record key. Includes + resolve from the Ink file's own directory (`:15-25, :49, :112`), which is the probe-proven RSA fix. A missing + `InkPath`, a compile error, or an unknown knot in `Injections` throws, naming the record. + - **Tag refusal (Q10 A)** runs right after compile, as the only remaining reader of `globalTags` and + `TagsForContentAtPath`. Every global tag and every knot-start tag must appear verbatim in `SupersededTags`, + and every `SupersededTags` entry must be present in the file. Either mismatch throws, naming the record and + the tag. A stale acknowledgement is refused as a lie. + - `ProcessLocation` becomes `Place(PlaceData)`, a call to `Placement` plus construction of + `LocationStory { Zone, Story, Place (ref), Data (resolved PlaceData), Faction (resolved: record, else zone + owner), KnotQuests }`. `ZoneName` writes `zone.Name` and `zone.NamedZone = true` together. + - `ProcessQuest` becomes `Register(QuestData)`: for each injection, look up the placed `LocationStory` by + `Place` ref. A `Required` injection whose place is `NotPlaced` drops the quest and logs it (today's rule at + `:136-140`, keyed by ref, not by file name). + - `ZoneGenerator.cs:294-309` reads `story.Data.Security` and `story.Data.Turrets`, and sets the entity name from + `story.Data.DisplayName` when present. `MenuPanel.cs:52` gains the Trade-tab rule: hidden when the docked + station's `Story.Data.TradeDisabled` is set. (Q11 A; drop both if Q11 is ruled B.) + - `Galaxy.cs:569-573` `GalaxyQuest`: adds `CultRecordRef Quest`. +- **Record migration** (every existing tag value, with its disposition): + + | Source | Tag | Becomes | + |---|---|---| + | TestA (fixture) | `constraint: DistanceFrom start = 0` | `DistanceFrom { Anchor = Entrance, Op = Equal, Hops = 0 }` | + | TestA | `type: Station` | deleted (C14: every place is a station) | + | TestA | `security: Open` | `Security = Open` | + | TestA | `faction: Miss Terri` | `Faction` = a ref to the catalog `Faction` named "Miss Terri". The string occurs in the operator's working-tree `Aetheria.cc` (a byte grep only; that is the local `4b594e11` catalog). Hands confirms an exact-name faction at `M`. The capture test records what the legacy prefix match resolved to, and the ref must name that same faction. | + | TestA | `name: Test Location 1` | `DisplayName` (Q11) | + | TestA | `nameZone: Start Zone` | `ZoneName` | + | TestA | `turrets: 1` | `Turrets = 1` | + | TestQuest (fixture) | knot `A1`: `location: TestA`, `required` | `Injections = [{ Knot = "A1", Place = , Required = true }]` | + | RSA (Emily; file untouched) | `constraint: DistanceFrom start < 1` | `DistanceFrom { Entrance, Less, 1 }` | + | RSA | `planet: ReconStationAlpha` | `DisplayName = "ReconStationAlpha"` (Q11 A) | + | RSA | `trade: disabled` | `TradeDisabled = true` (Q11 A) | + | RSA | all three lines | `SupersededTags` = the three strings exactly as `globalTags` returns them (probe output: `planet: ReconStationAlpha`, `constraint: DistanceFrom start < 1`, `trade: disabled`) | + + The RSA record's credits are `Authors = ["Emily Harvey"]`. Its `Title` is the one piece of new text, and it is + placement, not authorship. Q14 decides where the record lives. - **Authority map:** - - Owner: the `NarrativeData` catalog record owns what loads, its title, its credits, and whether it is a - place or a quest. - - Inputs: the catalog store, and the Ink file at `InkPath`. - - Outputs: `LocationStory.Narrative` and `GalaxyQuest.Narrative`. - - Derived state: the Ink file name is no longer identity. It is derived from `InkPath` for log text only. - `LocationStory.Name` stays the in-world entity name (`#name`) and is not the story title. - - Forbidden writers: directory globs (deleted), `#title`/`#author` Ink tags (refused), git history (never - read). - - Shared paths: new game (`MainMenu.cs:132,160` → `Galaxy` ctor) and load (Cut 2) both resolve stories only - through records. - - Deletion line: `StoryProcessor.cs:51-52, 55-66, 117`. -- **Verification** (new `tests/Aetheria.Shared.Tests/NarrativeTests.cs`, run on Yggdrasil): - - `RecordIsTheOnlyAdmission`: a fixture narrative dir holds 2 Ink files, and a cache holds a record for 1. - Only that one compiles or places. Pins: no record, no story. - - `CatalogRefusesUncreditedStory`: `Open` throws on an empty `Authors` or `Title`, naming the record. Pins - the invariant at the store boundary. - - `InkIdentityTagsRefused`: a fixture with `#author:` throws, naming the file. Pins one owner. - - `IncludesResolveFromStoryDirectory`: load the real `GameData/Narrative/ReconStationAlpha.ink` read-only - through the loader and expect 0 compile errors. Pins that Emily's file loads unedited. - - `TagValuesKeepColons`: `#select: DistanceFrom home.X > 2`-style values and colon-bearing values survive. - - Negative: `rg -n 'EnumerateFiles\(' Assets/Scripts/ServerShared/Narrative` returns nothing. Also - `git diff M -- GameData/Narrative` returns empty (her files are untouched). - - Operator: Studio click-through that a `NarrativeData` record is creatable and editable in `Aetheria.cc`. -- **Subtraction:** about -20 / +70 code, about +120 test. Adds one schema. No new project, package or target. + - Owner: the `NarrativeData` catalog records (`PlaceData`, `QuestData`). They own what loads, the title, the + credits, and every placement and injection parameter. + - Inputs: the catalog store, and the Ink file at `InkPath` (words and knots only). + - Outputs: `LocationStory` (with `Place` and `Data`), `GalaxyQuest.Quest`, zone names, station security, + turrets, display name, and the Trade-tab rule. + - Derived state: `LocationStory.Faction` is resolved from the record or the zone owner. The Ink file name is + log text only. `GalaxyZone.NamedZone` is derived from `ZoneName`. + - Forbidden writers: Ink tags of any kind (refused; `SupersededTags` is acknowledgement, never input). Directory + globs. Name-prefix faction lookup. String anchors. The deleted `LocationType` filter. Git history. + - Shared paths: new game (`MainMenu.cs:132,160` → `Galaxy` ctor), load (Cut 2), and `AetherDb`'s galaxy build + all compile and place through `StoryProcessor` + `Placement` only. + - Deletion line: every item under "Deletes first". +- **Verification** (new `tests/Aetheria.Shared.Tests/NarrativeTests.cs`; heavy runs on Yggdrasil through the + snapshot transport): + - `MigratedPlacementMatchesLegacy` pins that the migration preserves placement: typed records place into the + captured zones for seeds 1-20. + - `RecordIsTheOnlyAdmission` pins no record, no story: an Ink file with no record never compiles or places. + - `CatalogRefusesUncreditedStory` pins the header invariant at the store boundary: an empty `Title` or + `Authors` throws, naming the record. + - `CatalogRefusesDanglingRefsAndCycles` pins store-open refusal: an unresolved `Faction`/`Place` ref, or an + `A → B → A` `PlaceAnchor` cycle, throws. + - `LoaderRefusesUnacknowledgedTags` pins Q10: a fixture with `#faction:` and empty `SupersededTags` throws, + naming the record and the tag. `LoaderRefusesStaleAcknowledgement` pins that a listed tag the file lacks + throws. + - `RsaLoadsUneditedWithAcknowledgedTags` pins Emily's file loading as written: the real + `GameData/Narrative/ReconStationAlpha.ink`, read-only, with a fixture `PlaceData` carrying its three + `SupersededTags`, compiles with 0 errors and is not refused. + - `UnresolvedAnchorIsNotPlaced` pins C15: a `FactionHome` anchor for a faction absent from the galaxy yields + `NotPlaced` with no exception, as does an empty candidate set. + - `ZoneNameSetsNamedZone` pins C13: the documented exclusion of named zones now holds. + - `FactionIsExactRef` pins C15: two factions sharing a name prefix resolve to the referenced one only. + - Negative: `rg -n 'globalTags|TagsForContentAtPath' Assets/Scripts` hits exactly one site, the refusal. + `rg -n 'GetContentTags|ResolveFaction|IZoneResolver|IFactionResolver|LocationType|EnumerateFiles\(' Assets + tools tests` returns nothing. Test these greps before relying on them: `LocationType` must not collide with a + Unity or Ink type name at `M`. `git diff M -- GameData/Narrative` shows only the two fixture moves; no Emily + file changes. + - Operator: a Studio click-through that a `PlaceData` with a `DistanceFrom` constraint (a union-typed field) can + be created and edited in a scratch copy of `Aetheria.cc`. **If Studio cannot author union fields, that is a + Studio defect to raise against CultLib**, not a reason to flatten the shape. +- **Subtraction:** about -265 code (StoryProcessor about 115, ZoneConstraints plus ZoneSelectors 139, enum and + fields about 11) against about +250 (types about 110, `Placement` about 70, validation about 40, wiring about 30). + Net code about 0, while two parsers, two resolver interfaces, and a string DSL disappear. Tests add about 260. It + adds two catalog schemas (`aetheria.place`, `aetheria.quest`) and removes one enum. There is no new project, + package or target. ### Cut 2. Revive placement, and make it survive save and load -- **Depends on:** Cut 1, Q5 and Q8. -- **First:** a headless probe test, `RevivedPipelineOnRealGalaxies`. It runs `ProcessStories` with fixture +- **Depends on:** Cut 1 (Q5 and Q8 are ruled). +- **First:** a headless probe test, `RevivedPipelineOnRealGalaxies`. It runs the Cut 1 pipeline with fixture records on a generated tutorial galaxy and a generated standard galaxy (the `RestoredHullsTests.cs:303,393` - construction path) across 20 seeds, and records every exception. This answers locomotion-cut.md:375 ("find - out why they were switched off") with evidence before any fix. The expected findings to confirm or refute - are the empty-candidate null dereference (`StoryProcessor.cs:197-217`) and an unresolved faction. + construction path) across 20 seeds, and records every exception. v2: the historical question from + locomotion-cut.md:375 ("find out why they were switched off") has to be answered against the **legacy** code. + So Cut 1's First-step capture also records every exception the legacy `StoryProcessor` throws on those galaxies, + before Cut 1 deletes it. The candidates are the empty-candidate throw (C15) and the null-faction `ContainsKey` + (C15). This probe then confirms that the typed pipeline throws none of them. - **Deletes first:** - `Galaxy.cs:241-243`: the commented block becomes the live call, with records passed in. - `LocalMenu.cs:106-110` (empty `Update`). - - Per Q5-B/Q8-A: `git mv` `GameData/Narrative/Locations/TestA.ink` and `Quests/TestQuest.ink` (plus - `.meta`) to `tests/Aetheria.Shared.Tests/Fixtures/Narrative/`. The empty `Locations/` and `Quests/` folders - go with them. + - (v2: the fixture move is now in Cut 1.) - **Adds and changes:** - - `StoryProcessor.cs:197-200`: when no zone satisfies a place's constraints, log it naming the record and do - not place it. Quests that `#required` it drop, using the existing path at `:136-140`. - - `SavedGame.cs:142-160` `SavedZone`: add `[Key(6)] CultRecordRef[] Locations`, the zone's + - `Placement`'s `NotPlaced` result (Cut 1) is logged, naming the record and the reason, and the place is + skipped. Quests whose `Required` injection names it drop (Cut 1's `Register`). + - `SavedGame.cs:142-160` `SavedZone`: add `[Key(6)] CultRecordRef[] Locations`, the zone's placed stories in index order. `RunSave.Capture` (`SavedGame.cs:82-90`) writes it from `zone.Locations`. - `Galaxy.cs:48-92` load constructor: takes the narrative root. For each zone, it recompiles its saved @@ -363,9 +599,13 @@ note or route it to the Idunn verify campaign. Hooks are not to be skipped. catalog lacks throws, naming it, like `ProvenanceLedger`'s loud absent lot (`Provenance.cs:25-34`). `MainMenu.cs:106` and `tools/AetherDb/Program.cs:804` pass the root. - `EntitySerializer.cs:77`: unchanged. The index is valid because order is persisted. The test pins it. - - Q7-A (if ruled): add a run-store `aetheria.questprogress` global with record key → Ink state JSON, added - to `RunTypes` (`AetheriaStores.cs:10`) and written in the same `RunSave.Commit` batch. If Q7 is not ruled, - this piece waits. It is not needed to stop the crash. + - Q7 A (ruled): add a run-store `aetheria.questprogress` global, mapping `QuestData` key → Ink state JSON (an + opaque blob sealed in one typed document). It is added to `RunTypes` (`AetheriaStores.cs:10`) and written in + the same `RunSave.Commit` batch. The load constructor restores each quest's state after re-registering it. + A saved key the catalog lacks throws. + - Recorded, not fixed here (C16): the injection preview (`LocalMenu.cs:85-86`) advances quest state on every + dock, and Q7 A now persists that. Cut 4 refuses rewards on injection knots so no grant depends on it. The + preview rebuild is a follow-up. - **Authority map:** - Owner: generation owns first placement (`StoryProcessor.ProcessLocation`). The run store (`SavedZone.Locations`) owns placement thereafter. @@ -375,23 +615,25 @@ note or route it to the Idunn verify campaign. Hooks are not to be skipped. re-rolled. - Forbidden writers: constraint evaluation on load. Any second placement pass. - Shared paths: new game, Continue, and `AetherDb` galaxy load all go through the same record-to-story compile. - - Deletion line: `Galaxy.cs:241-243` comments, `LocalMenu.cs:106-110`, fixture files out of `GameData`. + - Deletion line: `Galaxy.cs:241-243` comments, `LocalMenu.cs:106-110`. - **Verification:** - - `PlacedPlaceGetsStoryStation`: a fixture place with `DistanceFrom start = 0` on the tutorial galaxy gets a + - `PlacedPlaceGetsStoryStation`: a fixture place with `DistanceFrom { Entrance, Equal, 0 }` on the tutorial galaxy gets a station whose `Story` resolves to that record. Pins the chain from place to station to tab condition. - `PlacementSurvivesSaveAndLoad`: generate, `RunSave.Capture`+`Commit`, `new Galaxy(cache, saved, root)`, - then unpack the zone. The station's `Story.Narrative` equals the original. **Negative:** the same test at `M` + then unpack the zone. The station's `Story.Place` equals the original. **Negative:** the same test at `M` throws `ArgumentOutOfRange` (C7). Keep that failure evidence in the Hands report. - `UnplaceablePlaceIsReportedNotThrown`: constraints matching no zone produce a log line and no exception. - `QuestInjectsAtRestoredPlace`: after a load, the fixture quest's knot is registered at the restored place. - `NoFixtureInShippedGalaxy`: generate with the shipped catalog. No `LocationStory` comes from `tests/`. + - `QuestProgressSurvivesSaveAndLoad`: advance a fixture quest, commit, load; the Ink state (visit counts and + variables) is equal. Pins Q7 A. - `RunSaveTests` stays green. The run-record set changes only by Q7's document, and `IsRunRecord` covers it. - Operator (play): New Game (tutorial) → dock at the story station → the Local tab shows and the story runs → an injected choice appears → save, quit, Continue → dock → the same story and choice appear. This needs one real record that Q1 and Q5 admit. If there is none, use a fixture record in a scratch catalog, per the checklist's scratch-catalog practice. -- **Subtraction:** about -10 / +80 code, about +200 test. Adds one `SavedZone` key (optionally one run - document). Moves 2 fixtures (net 0). +- **Subtraction:** about -8 / +100 code, about +230 test. Adds one `SavedZone` key and one run schema + (`aetheria.questprogress`). ### Cut 3. The sticky header @@ -399,8 +641,8 @@ note or route it to the Idunn verify campaign. Hooks are not to be skipped. - **Deletes first:** `LocalMenu.cs:78` (the `Debug.Log` of the path/story kind). The header supersedes it as the observable signal. - **Adds:** - - `LocalMenu`: a header (TMP text) bound to the active story's `Narrative` (Title, Authors joined for - display). It updates wherever `_activeStory` changes (`:28`, `:64-71`, `:99`). Per Q6-A, `PresentChoice` + - `LocalMenu`: a header (TMP text) bound to the active story's record: `LocationStory.Place` or + `GalaxyQuest.Quest`, both `NarrativeData` (Title, Authors joined for display). It updates wherever `_activeStory` changes (`:28`, `:64-71`, `:99`). Per Q6-A, `PresentChoice` (`:93-104`) adds a credit line to choices whose `story` is not the active one. - One pure derivation, `NarrativeCredit.For(Story)`, that returns the record or throws. The UI calls only this, so no UI path can render content without an owner. @@ -418,29 +660,155 @@ note or route it to the Idunn verify campaign. Hooks are not to be skipped. quest END and the header returns to the place. After save and Continue, the header shows on first dock. - **Subtraction:** about -1 / +45 code, one prefab edit, about +40 test. -### Cut 4. Quest items: parked +### Cut 4. Quest items: granted rewards and quest-owned story objects -This cut is not mapped. It needs Q1 and Q4. Candidate anchors for when it is: `Provenance.cs:92-95` (union -slot 3), `ItemManager.cs:136-170` (lot minting), `PropertiesPanel.cs:361-386` (the inspection header goes -above `Description`), and `SavedGame.cs` via `ProvenanceLedger.Reachable`, which already persists lots. +v2: mapped per the Q4 ruling ("both"). It assumes Q12 A and Q13 A. + +- **Repo/branch:** Aetheria `codex/narrative-1`, after Cut 3. Depends on: + - Cut 1 (`QuestData`); + - Cut 2 (quest progress persisted as Ink state, Q7 A; that is what makes grant-once survive a reload); + - Cut 3 (`NarrativeCredit`, the one credit renderer). +- **First:** + - Pin the current inspection and branding behaviour. `BrandIsDerivedFromAttributedAndProduced` covers + `ItemManager.cs:206-222` over the existing `Attributed`/`Produced`/`Extracted` origins. + - Pin `RunSaveTests` over a ledger holding every existing union case, so adding union slot 3 is proven not to + disturb stored lots. + - Record **C16**, found in this pass. `LocalMenu.PresentCurrentChoices` previews each injected quest by calling + `quest.Story.ChoosePathString(_currentPath)` and then `ContinueMaximally()` (`LocalMenu.cs:85-86`). With + `countAllVisits = true` (`StoryProcessor.cs:111`), merely docking increments the quest's visit count for the + injection knot, before the player chooses anything. Under Q7 A that inflated count is persisted. So an + injection knot cannot be a reward trigger. This cut refuses it by validation (below). Rebuilding the preview so + it stops mutating quest state is recorded as a follow-up, not fixed here. It changes injection mechanics, which + Cut 2 owns. +- **Deletes first:** + - The duplicate role-fill construction. `ItemManager.CreateLot(FactionProductData)` (`ItemManager.cs:136-158`) + hard-codes `Origin = new Attributed { ... }` (`:142`). It becomes `CreateLot(FactionProductData product, + Provenance origin)`, and the one existing caller (`CreateInstance(FactionProductData)`, `:191-201`) passes + `new Attributed { Faction = product.Manufacturer }`. Rewards then reuse the role-fill loop instead of copying + it. + - `Provenance.cs:90-91`: the stale comment "Terminus mints Attributed placeholders; Produced and Extracted are + the forward shape". It is replaced by a comment naming all four cases. +- **Adds:** + - `Provenance.cs:92-95`: `Union(3, typeof(Granted))`, with + `[MessagePackObject] public class Granted : Provenance { [Key(0)] public CultRecordRef Quest; + [Key(1)] public CultRecordRef Faction; }`. `Faction` is the maker for a product reward, so the brand + survives. It is unset for a story object, which has no brand. + - `ItemData.cs:273-285` (abstract base): `[Key(33)] public CultRecordRef Quest;`. This is the + story-object link (a design owned by a quest). Census at `b66ba524`: `ItemData.cs` uses keys 0-16 and 18-32, + and every `ItemData` subclass lives in that file, so 33 is the next free key. Hands confirms nothing retired + names 33 at `M`, and does not reuse Key 3 (retired, `:281-282`). It is optional in MessagePack, so existing + catalog records read it as unset. No catalog rewrite is needed. + - `NarrativeData.cs` `QuestData`: `[Key(5)] public QuestReward[] Rewards;`, where + `QuestReward { [Key(0)] string Knot; [Key(1)] RewardSource Source; }` and `RewardSource` is a union: + `ProductReward { [Key(0)] CultRecordRef Product; [Key(1)] int Count }`, or + `DesignReward { [Key(0)] CultRecordRef Design; [Key(1)] float Quality; [Key(2)] int Count }`. + Rewards are crafted items only, because only crafted items carry a lot, and so only they can carry `Granted`. + Commodity rewards are out of scope. + - `ItemManager`: one primitive, `int CreateGrantedLot(QuestData quest, RewardSource source)`. For a product it + calls `CreateLot(product, new Granted { Quest, Faction = product.Manufacturer })`. For a design it builds the + lot with `Quality` and `Granted { Quest }`. Every quest-item lot is minted here. + - `ItemManager.Brand` (`:209-214`): adds the arm `Granted g => g.Faction`. + - `Narrative/QuestGrants.cs`: `Step(GalaxyQuest quest, Action mutate, IEnumerable shipBays, + EquippedDockingBay dockedBay)`. + - It snapshots `VisitCountAtPathString` for the quest's reward knots, runs `mutate`, and then, for each knot + that went from 0 to at least 1, mints `Count` instances through `CreateGrantedLot` and `CreateInstance`. + - It stores each instance in the first ship bay with room (`TryStore`, `Entity.cs:1881`). Otherwise it goes + into the docked bay (Q13 A), which persists through `EntitySerializer.cs:40`. If neither has room, it throws + naming the quest and the knot. A silent loss is not allowed. + - "Already granted" is derived from Ink's persisted visit counts (Q7 A). There is no second ledger. + - `LocalMenu`: every mutation of a **quest** story is routed through `QuestGrants.Step`. That covers + `Continue` (`:46`), `ChoosePath` (`:100`), and the injected-branch entry (`:99-101`). The preview at `:85-86` + is deliberately not routed. It cannot grant, because validation forbids rewards on injection knots. + - `PropertiesPanel.AddItemProperties` (`PropertiesPanel.cs:361-366`): before `AddProperty(data.Description)`, + render the quest header through Cut 3's `NarrativeCredit`. The quest is `data.Quest` if set, else the lot's + `Granted.Quest`, else none. Both inspection entry points pass through this method (`Inspect(EquippedItem)` + `:439-446` and `Inspect(ItemInstance)` `:507`), as do the Inventory and Trade menus (`InventoryMenu.cs:98,152`, + `TradeMenu.cs:316`). So the header is on every inspection surface, with one call site. + - Validation in `AetheriaStores.Open`, next to Cut 1's: + - Every reward ref resolves, and `Count >= 1`. + - A `DesignReward` naming a quest-owned design is only allowed in that design's own quest. + - **No `FactionProductData` names a quest-owned design.** Random generation and markets draw only through + products (`LoadoutGenerator.cs:126`, `Loadout.cs:100`), so this makes a story object unmintable outside its + quest by construction. + - A `ProductReward`'s design is therefore never quest-owned. + - Every `Rewards[].Knot` exists in the quest's Ink (checked at compile, as Cut 1 checks injection knots) and + is **not** an injection knot (C16). +- **Authority map:** + - Owner: `QuestData.Rewards` owns what a quest grants, and when. `ItemData.Quest` owns which designs are + story objects. `CreateGrantedLot` is the single minter of quest-item lots. + - Inputs: catalog records, and the quest's Ink visit counts. + - Outputs: lots with `Granted` origin in `ProvenanceLedger`, instances in cargo or the docked bay, and the + inspection header. + - Derived state: "already granted" is derived from Ink visit counts. The inspection header's quest is derived + from `ItemData.Quest`, else `Granted.Quest`. Brand is derived from `Granted.Faction`. + - Forbidden writers: + - Ink text (no `EXTERNAL`, Q12 A). + - UI code minting lots directly. + - Any `FactionProductData` for a quest-owned design (refused). + - The injection preview (it cannot reach a reward knot). + - The debug console `give` (`ActionGameManager.cs:522-526`) stays a dev-only writer, minting `Attributed`. + A story object minted there still shows its quest header via `ItemData.Quest`. It is out of the invariant + by being a dev tool, and it is named here so no one mistakes it for a path. + - Shared paths: the direct choice path and the continue path both go through `QuestGrants.Step`. So does reload: + visit counts restore from the run store, so re-entry after Continue cannot re-grant. + - Deletion line: the hard-coded `Attributed` in `CreateLot(product)` (`ItemManager.cs:142`), and the stale + comment at `Provenance.cs:90-91`. +- **Verification** (headless, in `NarrativeTests.cs` and `RunSaveTests.cs`; on Yggdrasil through the snapshot + transport): + - `RewardGrantedOnFirstVisitOnly` pins grant-once, with visit counts as the owner: stepping into a reward knot + grants `Count`, and stepping into it again grants nothing. + - `RewardNotRegrantedAfterReload` pins that the reload path shares the owner. Grant, `RunSave` commit, load + (Cut 2), and re-enter the knot: no second grant, and the ledger holds exactly one `Granted` lot per grant. + - `GrantedLotKeepsBrand`: a `ProductReward` lot's `Brand` returns the product's manufacturer and product. Pins + the `Granted.Faction` arm. + - `StoryObjectHasNoProductAndNoBrand` pins unmintable-outside-quest: a quest-owned design with a + `FactionProductData` naming it makes `Open` throw, and its granted lot brands as `(null, null)`. + - `RewardOnInjectionKnotRefused` pins C16: validation throws, naming the quest and the knot. + - `FullCargoFallsToDockedBay` pins Q13 A: ship bays full means the item lands in the docked bay and persists + through `PackEntity`. Both full throws. + - `GrantedSurvivesLedgerPrune`: `ProvenanceLedger.Reachable` keeps a `Granted` lot reachable from a stored + instance, and enqueues nothing for it (it has no inputs). Pins `Provenance.cs:38-58` over the new case. + - `UnionSlot3DoesNotDisturbStoredLots`: the First-step ledger fixture round-trips unchanged. + - Negative: `rg -n 'new Granted' Assets/Scripts` hits only `ItemManager.CreateGrantedLot`. + `rg -n 'CreateGrantedLot' Assets/Scripts/UI` returns nothing. `rg -n 'EXTERNAL' GameData/Narrative` returns + nothing new. + - Operator (play): + - Dock at a fixture quest station, take the branch to the reward knot, and see the item appear in cargo. + - Inspect it: the quest header (title and authors) shows above the description, with the manufacturer line + intact. + - Save, quit, Continue, re-enter the knot: no second item. + - Fill cargo and repeat on a second reward: the item appears in the station bay. + - Inspect a story object: the quest header shows, and there is no manufacturer. +- **Subtraction:** about -8 / +150 code (`Granted` about 10, `ItemData.Quest` about 3, rewards types about 30, + `CreateGrantedLot` about 20, `QuestGrants` about 50, `LocalMenu` routing about 10, header about 10, + validation about 20). Tests add about 250. It adds one union case, one `ItemData` key, and one `QuestData` key. + There is no new schema, project or target. The positive delta buys the ruled capability (Q4 "both"). No existing + owner carries quest origin, so reuse was limited to `CreateLot`'s role fill and `Brand`'s switch. ### Out of this map -- Content: the curated opening and the widening galaxy. Records for Emily's files and any new quests need Q1 - and Q5. Extensions of her premise are separate records crediting their actual authors. +- Content: the curated opening and the widening galaxy. Records for Emily's files (Q14 for RSA) and any new + quests are content decisions under Q1 A and Q5 B. Extensions of her premise are separate records crediting + their actual authors. +- The injection preview mutating quest state (C16). It should preview without advancing the quest's story (for + example, reading choices from a state copy). That changes injection mechanics. Cut 4 only fences it. - `Thread.Sleep(500)` at `Galaxy.cs:246` ("to make it seem like it's doing more work"). Unrelated. Note it for a separate sweep. +- The verification transport (stopgap). It belongs beside `ygg-verify.sh` and in the Idunn verify campaign, not + in this map. -## 6. Subtraction ledger (estimate) +## 6. Subtraction ledger (estimate, v2) -| Cut | Code − | Code + | Test + | Schemas / targets | +| Cut | Code − | Code + | Test + | Schemas / types / targets | |---|---|---|---|---| -| 0 | 0 | 0 | 0 | none (doc about ±50) | -| 1 | ~20 | ~70 | ~120 | +1 catalog schema `aetheria.narrative` | -| 2 | ~10 | ~80 | ~200 | +1 `SavedZone` key; optionally +1 run schema (Q7) | +| 0 | 0 | 0 | 0 | none (doc about ±600, including this map) | +| 1 | ~265 | ~250 | ~260 | +2 catalog schemas (`aetheria.place`, `aetheria.quest`); -1 enum (`LocationType`); -2 files (`ZoneConstraints.cs`, `ZoneSelectors.cs`); -2 interfaces | +| 2 | ~8 | ~100 | ~230 | +1 `SavedZone` key; +1 run schema (`aetheria.questprogress`) | | 3 | ~1 | ~45 | ~40 | 1 prefab edit | -| 4 | parked | | | | +| 4 | ~8 | ~150 | ~250 | +1 `Provenance` union case; +1 `ItemData` key (33); +1 `QuestData` key | -This is net additive. The capability it buys is explicit and ruled: credited, persisted narrative that does -not exist today. Nothing smaller works. Identity has no current owner to reuse, and the only existing carrier +Code is net additive by about 270 lines across the campaign, and Cut 1 is roughly net zero. The capability it +buys is ruled: credited, placed, persisted narrative, and quest items, none of which exists today. Cut 1 buys its +schemas by deleting two parsers, two resolver interfaces, a string placement DSL, and the dead +`LocationType`/`Name`/`FileName` fields. Identity has no current owner to reuse, and the only existing carrier (Ink tags) cannot reach Emily's files.