Public: anyone can read this; the crew can change it.

An open deal nothing has touched in 14 days says so on the clock #313

Parked opened this
Closed without merging

An open deal nothing has touched in 14 days now shows a "Quiet 16 days" badge beside its address on the clock, and the deal page says when it was last touched. All tests pass except one speed-budget case that failed once under load. I couldn't run `scripts/gate.ts`, `scripts/fast.ts`, `scripts/design-lint.ts` or `bun x tsc --noEmit`, because none of them exist in this clone or its config.

stopped parked by the crew deploy f4f821e

opened this

An open deal nothing has touched in 14 days now shows a "Quiet 16 days" badge beside its address on the clock, and the deal page says when it was last touched. All tests pass except one speed-budget case that failed once under load. I couldn't run scripts/gate.ts, scripts/fast.ts, scripts/design-lint.ts or bun x tsc --noEmit, because none of them exist in this clone or its config.

What changed

  • Quiet rule: src/quiet.ts is the pure function. A deal is quiet when it is open, 14 or more days have passed since its last touch, and no open date is due today or in the next 3 days. Closed and fell-through deals are never quiet. An overdue date does not exempt a deal, because the clock already flags it and it is the deal a client would ask about.
  • Last touch: src/deals.ts adds DealView.touched. It is the latest day, in the agent's timezone, of any of these:

- the deal being opened; - a date marked done or waived; - a date moved; - a message sent or declined; - any allowed change to the deal in the audit trail, which covers party and note edits.

There is no migration, and the clock list reads the audit trail in one grouped query rather than one per deal.

  • Display: src/pages/quiet.ts draws the badge on the clock lane and a "Last touched N days ago" line on the deal page. Closed and fell-through deals show nothing. The output is escaped, and .quiet-badge is in static/app.css and listed in docs/design/areas/clock.md.
  • Sample data: 2210 Juniper Court now boots with 16 quiet days, with its dates pushed out so none is due soon. refresh keeps it quiet by shifting its created_at forward as the days pass.
  • README: the tour gets one sentence, mirrored in src/tour.ts, since a test requires the two to match.
  • Tests: src/quiet.test.ts covers quiet at 14 days and not at 13, the due-soon exemption, closed deals, the audit and done-date touches, and the sample boot.

What I chose not to do

  • No contract cell changes and no migration.
  • No new setting for the 14-day or 3-day thresholds.

Test results

  • The full bun test run had one failure: the speed-budget test, which took 54 ms against the 50 ms limit while the whole suite ran in parallel. Run on its own, src/speed.test.ts passes (27 of 27), including with my changes stashed.
  • The tour/README test failed on the first full run; it passes now.

To try it

  • Open the preview and look for "Quiet 16 days" on 2210 Juniper Court.
  • Open that deal to see its last-touched line.
  • Mark one of its dates done and the badge goes away.

Closes #310

commented

An open deal nothing has touched in 14 days now shows a "Quiet 16 days" badge beside its address on the clock, and the deal page says when it was last touched. All tests pass except one speed-budget case that failed once under load. I couldn't run scripts/gate.ts, scripts/fast.ts, scripts/design-lint.ts or bun x tsc --noEmit, because none of them exist in this clone or its config.

What changed

  • Quiet rule: src/quiet.ts is the pure function. A deal is quiet when it is open, 14 or more days have passed since its last touch, and no open date is due today or in the next 3 days. Closed and fell-through deals are never quiet. An overdue date does not exempt a deal, because the clock already flags it and it is the deal a client would ask about.
  • Last touch: src/deals.ts adds DealView.touched. It is the latest day, in the agent's timezone, of any of these:

- the deal being opened; - a date marked done or waived; - a date moved; - a message sent or declined; - any allowed change to the deal in the audit trail, which covers party and note edits.

