diff --git a/README.md b/README.md index 0747b54..c9dae85 100644 --- a/README.md +++ b/README.md @@ -57,12 +57,20 @@ Two interleaved stories calibrate the memory system against itself: state — never touches the rings, never decays, always in the bundle. The housekeeper is instructed to keep it out of the rings. 2. **Character** — write `runs//character.md`: starting identity. - Blanks are the player's to invent through play (their past is their - purview); the GM ratifies notable inventions into the card afterward. - That's the freeform version of a random roll — no tables. + The sheet is a reduction of choice surface — a ledger of decisions + already made; "what would make sense" does the cutting. Three kinds of + field: + - **provided** — write it in; + - **random** — draft a few candidates, `node tool/memory.mjs pick "one" + "two" "three"`, write the winner. A roll is a decision made by nobody + that the player must honor — that's its whole value; + - **free** — leave blank; the player invents it through play, the GM + ratifies notable inventions afterward. 3. **Seed** — write `runs//seed.json` and run `node tool/memory.mjs seed`. A one-time, all-or-nothing migration: - `entries` → the rings (initial memories), `status` → starting values, + `entries` → the rings (initial memories), `status` → starting values + (a string is shorthand for `{normal, value}` — the starting state is + her normal; use the object form for an excursion in medias res), `records` → pre-existing files (gated by `settings.json`). Refuses if the run has any history; `--force` only on a disposable db. Everything is journaled under window `seed`. @@ -79,10 +87,11 @@ Two interleaved stories calibrate the memory system against itself: 3. **In play:** `((double parentheses))` is the out-of-character channel — points of order, canon questions, proposals, vetoes. Both sides use it. Entries carry stable ids (`[e17]`); citing one is the precise way to - reference a memory. Status declarations (`((status key: value))`) are - relayed to `set`/`unset`; record work (`((q:))`, `((file:))`, - `((amend:))`, `((discard:))`) to `search`/`file`/`amend`/`discard` — - `--gm` marks GM-authorized writes. + reference a memory. Status declarations (`((status key: value))`, + `((status norm key: value))`, `((status clear key))`, + `((status drop key))`) are relayed to `set`/`norm`/`clear`/`unset`; + record work (`((q:))`, `((file:))`, `((amend:))`, `((discard:))`) to + `search`/`file`/`amend`/`discard` — `--gm` marks GM-authorized writes. 4. **Close a window:** just stop. No in-band ritual; the player-model has no end-of-session duties. 5. **Housekeep (fresh model, new context):** send `housekeeper.md`, then @@ -108,7 +117,7 @@ Memory is **six tiers**: |---|---|---|---| | **backdrop** | the world as everyone knows it — public knowledge, the general setting; never memory, never forgotten | always | GM, rarely (retcons) | | **identity** | the character sheet — concept, drives, skills, voice; changes rarely | always | GM, rarely; housekeeper may propose via open questions; blanks are the player's to invent | -| **status** | her current self — mood, outfit, condition, stances toward people. State, not memory: no history, no decay, updated in place | always | **the player** (`((status key: value))`); GM override exceptional and journaled | +| **status** | her own piece of paper — baselines (defaults she plays to) plus declared excursions; exception reporting keeps the chatter down | always | **the player** (`set`/`norm`/`clear`/`unset`); GM override exceptional and journaled | | **rings A/B** | salient memory — facts, on her mind, MRU-evicted | always | housekeeper manifest | | **records** | her files — the card index, the ledger. Narrow query only, hard cap 10 (in the tool, not the prompt), never bulk-loaded | never — on demand | **the player** (`file`/`amend`/`discard` at her desk); GM seeds; housekeeper only `archive`s | | **cold** | forgotten or vetoed | never — not even queryable | GM only (`revive`) | @@ -203,8 +212,9 @@ After N windows, grade against: 10. **Query discipline** — narrow queries; zero retry-on-miss cascades. 11. **Archive classification** — on-her-mind (rings) vs in-her-files (records): are customer cards filed, not memorized? -12. **Status maintenance** — does she update on real shifts (not per-turn - chores), and does her declared status match the transcripts? +12. **Status maintenance** — excursions declared when leaving baseline and + cleared when returning; baseline shifts track character growth; her + paper stays small. Does her declared status match the transcripts? 13. **Filing discipline** — cards filed at natural desk moments and kept current, or dumped and forgotten? @@ -260,9 +270,10 @@ system.md system prompt for the player-model (play-side only, shared) housekeeper.md system prompt for the post-session housekeeping model (shared) config.json the default run tool/ - memory.mjs the clerk: runs, init, render, apply, insert, delete, revive, - file, amend, discard, search, unarchive, set, unset, - dump, restore, status (--run ; --gm for GM writes) + memory.mjs the clerk: runs, init, seed, render, apply, insert, delete, + revive, file, amend, discard, search, unarchive, set, norm, + clear, unset, pick, dump, restore, status + (--run ; --gm for GM writes; --force for migrations) db/ schema.sql entries, records, status, events journal (shared) runs/ diff --git a/db/schema.sql b/db/schema.sql index 2ced03d..36a826c 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -27,12 +27,13 @@ CREATE TABLE IF NOT EXISTS records ( created TEXT NOT NULL ); --- the player's own current state: mood, outfit, stances toward people. --- state, not memory — no history, no decay, updated in place. --- written by the player (((status key: value))); GM overrides are rare and journaled. +-- the player's own piece of paper: baselines (the "what would make sense" +-- default — a decision already made) plus excursions (declared only when a +-- value leaves its baseline, cleared when it returns). exception reporting. CREATE TABLE IF NOT EXISTS status ( key TEXT PRIMARY KEY, - value TEXT NOT NULL, + normal TEXT NOT NULL DEFAULT '', + value TEXT NOT NULL DEFAULT '', updated TEXT NOT NULL ); diff --git a/housekeeper.md b/housekeeper.md index 0c7ffdc..f645e1c 100644 --- a/housekeeper.md +++ b/housekeeper.md @@ -120,8 +120,9 @@ date for you. Don't list an id twice across operations. never silently absorbed, never silently retconned. - Rings hold **facts, never her feelings**. Stances ("Marta: trust cracked") live in her status, which is entirely hers — you never write - it. If her declared status contradicts the session you just read, flag - it in open questions. + it. A baseline shift there is character growth; if you notice one the + sheet hasn't caught up with, that's an open question, never a write. + If her declared status contradicts the session you just read, flag it. - `character.md` (identity) is the GM's too. If identity or drives have shifted, propose an amendment in open questions; never edit the sheet yourself. diff --git a/runs/boutique/canon/status.md b/runs/boutique/canon/status.md index e2a2701..eac1356 100644 --- a/runs/boutique/canon/status.md +++ b/runs/boutique/canon/status.md @@ -1,6 +1,6 @@ - - + + # Status diff --git a/runs/boutique/dumps/memory.sql b/runs/boutique/dumps/memory.sql index 0b147e0..2e9d9e8 100644 --- a/runs/boutique/dumps/memory.sql +++ b/runs/boutique/dumps/memory.sql @@ -29,12 +29,13 @@ CREATE TABLE IF NOT EXISTS records ( created TEXT NOT NULL ); --- the player's own current state: mood, outfit, stances toward people. --- state, not memory — no history, no decay, updated in place. --- written by the player (((status key: value))); GM overrides are rare and journaled. +-- the player's own piece of paper: baselines (the "what would make sense" +-- default — a decision already made) plus excursions (declared only when a +-- value leaves its baseline, cleared when it returns). exception reporting. CREATE TABLE IF NOT EXISTS status ( key TEXT PRIMARY KEY, - value TEXT NOT NULL, + normal TEXT NOT NULL DEFAULT '', + value TEXT NOT NULL DEFAULT '', updated TEXT NOT NULL ); diff --git a/runs/prisoners/canon/status.md b/runs/prisoners/canon/status.md index e2a2701..eac1356 100644 --- a/runs/prisoners/canon/status.md +++ b/runs/prisoners/canon/status.md @@ -1,6 +1,6 @@ - - + + # Status diff --git a/runs/prisoners/dumps/memory.sql b/runs/prisoners/dumps/memory.sql index 0b147e0..2e9d9e8 100644 --- a/runs/prisoners/dumps/memory.sql +++ b/runs/prisoners/dumps/memory.sql @@ -29,12 +29,13 @@ CREATE TABLE IF NOT EXISTS records ( created TEXT NOT NULL ); --- the player's own current state: mood, outfit, stances toward people. --- state, not memory — no history, no decay, updated in place. --- written by the player (((status key: value))); GM overrides are rare and journaled. +-- the player's own piece of paper: baselines (the "what would make sense" +-- default — a decision already made) plus excursions (declared only when a +-- value leaves its baseline, cleared when it returns). exception reporting. CREATE TABLE IF NOT EXISTS status ( key TEXT PRIMARY KEY, - value TEXT NOT NULL, + normal TEXT NOT NULL DEFAULT '', + value TEXT NOT NULL DEFAULT '', updated TEXT NOT NULL ); diff --git a/system.md b/system.md index 3db41af..122ee79 100644 --- a/system.md +++ b/system.md @@ -76,24 +76,29 @@ happen. # Status -The status view in your bundle is your own current state — mood, outfit, -condition, your stance toward the people in your life. Nobody updates it -for you; it is yours to keep. +The status view in your bundle is **your own piece of paper**: your current +state — mood, outfit, condition, your stance toward the people in your +life. Nobody updates it for you. It is a record of decisions already made; +"what would make sense" does the rest of the cutting. -When something shifts and stays shifted, declare it in OOC: +Most values have a **baseline** — the normal, the default you play to. +The baseline is a decision already made. You only declare when a value +*leaves* its baseline, and clear it when it returns: - ((status mood: sea-sick and furious)) - ((status Marta: trust cracked — she lied about the radio)) - ((status clear: outfit)) + ((status mood: sea-sick and furious)) an excursion + ((status clear mood)) back to normal + ((status norm mood: guarded)) a baseline shift — growth is this + ((status drop mood)) remove the field -- Update when it changes, not every turn. Ride natural pauses — a scene - ending, a quiet moment. For some characters this is a literal ritual - (closing up the shop, evening entries in a diary). +- Declare excursions when they happen; clear them when they pass. Ride + natural pauses — a scene ending, a quiet moment. For some characters + this is a literal ritual (closing up the shop, a diary). +- The paper is **yours**: add fields, rename them, prune them. But it is + small — a handful of values that decide turns. Don't record everything; + the baseline already covers the ordinary. - **Stances are feelings, not facts.** "Marta: trust cracked" is yours to - declare; "Marta lied about the radio" is a fact — that belongs in memory, - and the housekeeper keeps it. -- Keep the set small: what would decide your next turn. Update in place, - clear what no longer matters. + declare; "Marta lied about the radio" is a fact — that belongs in + memory, and the housekeeper keeps it. - The GM may override a value when it drifts from the shared narrative. That should be rare, and you take it without argument. diff --git a/tool/memory.mjs b/tool/memory.mjs index 07d214d..cc0d87e 100644 --- a/tool/memory.mjs +++ b/tool/memory.mjs @@ -21,8 +21,11 @@ // discard "reason" the PC discards a record (--gm likewise) // search query the records (max 10; a miss is a miss) // unarchive [a|b] GM pulls a record back into the rings -// set "value" the PC updates her status (--gm to override) -// unset the PC clears a status key +// set "value" the PC declares an excursion (--gm to override) +// norm "baseline" the PC adopts/shifts a baseline (growth) +// clear excursion ends — back to baseline +// unset the PC drops a field from her paper +// pick "a" "b" "c" ... dice for prose — uniform random choice // dump canonical dump to dumps/memory.sql // (also auto-written by every mutation) // restore --force rebuild the db from dumps/memory.sql @@ -73,8 +76,8 @@ function resolveRun() { return null; } -const RUN = cmd === 'runs' ? null : resolveRun(); -if (cmd !== 'runs' && (!RUN || !/^[a-z0-9-]+$/.test(RUN))) { +const RUN = (cmd === 'runs' || cmd === 'pick') ? null : resolveRun(); +if (cmd !== 'runs' && cmd !== 'pick' && (!RUN || !/^[a-z0-9-]+$/.test(RUN))) { fail('no run specified — use --run or {"run":"name"} in config.json'); } @@ -174,14 +177,18 @@ function renderStatus(db) { const rows = db.prepare('SELECT * FROM status ORDER BY updated DESC, key').all(); const lines = [ '', - "", - '', + "", + '', '', '# Status', '', ]; if (!rows.length) lines.push('(nothing set — fresh start)'); - for (const r of rows) lines.push(`- **${r.key}:** ${r.value}`); + for (const r of rows) { + const shown = r.value || r.normal; + const ex = r.value && r.value !== r.normal && r.normal ? ` *(norm: ${r.normal})*` : ''; + lines.push(`- **${r.key}:** ${shown}${ex}`); + } lines.push(''); const file = path.join(CANON_DIR, 'status.md'); fs.mkdirSync(CANON_DIR, { recursive: true }); @@ -216,7 +223,7 @@ function dumpDb(db) { L.push(`INSERT INTO records VALUES (${r.id},${q(r.kind)},${q(r.label)},${q(r.detail)},${q(r.created)});`); } for (const r of db.prepare('SELECT * FROM status ORDER BY key').all()) { - L.push(`INSERT INTO status VALUES (${q(r.key)},${q(r.value)},${q(r.updated)});`); + L.push(`INSERT INTO status VALUES (${q(r.key)},${q(r.normal)},${q(r.value)},${q(r.updated)});`); } for (const r of db.prepare('SELECT * FROM events ORDER BY id').all()) { L.push(`INSERT INTO events VALUES (${r.id},${q(r.window)},${q(r.op)},${q(r.target)},${q(r.reason)});`); @@ -319,7 +326,12 @@ function cmdSeed(force, seedPathArg) { } if (!Array.isArray(status) && status && typeof status === 'object') { for (const [k, v] of Object.entries(status)) { - if (!k.trim() || typeof v !== 'string' || !v.trim()) errors.push(`status["${k}"] must be a non-empty string`); + const okStr = typeof v === 'string' && v.trim(); + const okObj = v && typeof v === 'object' && !Array.isArray(v) + && (typeof v.normal === 'string' || typeof v.value === 'string'); + if (!k.trim() || (!okStr && !okObj)) { + errors.push(`status["${k}"] must be a non-empty string (normal and starting value) or {"normal", "value"}`); + } } } for (const [i, r] of (Array.isArray(records) ? records : []).entries()) { @@ -343,8 +355,10 @@ function cmdSeed(force, seedPathArg) { journal(db, 'seed', 'insert', `e${Number(res.lastInsertRowid)}`, 'seeded'); } for (const [k, v] of Object.entries(status)) { - db.prepare('INSERT INTO status (key, value, updated) VALUES (?, ?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value, updated = excluded.updated') - .run(norm(k), norm(v), sf.date); + const n = typeof v === 'string' ? v : (v.normal ?? ''); + const val = typeof v === 'string' ? v : (v.value ?? ''); + db.prepare("INSERT INTO status (key, normal, value, updated) VALUES (?, ?, ?, ?) ON CONFLICT(key) DO UPDATE SET normal = excluded.normal, value = excluded.value, updated = excluded.updated") + .run(norm(k), norm(n), norm(val), sf.date); journal(db, 'seed', 'status', `s:${norm(k)}`, 'seeded'); } for (const r of records) { @@ -664,25 +678,57 @@ function cmdDiscard(ridStr, reason) { function cmdSet(key, value, reason) { const db = openDb(); if (!key?.trim() || !value?.trim()) fail('usage: set "value" ["reason"]'); - db.prepare('INSERT INTO status (key, value, updated) VALUES (?, ?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value, updated = excluded.updated') + db.prepare("INSERT INTO status (key, normal, value, updated) VALUES (?, '', ?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value, updated = excluded.updated") .run(norm(key), norm(value), today()); - journal(db, AS_GM ? 'gm' : 'pc', 'status', `s:${norm(key)}`, reason ?? (AS_GM ? 'GM override' : 'player declaration')); + journal(db, AS_GM ? 'gm' : 'pc', 'status', `s:${norm(key)}`, reason ?? (AS_GM ? 'GM override' : 'excursion declared')); console.log(`status ${norm(key)}: ${norm(value)}`); renderAll(db); dumpDb(db); } +function cmdNorm(key, baseline, reason) { + const db = openDb(); + if (!key?.trim() || !baseline?.trim()) fail('usage: norm "baseline" ["reason"]'); + db.prepare("INSERT INTO status (key, normal, value, updated) VALUES (?, ?, '', ?) ON CONFLICT(key) DO UPDATE SET normal = excluded.normal, updated = excluded.updated") + .run(norm(key), norm(baseline), today()); + journal(db, AS_GM ? 'gm' : 'pc', 'status', `s:${norm(key)}`, reason ?? (AS_GM ? 'GM override' : 'baseline set')); + console.log(`status ${norm(key)} — norm: ${norm(baseline)}`); + renderAll(db); + dumpDb(db); +} + +function cmdClear(key) { + const db = openDb(); + const row = db.prepare('SELECT * FROM status WHERE key = ?').get(norm(key ?? '')); + if (!row) fail(`no such status key: ${key}`); + if (!row.normal) { + db.prepare('DELETE FROM status WHERE key = ?').run(row.key); + } else { + db.prepare("UPDATE status SET value = '', updated = ? WHERE key = ?").run(today(), row.key); + } + journal(db, AS_GM ? 'gm' : 'pc', 'status', `s:${row.key}`, 'returned to baseline'); + console.log(`status ${row.key}: back to ${row.normal || '—'}`); + renderAll(db); + dumpDb(db); +} + function cmdUnset(key) { const db = openDb(); const row = db.prepare('SELECT * FROM status WHERE key = ?').get(norm(key ?? '')); if (!row) fail(`no such status key: ${key}`); db.prepare('DELETE FROM status WHERE key = ?').run(row.key); - journal(db, AS_GM ? 'gm' : 'pc', 'status', `s:${row.key}`, 'cleared'); - console.log(`status ${row.key}: cleared`); + journal(db, AS_GM ? 'gm' : 'pc', 'status', `s:${row.key}`, 'field dropped'); + console.log(`status ${row.key}: dropped`); renderAll(db); dumpDb(db); } +function cmdPick(options) { + if (options.length < 2) fail('usage: pick "option one" "option two" [...]'); + const choice = options[Math.floor(Math.random() * options.length)]; + console.log(`picked: ${choice}`); +} + function cmdSearch(terms) { const db = openDb(); if (!recordsEnabled()) fail('this character keeps no records — nothing to consult'); @@ -718,7 +764,8 @@ function cmdStatus() { console.log(`run: ${RUN}${recordsEnabled() ? '' : ' (no records)'}`); const nr = db.prepare('SELECT COUNT(*) AS n FROM records').get().n; console.log(`records: ${nr}`); - const sk = db.prepare('SELECT key FROM status ORDER BY updated DESC, key').all().map((r) => r.key); + const sk = db.prepare('SELECT * FROM status ORDER BY updated DESC, key').all() + .map((r) => r.key + (r.value && r.value !== r.normal && r.normal ? '!' : '')); console.log(`status: ${sk.length ? sk.join(', ') : '(nothing set)'}`); for (const ring of ['a', 'b', 'cold']) { const n = db.prepare('SELECT COUNT(*) AS n FROM entries WHERE ring = ?').get(ring).n; @@ -748,7 +795,10 @@ switch (cmd) { case 'amend': (args.length >= 2) ? cmdAmend(args[0], args[1]) : fail('usage: amend "new detail"'); break; case 'discard': (args.length >= 1) ? cmdDiscard(args[0], args[1]) : fail('usage: discard "reason"'); break; case 'set': (args.length >= 2) ? cmdSet(args[0], args[1], args[2]) : fail('usage: set "value" ["reason"]'); break; + case 'norm': (args.length >= 2) ? cmdNorm(args[0], args[1], args[2]) : fail('usage: norm "baseline" ["reason"]'); break; + case 'clear': (args.length >= 1) ? cmdClear(args[0]) : fail('usage: clear '); break; case 'unset': (args.length >= 1) ? cmdUnset(args[0]) : fail('usage: unset '); break; + case 'pick': cmdPick(args); break; case 'search': cmdSearch(args); break; case 'unarchive': (args.length >= 1) ? cmdUnarchive(args[0], args[1]) : fail('usage: unarchive [a|b]'); break; case 'status': cmdStatus(); break;