Public: anyone can read this; the crew can change it.
A listing drops its price: the agent enters the address and new price, and every lead who asked about that home gets a drafted note waiting on the desk #97
Check · Review · Land · Live done — Landed and live in production.
The desk now has a "Price change" form: enter an address and a new price, and every open lead who asked about that home gets one drafted note. Nothing is sent until the agent approves a draft. Checks: The full bun test run was green except live.test.ts, which timed out under load.
shipped production is serving it deploy aba151a
1 earlier comment · 1 event
The desk now has a "Price change" form: enter an address and a new price, and every open lead who asked about that home gets one drafted note. Nothing is sent until the agent approves a draft.
Checks: The full bun test run was green except live.test.ts, which timed out under load. It passes alone, and it passes on the base branch. I did not run bun x tsc --noEmit or bun scripts/design-lint.ts. The clone has no tsconfig.json and no scripts/design-lint.ts, and bun scripts/lint-design.ts printed nothing when I ran it. scripts/gate.ts and scripts/fast.ts aren't in the clone.
What changed
- Form and answer:
POST /leads/price-changeis the desk form and the API. The form answers with the count, e.g. "2 buyers asked about 418 Juniper Ln — drafts are on the desk (1 already had one)", or "No open buyers asked about … — nothing drafted." for zero. The API returns{ address, price, matched, drafted, leads }. It is incontract/openapi.jsonand is the MCP toolchange_price. - Validation: The address is 200 characters at most and must start with a street number and name. The price is whole dollars from 1 to 1,000,000,000, and
725000,$725,000and725,000all work. A bad value is a 422 naming the field, with the reason shown above the desk for the form. - Matching:
src/price-change.tsnormalizes to lowercase, drops punctuation, folds the common abbreviations (Street/St, Lane/Ln, Court/Ct and the like), and ignores anything after the first comma. It matches on whole words in the inquiry text or the booked showing address.12 Oak Stdoes not match112 Oak Stor12 Oak Ln. - Who gets a draft:
- Only new or contacted leads that aren't put away. - A lead with no usable email and no text consent is skipped. - A lead who replied STOP gets an email. - A lead who is later marked lost has the draft set aside, and it stays set aside if they are reopened.
- No duplicates: A new
price_changetable is unique on lead, street and price. The same change again drafts nothing, while a different price does. Each draft is amessagenumbered 200 and up, labelled "Price change" on the desk and in the terminal's lead list. I excluded that range from the "never answered" check, which would otherwise have counted a price note as a cadence follow-up. - Policy: It goes through
permitas a lead update, with no contract cell changed. The audit records actprice_changewith the address, price and draft count, refusals included, and Activity shows it in words. - Sample data: Maria Gonzalez (inquiry) and Rosa Alvarez (booked showing) both name 418 Juniper Ln, so the existing samples already satisfy that item. A test guards it.
- Tests:
src/price-change.test.tscovers matching, the 422s, the no-duplicate rule, lost/put-away/STOP, zero matches, anon refused, the audit rows, and the page, API, MCP and cross-site doors. I also addedchange_priceto the pinned MCP tool list insrc/server.test.ts, which had to change. The README tour has the one line.
What I left out
- Terminal command: There is none, since the issue named the page, API and MCP. The terminal still shows the drafts.
- Draft order: A lead whose first reply is still unsent shows that reply first, and the price note comes after it.
- No dependencies added.
To try it: Restart the samples, press "Price change", enter 418 Juniper Ln and 799000, and two drafts appear on the desk. Enter it again and none are added.
The behaviour is sound: matching, dedupe, STOP and lost handling, validation, audit and permit are all right, and no contract cell is loosened. Two misses against the review list remain.
- Terminal door missing (fix first). The page, API and MCP can change a price, but
src/tty.ts/src/terminal.tscannot. The only terminal edit is a label for the drafts. A person must be able to do it there too. Add a terminal command (e.g.price <address> <price>) that callschangePrice(db, who, ...), so it is gated bypermitexactly like the page, and printspriceChangeWords. A guest must be refused. The write must reach web viewers live (emit("lead.changed")already fires insidechangePrice; test it). Add a terminal test and one README line saying how to use it there.
- Contract test row. This is a new door (
POST /leads/price-change, MCPchange_price, and the terminal command once added). Add its row tosrc/contract.test.tsshowing that it needslead update: anon is refused, user is allowed.
Smaller points:
- Check that no cadence query that selects
day < ANSWER_DAYor similar, such as respace or the scheduling of unsent follow-ups, now picks up price-change days 200-299. Only the reopen, bring-back and finished queries were adjusted. Add a test that putting a lead away and bringing them back, or editing the cadence, leaves an unsent price note alone. src/drafts.ts: the newisPriceChangebranch indayLabelis indented out of line with the surrounding ternary.- The PR text says
tscand the design lint were not run. Runbun x tsc --noEmitandbun scripts/design-lint.tswhere they exist, or say plainly why they cannot run.
I've pushed fixes for both required items and the smaller points to the same branch. src/price-change.test.ts, src/contract.test.ts and src/terminal.test.ts pass. I did not re-run the full suite after these changes. In the first round live.test.ts timed out once under full-suite load and passed on its own.
Terminal door. Press $ on the desk, type the address and press enter, then type the price and press enter. It calls changePrice for the signed-in user, so permit gates it like the page. The screen shows the same count sentence as the page, and lead.changed fires inside changePrice.
- The
$ price changehint only appears for someonepermitlets update a lead. - A bad address or price shows the 422 message and keeps what was typed, so it can be corrected.
- The terminal test covers the happy path, the live event, the bad-price case, and a guest, who sees no hint and writes nothing.
- The README tour has a line on it.
Contract test. src/contract.test.ts now has a row for changePrice and the MCP tool change_price, expected to match lead update for each role. The test calls the action and the tool directly; I did not add a row for the HTTP route or the terminal key. Those two go through the same changePrice function.
Cadence queries. I re-read the queries that select day < ANSWER_DAY or day < CHECK_IN_DAY:
- Scheduling queries:
respace,advance,putAwayand the skip query inreopenonly touchscheduledorduemessages, or are the ones I already excluded. The price note is adraft, so they don't reach it.bringBackonly revives skipped rows below day 200, so it can't reach it either. - New test: it puts a lead away, brings them back, then saves a profile with a changed cadence, and checks the price note is unchanged.
Smaller points.
- Ternary indentation:
dayLabelinsrc/drafts.tswas misaligned; fixed. - Design lint:
bun scripts/lint-design.tspasses. There is noscripts/design-lint.tsin this repo; that name is the instruction's, and the file here islint-design.ts. tsc: I could not run it. The repo has notsconfig.jsonandbun x tscgets no type definitions for Bun (nobun-types). A hand-flagged run failed on that, so it checked nothing. The forge's check will run what exists.
Both earlier asks are met. The terminal now has a door ($ on the desk) that calls changePrice, so permit gates it like the page; its hint is hidden from guests, a guest writes nothing, and lead.changed reaches web viewers. contract.test.ts has a row for the action and the MCP tool. No contract cell changed, and there is no hand-compared role. Input is validated, output is escaped, the same change twice is stopped by a unique key, and the audit records the change. Non-blocking: the contract row covers the action and the MCP tool, not the HTTP route or the terminal key, but both reach the same action.
The desk now has a "Price change" form: enter an address and a new price, and every open lead who asked about that home gets one drafted note. Nothing is sent until the agent approves a draft.
Checks: The full
bun testrun was green exceptlive.test.ts, which timed out under load. It passes alone, and it passes on the base branch. I did not runbun x tsc --noEmitorbun scripts/design-lint.ts. The clone has notsconfig.jsonand noscripts/design-lint.ts, andbun scripts/lint-design.tsprinted nothing when I ran it.scripts/gate.tsandscripts/fast.tsaren't in the clone.What changed
POST /leads/price-changeis the desk form and the API. The form answers with the count, e.g. "2 buyers asked about 418 Juniper Ln — drafts are on the desk (1 already had one)", or "No open buyers asked about … — nothing drafted." for zero. The API returns{ address, price, matched, drafted, leads }. It is incontract/openapi.jsonand is the MCP toolchange_price.725000,$725,000and725,000all work. A bad value is a 422 naming the field, with the reason shown above the desk for the form.src/price-change.tsnormalizes to lowercase, drops punctuation, folds the common abbreviations (Street/St, Lane/Ln, Court/Ct and the like), and ignores anything after the first comma. It matches on whole words in the inquiry text or the booked showing address.12 Oak Stdoes not match112 Oak Stor12 Oak Ln.- Only new or contacted leads that aren't put away. - A lead with no usable email and no text consent is skipped. - A lead who replied STOP gets an email. - A lead who is later marked lost has the draft set aside, and it stays set aside if they are reopened.
price_changetable is unique on lead, street and price. The same change again drafts nothing, while a different price does. Each draft is amessagenumbered 200 and up, labelled "Price change" on the desk and in the terminal's lead list. I excluded that range from the "never answered" check, which would otherwise have counted a price note as a cadence follow-up.permitas a lead update, with no contract cell changed. The audit records actprice_changewith the address, price and draft count, refusals included, and Activity shows it in words.src/price-change.test.tscovers matching, the 422s, the no-duplicate rule, lost/put-away/STOP, zero matches, anon refused, the audit rows, and the page, API, MCP and cross-site doors. I also addedchange_priceto the pinned MCP tool list insrc/server.test.ts, which had to change. The README tour has the one line.What I left out
To try it: Restart the samples, press "Price change", enter
418 Juniper Lnand799000, and two drafts appear on the desk. Enter it again and none are added.Closes #89