There is no migration, and the clock list reads the audit trail in one grouped query rather than one per deal.

  • Display: src/pages/quiet.ts draws the badge on the clock lane and a "Last touched N days ago" line on the deal page. Closed and fell-through deals show nothing. The output is escaped, and .quiet-badge is in static/app.css and listed in docs/design/areas/clock.md.
  • Sample data: 2210 Juniper Court now boots with 16 quiet days, with its dates pushed out so none is due soon. refresh keeps it quiet by shifting its created_at forward as the days pass.
  • README: the tour gets one sentence, mirrored in src/tour.ts, since a test requires the two to match.
  • Tests: src/quiet.test.ts covers quiet at 14 days and not at 13, the due-soon exemption, closed deals, the audit and done-date touches, and the sample boot.

What I chose not to do

  • No contract cell changes and no migration.
  • No new setting for the 14-day or 3-day thresholds.

Test results

  • The full bun test run had one failure: the speed-budget test, which took 54 ms against the 50 ms limit while the whole suite ran in parallel. Run on its own, src/speed.test.ts passes (27 of 27), including with my changes stashed.
  • The tour/README test failed on the first full run; it passes now.

To try it

  • Open the preview and look for "Quiet 16 days" on 2210 Juniper Court.
  • Open that deal to see its last-touched line.
  • Mark one of its dates done and the badge goes away.
commented

I pushed a fix for the preview failure, but I can't confirm the speed-budget tests pass: the machine is heavily loaded (load average about 39), and they still fail intermittently here. The deploy log you sent ended on passing tests with no failure shown, so I took the cause from my own full runs: the speed-budget tests were the ones failing.

Cause: reading a deal's last touch queries the audit trail by deal, and the trail had no index on that column. Every read of the clock, the people page and the reminder review therefore scanned the whole trail, which pushed those pages past the 50 ms budget.

Fix:

  • Migration: I appended one migration to the end of the list in src/db.ts, an index on audit (resource, target, at), and updated src/migrations.pin.json with its hash.
  • Query plan: the plan now shows the query searching by that index instead of scanning.
  • Existing test: the old-database upgrade test in src/migrations.test.ts builds its "before" schema from a filtered list of migrations. It failed once the new migration existed, so I excluded the new index from that list.

Test status: the migration and upgrade tests pass (70 of 70). The last two full bun test runs here still failed between two and four speed-budget cases, and different ones each time. src/speed.test.ts alone passed on a quieter machine before the index and failed on this one after it, so I couldn't compare before and after. The forge's check will give the real verdict.

What changed: the pull still adds the Quiet badge to the clock lane and a last-touched line to the deal page, with one sample deal (2210 Juniper Court) quiet on a fresh boot. This fix adds one migration, which the issue said to avoid if possible; it sits at the end of the list and is pinned.

commented

I pushed a change that makes reading a deal's last touch cheaper, but I can't confirm the four speed-budget tests now pass.

What I found:

  • Same four tests: your failures were people (200 deals), and the clock, reminder review and people after a deal changes.
  • Machine load: this machine's load average was 40–66 during my runs. Unmodified main failed the same speed-budget cases here, with times around 53 ms against the 50 ms limit.
  • Small real cost: my change did add about 1 ms to loading the deal list, measured at 200 deals. That is enough to tip a test already sitting near the limit, so I didn't write the failures off as load alone.

What changed (src/deals.ts):

  • Single pass: it used to build a list of every stamp and convert each to a day in the agent's timezone. It now tracks the latest stamp in one pass and converts only that one. The conversion was the expensive part.
  • Earlier index: the audit index from the previous push stays. A micro-benchmark puts the audit lookup at about 0.5 ms.

Tests: src/quiet.test.ts, the sample tests, and the migration and upgrade tests pass. After this change the list-load time was about the same as before, within the noise on this machine. I couldn't typecheck: this repo has no tsconfig.json, so bun x tsc --noEmit only prints its help text.

If the forge's check fails the same four tests again on a quiet machine, the remaining option is to compute the last touch only where it is shown, on the clock and the deal page, rather than for every deal in every list.

commented

Parked by the crew: the check stayed red through 2 automatic tries

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs