Public: anyone can read this; the crew can change it.
Sample deals look like today on every boot, not like the day the database was made #11
Check · Review · Land · Live done — Landed and live in production.
Sample deals now move forward to today on every boot, so a database seeded weeks ago still shows one overdue, one closing this week, one moved appraisal and one just signed. I ran the tests for db, sample, deals, server and terminal, and all pass. I did not run bun x tsc --noEmit, because the repo has no tsconfig.json.
shipped production is serving it deploy d2eada7
Sample deals now move forward to today on every boot, so a database seeded weeks ago still shows one overdue, one closing this week, one moved appraisal and one just signed. I ran the tests for db, sample, deals, server and terminal, and all pass. I did not run bun x tsc --noEmit, because the repo has no tsconfig.json. The repo has no scripts/gate.ts or scripts/fast.ts. I did not run scripts/design-lint.ts, since nothing in src/web/ changed.
What changed
- Migration (
src/db.ts): a new migration, appended after the existing ones, records the anchor day assample_anchorinapp_meta. It copies the existingseededvalue, so production's Oct 12 database anchors to Oct 12.seed()writessample_anchorfor new databases. - Pure shift (
src/sample.ts):shiftSample(dates, anchor, on)adds the days since the anchor to every date of a sample deal. That covers the contract date, each deadline and its done stamp, and each move's from and to dates. It reads no clock, and anonthat is not later than the anchor changes nothing. - Touched check:
isUntouched(state, anchor)is also pure. A sample counts as changed if any of these is true:
- someone marked a date done or added a done date (a done stamp that isn't the seeded one); - a move was made by anyone but the seed; - a date or party was added; - a reminder was sent; - the address was edited.
- On boot:
refresh(db, on = today())shifts every untouched sample and then sets the anchor toon.openDbcalls it right afterseed, in one immediate transaction, so a second process on the same file does nothing. - README: the "Four sample deals" paragraph now says the samples stay current and that one you changed is left alone.
Tests
src/sample.test.tschecks the shift with twoondates a month apart, the no-op whenonisn't later than the anchor, and each way a sample counts as changed.src/db.test.tshas a new test that boots a database seeded 30 days ago. It finds the closing-this-week deal closing in 4 days, the appraisal moved to +2 and its move row moved with it, and the anchor set to today. It also marks a date done on the Juniper Court sample and finds that deal unchanged.
Choices
- A sample with any sent reminder counts as changed and is never shifted, so
reminder.duenever needs rewriting and sent marks can't resurface as unsent. - A changed sample stays at its old dates for good, because the anchor moves on without it.
- The shift runs on boot only, as the issue says. A server that stays up for days won't shift until it restarts.
server.tsneeded no edit, sinceopenDbalready runs at boot.- No contract cell changed.
To try it, open a database whose anchor is old. The overdue and closing-this-week deals come up on the clock at the next boot.
Clean. The shift is pure and clock-injected, the migration pins the anchor to the existing seeded day, refresh runs in one immediate transaction, and no contract cell or door changed. Tests fail without the change (shift, untouched rules, 30-day-old boot, touched sample left alone). Not blocking: a single touch (e.g. one date marked done) freezes that sample at its old dates for good, which the README states; and an app that stays up for days only refreshes at restart, as the issue says.
Sample deals now move forward to today on every boot, so a database seeded weeks ago still shows one overdue, one closing this week, one moved appraisal and one just signed. I ran the tests for
db,sample,deals,serverandterminal, and all pass. I did not runbun x tsc --noEmit, because the repo has notsconfig.json. The repo has noscripts/gate.tsorscripts/fast.ts. I did not runscripts/design-lint.ts, since nothing insrc/web/changed.What changed
src/db.ts): a new migration, appended after the existing ones, records the anchor day assample_anchorinapp_meta. It copies the existingseededvalue, so production's Oct 12 database anchors to Oct 12.seed()writessample_anchorfor new databases.src/sample.ts):shiftSample(dates, anchor, on)adds the days since the anchor to every date of a sample deal. That covers the contract date, each deadline and its done stamp, and each move's from and to dates. It reads no clock, and anonthat is not later than the anchor changes nothing.isUntouched(state, anchor)is also pure. A sample counts as changed if any of these is true:- someone marked a date done or added a done date (a done stamp that isn't the seeded one); - a move was made by anyone but the seed; - a date or party was added; - a reminder was sent; - the address was edited.
refresh(db, on = today())shifts every untouched sample and then sets the anchor toon.openDbcalls it right afterseed, in one immediate transaction, so a second process on the same file does nothing.Tests
src/sample.test.tschecks the shift with twoondates a month apart, the no-op whenonisn't later than the anchor, and each way a sample counts as changed.src/db.test.tshas a new test that boots a database seeded 30 days ago. It finds the closing-this-week deal closing in 4 days, the appraisal moved to +2 and its move row moved with it, and the anchor set to today. It also marks a date done on the Juniper Court sample and finds that deal unchanged.Choices
reminder.duenever needs rewriting and sent marks can't resurface as unsent.server.tsneeded no edit, sinceopenDbalready runs at boot.To try it, open a database whose anchor is old. The overdue and closing-this-week deals come up on the clock at the next boot.
Closes #4