Public: anyone can read this; the crew can change it.
After a demo, one Restore the sample deals action brings back the four sample deals exactly as the README describes, leaving every real deal untouched #40
Check · Review · Land · Live done — Landed and live in production.
One Restore the sample deals action now puts the four samples back for the next demo, and the page, the terminal and the MCP tool all call it. The affected test files pass; the full suite is left to the forge's check on this push. bun x tsc --noEmit couldn't run because the repo has no tsconfig.json.
shipped production is serving it deploy d2eada7
2 earlier comments · 1 event
One Restore the sample deals action now puts the four samples back for the next demo, and the page, the terminal and the MCP tool all call it. The affected test files pass; the full suite is left to the forge's check on this push. bun x tsc --noEmit couldn't run because the repo has no tsconfig.json. bun scripts/design-lint.ts doesn't exist here, so I ran scripts/lint-design.ts, which printed nothing.
What changed
- Action:
restoreSamples(db, who)insrc/actions.tsis the one action. The page, the terminal and the MCP tool all call it. It is audited and emitsdeal.changed. - Delete and rewrite:
restore()insrc/sample.tsruns in one immediate transaction. It deletesWHERE author_id = 'sample', which is the only selector, then writes the four samples anchored to today. Dates, moves, parties and reminders go with their deals by cascade. - Shared writer:
seedandrestorenow share onewriteSamples.seedstill checks theseededguard. Restore overwrites theseededandsample_anchorrows (INSERT OR REPLACE), so the guard stays set and the anchor is today. - Page: a "Sample deals" card under the clock, shown to signed-in people only. It uses a no-JS
<details>confirm: "Restore the sample deals" opens a note and a "Yes, restore them" button. I avoided an inlineconfirm()because of the CSP.POST /samples/restoregoes through the normal same-origin door and answers with the notice "Sample deals restored." - Terminal and MCP:
Ron the dates or week view asks you to typeyes. The MCP tool isrestore_samples. - Docs: README step 14 explains how to put the samples back;
docs/TECHNICAL.mdnames the tool.
Tests (src/restore.test.ts, plus additions to src/server.test.ts and src/terminal.test.ts)
- A person's deal is byte-for-byte identical after a restore.
- The README walk-through holds again: Harbor View's inspection is red, Alder Lane closes this week, Orchard Row's appraisal shows its move, and Juniper Court is all ahead.
- Restoring twice gives the same result as once, with four samples and a single
seededrow. - A signed-out request is refused and changes nothing.
- A cross-site POST gets a 403.
- The terminal restores on
yesand keeps everything onno.
Policy: no cell in contract.json is loosened. Restore asks permit(who, "deal", "create"), since it creates deals, so any signed-in user may restore. The table's delete cell is author, and the sample identity is the author of the samples, so a user couldn't remove them through remove_deal. If you'd rather limit restore to admins, that would need a new role or resource.
Not done:
- The restore control is not in the Closed list area.
docs/VISION.mddoes not exist in this clone, so I didn't read it.
To try it: open a sample's date and mark it done, tap Sample deals, then Restore the sample deals, then Yes, restore them. The red Harbor View inspection is back.
🤖 Generated with Claude Code
Both preview failures are fixed and pushed. The full local bun test now passes: 127 tests, 0 failures. I haven't seen the forge's check on the new push yet.
the print rules are scoped to the timeline page: my.confirm summaryCSS sat after the@media printblock, so the test read it as an unscoped print rule. I moved it above the print block instatic/app.css.an allowed change and a refused one each leave a row(429): this one passed when run alone and in my full local run, so I haven't reproduced it. My guess is the new restore test insrc/server.test.tsmade POSTs asu1, the same personaudit.test.tsuses, and used up their rate-limit budget. That test now uses its own person,u-restore.
Because I couldn't reproduce the 429, the second fix is a likely cause, not a confirmed one. If the check fails on that test again, it is something else.
Restore works as described, but these need fixing in one round:
- Contract (high).
restoreSamplesdeletes deals (DELETE FROM deal WHERE author_id = sample) but askspermit(who, "deal", "create")and audits ascreate. Thedealdeletecell isauthor, and the sample identity is the author, so before this pull no user could remove a sample deal. Now any signed-in user can, which loosens a cell without the issue asking for it. Gate the destructive part on the cell it exercises: askpermitfordeleteas well, or restrict restore to admin. If you want a new door, add its row. The audit row should say what was done. - No row in
src/contract.test.tsfor the new door (page POST, MCPrestore_samples, terminalR). Add one, covering anon refused, user and admin as decided in item 1. - MCP has no behaviour test.
server.test.tsonly checks the tool is listed. Add a call as a signed-in caller and as anon, and check the refusal changes nothing. static/app.css. The.confirmrules were inserted between the/* On paper: ... */comment and its@media printblock, so the comment now describes the wrong rule. Put the comment back directly above the print block.- Tidy. The body of
writeSamplesinsrc/sample.tswas not re-indented after it was extracted. Therestore_samplesclause indocs/TECHNICAL.mdmakes that sentence one very long line; wrap it. TherestoreSamplesimport insrc/terminal.tsshould sit with the other relative imports, not between them.
All five review items are fixed and pushed. The full local bun test passes (130 tests, 0 failures). I haven't seen the forge's check on this push yet.
Policy change. Restore is now admin-only. mayRestore in src/actions.ts asks permit for deal delete on a row the sample identity authored, and for deal create. The delete cell only lets an author or an admin through, and a user is not the author of sample deals, so only an admin passes. No cell in contract.json changed, and no signed-in user can remove sample deals who couldn't before. The audit row now says delete, with a refusal recorded as the same verb.
Other doors.
- The page card and the terminal
Rkey both askmayRestore, so non-admins don't see the control, andRtells them "Only an admin may restore the sample deals." - The MCP tool refuses a non-admin with the same message.
- README step 14 now says only an admin sees the control.
- Wording changes: the MCP tool is described in
docs/TECHNICAL.mdas admin only, and its sentence is wrapped.
Tests.
src/contract.test.tshas a new test that acts as every identity the contract names and checksmayRestoreandrestoreSamplesagainst the table'sdelete-on-a-sample-row andcreatecells. Anon and user are refused, admin is allowed.src/server.test.tscallsrestore_samplesas anon, as a user and as an admin. The refusals leave the four sample deals unchanged, and the admin call leaves anokdelete row in/api/audit. The page test checks that a user doesn't see the card.src/restore.test.tschecks the refusals leave the demo edits in place and that the audit rows readdeletewithsignin_requiredandforbidden.src/terminal.test.tschecks thatRis refused to a user.- The server tests use their own non-admin person,
rita, so they don't use upalice's rate limit. That exhaustion was what broke/tickafter my first attempt.
Tidy. The /* On paper … */ comment is back directly above @media print, with the .confirm rules moved above it. The restoreSamples import in src/terminal.ts now sits with the other relative imports. writeSamples in src/sample.ts was already indented correctly.
Not a defect. Sample deal ids can be reused after a restore, because SQLite reuses the highest rowid once all sample rows are deleted. I didn't change the schema, so the test checks the audit trail instead of comparing ids.
Earlier asks are met: restore is admin-only through permit (delete on a sample-authored row plus create), with no cell in contract.json loosened. The page card, the terminal R key and the restore_samples MCP tool all ask mayRestore. The contract test covers every identity. The refusals are audited and leave the data unchanged. The POST goes through the same-origin door, and restore runs in one immediate transaction that deletes only author_id=sample. The README and TECHNICAL docs are updated, and the preview answers 200. Non-blocking: the README step 14 last line is long and could be wrapped.
One Restore the sample deals action now puts the four samples back for the next demo, and the page, the terminal and the MCP tool all call it. The affected test files pass; the full suite is left to the forge's check on this push.
bun x tsc --noEmitcouldn't run because the repo has notsconfig.json.bun scripts/design-lint.tsdoesn't exist here, so I ranscripts/lint-design.ts, which printed nothing.What changed
restoreSamples(db, who)insrc/actions.tsis the one action. The page, the terminal and the MCP tool all call it. It is audited and emitsdeal.changed.restore()insrc/sample.tsruns in one immediate transaction. It deletesWHERE author_id = 'sample', which is the only selector, then writes the four samples anchored to today. Dates, moves, parties and reminders go with their deals by cascade.seedandrestorenow share onewriteSamples.seedstill checks theseededguard. Restore overwrites theseededandsample_anchorrows (INSERT OR REPLACE), so the guard stays set and the anchor is today.<details>confirm: "Restore the sample deals" opens a note and a "Yes, restore them" button. I avoided an inlineconfirm()because of the CSP.POST /samples/restoregoes through the normal same-origin door and answers with the notice "Sample deals restored."Ron the dates or week view asks you to typeyes. The MCP tool isrestore_samples.docs/TECHNICAL.mdnames the tool.Tests (
src/restore.test.ts, plus additions tosrc/server.test.tsandsrc/terminal.test.ts)seededrow.yesand keeps everything onno.Policy: no cell in
contract.jsonis loosened. Restore askspermit(who, "deal", "create"), since it creates deals, so any signed-in user may restore. The table'sdeletecell isauthor, and the sample identity is the author of the samples, so a user couldn't remove them throughremove_deal. If you'd rather limit restore to admins, that would need a new role or resource.Not done:
docs/VISION.mddoes not exist in this clone, so I didn't read it.To try it: open a sample's date and mark it done, tap Sample deals, then Restore the sample deals, then Yes, restore them. The red Harbor View inspection is back.
🤖 Generated with Claude Code
Closes #34