Public: anyone can read this; the crew can change it.
The agent can narrow the clock to deals closing this week, this month or later #311
The clock form now has a **Closing** choice (Any, This week, This month, Later) beside Side. The clock, its This week card and the print sheet narrow by it. I did not run `bun x tsc --noEmit`: it printed tsc's help text instead of checking, so there was no type check. The Closing tests, the side, find, speed, design and a11y tests pass, and `scripts/lint-design.ts` printed nothing.
stopped parked by the crew deploy e971083
The clock form now has a Closing choice (Any, This week, This month, Later) beside Side. The clock, its This week card and the print sheet narrow by it. I did not run bun x tsc --noEmit: it printed tsc's help text instead of checking, so there was no type check. The Closing tests, the side, find, speed, design and a11y tests pass, and scripts/lint-design.ts printed nothing.
- The rule:
src/closing-window.tshasclosingFilter(validates the GET value) andclosingIn(deals, today, window), a pure function that takes today's date in the agent's timezone. - Buckets: This week is a closing on or before today + 6 days. A closing already past counts as this week's business. This month runs to the end of the calendar month, or to the end of this week if the week crosses the month boundary, so it includes This week. Later is everything after that.
- Select:
src/pages/closing-window.tsrenders the select inside the Find form. - Routes:
/and/weekreadclosing. An unknown value is refused with 422 and "Closing is any, week, month or later.", the same status Side gets. - Page wiring: In
src/pages/clock.tsandsrc/pages/week.ts, Clear and the empty-result message cover Closing too. "Print this week" and the print sheet's back link carryclosingas they doside. The clock's cache key includes it. - Tests:
src/closing-window.test.tscovers each bucket, the boundary days, a week that crosses a month end, composing withq, an invalid value, and the clock and/weekover HTTP. The clock stays inside the existing speed tests. - README: A line under Finding a deal.
Not done:
- Review queue: The
/reminders/todayreview queue still takes onlyq, as it does not takesidetoday. Today's reminders on the clock do narrow by Closing. - API and MCP: I did not add
closingto/api/dealsor the MCP tools, since the issue asks for the page. - Design: The select reuses the existing
.inputand.findclasses, so no new class went intodocs/design/areas/. - Contract and migrations: No contract cell changed and there is no migration.
To try it: open /?closing=month, or pick Closing in the Find form and press Find. Combine it with q=harbor or side=listing. /?closing=year is refused.
The preview deploy failed on one test: "every module directly in src/ is named in docs/TECHNICAL.md or AGENTS.md". The new src/closing-window.ts wasn't listed in either file.
I added its row to the module table in docs/TECHNICAL.md and pushed (commit 282599a). I reran only src/readme.test.ts, which passes. I did not rerun the full suite, and no code changed, so the forge's check on this push is the full verdict.
The rest of the pull is unchanged: a Closing choice (Any, This week, This month, Later) beside Side narrows the clock, This week and the print sheet. An unknown value is refused with 422.
I found no cause in this pull for the three speed failures, so I pushed an empty commit (8a8ca24) to make the forge re-run the check. I haven't seen that run's result.
- The failures: the reminder review (2.0 s) and people (1.9 s) were slow in the deploy, and the clock was slow the first time after a deal changed (585 ms). This pull doesn't change the reminder review or people. For the clock, the new
closingInis a plain filter, and it returns early when no Closing choice is set. - Locally:
src/speed.test.tspassed all 27 tests, four runs in a row. - Likely cause: the deploy's full run took 71 s against 63 s the run before, which looks like a loaded machine.
If the speed tests fail again on the same routes, that points to the machine rather than this change.
main has moved on by one commit (7473f8f, #301). I did not merge it into this branch.
The code is sound and the buckets, month-end maths and 422 refusal look right. No contract cell changed, no new dependency, output is escaped. Two gaps against box 4 remain, plus one small fix.
Fix first: add a speed test for /?closing=month (and /week?closing=week) in src/speed.test.ts. Box 4 requires the page to answer inside the speed budget, and today no speed test requests a closing value. Only the unfiltered clock is covered, so the new path is not measured.
Also:
- Box 4 asks for each bucket on the sample deals dated from today. The tests use synthetic
{closing}objects and two hand-made deals. Add a test that runs the buckets over the seeded sample deals, so the real data shape is exercised.find(deals as never, ...)in 'composes with find' is a cast that hides a type mismatch; build proper deal values instead. - The README line breaks the wrapping: the 'Orchard Row' line is now longer than the rest. Re-wrap the paragraph.
- Nit: the empty message says 'that closing' even when Side is also set. Name what actually narrowed, or say 'those filters'.
The Closing choice is not carried on the /reminders/today review link. Side is not carried there either, so I leave it, but say so in the README or the pull.
Pushed as 13d8f19. It covers the speed tests, the sample-deal and real-deal tests, the empty message and the README re-wrap; the only exception is the README review-link caveat, which I put here instead of in the README. The new closing tests and src/speed.test.ts pass. src/readme.test.ts passed on its own run before my last two test edits and wasn't re-run afterwards. bun x tsc --noEmit still doesn't type-check in this clone (it printed help text), so there is no type check to report.
- Speed:
src/speed.test.tsnow times/?closing=monthand/week?closing=week. Each is timed on the 200-deal book, cold and warm, and on the sample book. All come in under 50 ms. - Real deal values: I removed the
as nevercast and the hand-made objects from the find test.
- The seeded sample deals, dated from today, are split into This week, the rest of this month and Later. Together those cover every open deal exactly once, This week sits inside This month, and each deal's closing date matches its bucket.
- A separate test composes find with the closing window on real deals read back from the database.
- The synthetic {closing} boundary tests stay, since they pin the exact days.
- Empty message: it now names what narrowed the clock: "that side", "that closing", "those filters", or the typed query. A test covers each.
- README: the Finding a deal paragraph is re-wrapped to the file's width.
- Review link: I did not carry
closingon the/reminders/todaylink. It takes onlyq, as it does forside. Today's reminders on the clock do narrow by Closing.
I merged main into the branch and pushed it as 1afff01. The merge conflicted in one place, the clock's empty-state message in src/pages/clock.ts, and no other file did.
- Conflict:
mainrewrote the "No deals yet" text, and this branch had changed the "No deal matches…" line to name the Closing and Side filters. I kept both: the filtered message is the branch's, and the "No deals yet" text ismain's new wording. - Tests: I ran the closing-window, side, find, speed, readme and design test files after the merge, and all 60 tests pass. I did not run the full suite.
The preview's two failures (people under 50 ms and people after an edit) look like machine load, not a regression. This pull doesn't touch /people, and I couldn't confirm the fix. I reran src/speed.test.ts three times here: the first run failed 12 tests, the second failed 1 (people under 50 ms), and the third passed all 33. The failures landed on whichever routes were measured while the machine was busy. I did not run the whole suite, only that file.
- What I changed: the two narrowed-clock speed routes (
/?closing=monthand/week?closing=week) now sit at the end of the list insrc/speed.test.ts. They no longer shift the order the existing routes are measured in. Budgets and assertions are unchanged. - Not run:
bun x tsc --noEmitfetched the wrong package, because TypeScript isn't installed in this clone, so I skipped the type check. The change is test-only. - Try it:
bun test src/speed.test.ts. Ifpeoplefails again on the forge's check, the cause is load on the test machine, not this pull's code.
🤖 Generated with Claude Code
Parked by the crew: the check stayed red through 2 automatic tries
The clock form now has a Closing choice (Any, This week, This month, Later) beside Side. The clock, its This week card and the print sheet narrow by it. I did not run
bun x tsc --noEmit: it printed tsc's help text instead of checking, so there was no type check. The Closing tests, the side, find, speed, design and a11y tests pass, andscripts/lint-design.tsprinted nothing.src/closing-window.tshasclosingFilter(validates the GET value) andclosingIn(deals, today, window), a pure function that takes today's date in the agent's timezone.src/pages/closing-window.tsrenders the select inside the Find form./and/weekreadclosing. An unknown value is refused with 422 and "Closing is any, week, month or later.", the same status Side gets.src/pages/clock.tsandsrc/pages/week.ts, Clear and the empty-result message cover Closing too. "Print this week" and the print sheet's back link carryclosingas they doside. The clock's cache key includes it.src/closing-window.test.tscovers each bucket, the boundary days, a week that crosses a month end, composing withq, an invalid value, and the clock and/weekover HTTP. The clock stays inside the existing speed tests.Not done:
/reminders/todayreview queue still takes onlyq, as it does not takesidetoday. Today's reminders on the clock do narrow by Closing.closingto/api/dealsor the MCP tools, since the issue asks for the page..inputand.findclasses, so no new class went intodocs/design/areas/.To try it: open
/?closing=month, or pick Closing in the Find form and press Find. Combine it withq=harbororside=listing./?closing=yearis refused.Closes #309