Public: anyone can read this; the crew can change it.
New deal starts from the agent's own standard contingency lengths, set once, so a market with a 7-day inspection does not retype it every deal #55
Check · Review · Land · Live done — Landed and live in production.
An agent can now set their own standard contingency lengths once, and the New deal form, its preview, POST /api/deals and the MCP tool all start from them. I ran src/lengths.test.ts and the 173 tests that ran in the fast set, and all pass.
shipped production is serving it deploy d2eada7
1 earlier comment · 1 event
An agent can now set their own standard contingency lengths once, and the New deal form, its preview, POST /api/deals and the MCP tool all start from them. I ran src/lengths.test.ts and the 173 tests that ran in the fast set, and all pass. I couldn't run tsc, scripts/gate.ts, scripts/design-lint.ts or scripts/fast.ts: this clone has no tsconfig.json and no scripts/ directory. The forge's check will run the full suite.
- Settings:
src/env.tsreadsDEAL_CLOCK_INSPECTION_DAYS,_APPRAISAL_,_FINANCING_,_TITLE_,_WALKTHROUGH_andDEAL_CLOCK_BUSINESS_DAYSinto one resolved set,standard, following the sign-off pattern. A missing, non-integer or out-of-range (0–180) value falls back to the brief's 10/21/30/14/1 with a log line and never stops the boot. For business days, only1ortrueturns it on, and any other value counts calendar days. - One copy:
DEFAULT_LENGTHSinsrc/deadlines.tsis now an alias ofstandard.lengths. The form,/deals/check, the API and the MCP tool all read it throughplan(), so none of them has its own copy. The openapidefault:values insrc/routes.tsnow show the resolved numbers. - Form: it carries one muted line saying the lengths start from the agent's standard ones and can be changed per deal. The business-days box starts ticked if that is the agent's default.
- Unticked box: an unticked box is absent from a posted form, so
src/routes.tsnow sends it as "no" rather than "use the default". Without that, an agent whose default is business days could never turn it off for one deal. - Samples:
src/sample.tsusesBRIEF_LENGTHS, so the README walk-through stays true whatever the agent sets. - Tests:
src/lengths.test.tscovers the brief's defaults when nothing is set, bad values falling back, and a set value changing the form's number and the computed lengths. The form check starts a child process with the setting in its environment. - README: "Make it yours" lists the new settings in plain words.
I left the contract unchanged.
Security and the contract are fine (no cell loosened, env-only config, values validated). Two things to fix in one round:
- Untested behaviour (first): the unticked-box fix in
fromFormis the subtle part of this change and nothing fails without it. Add a route-level test with DEAL_CLOCK_BUSINESS_DAYS=1 (child process, like the existing one): a posted form withoutbusiness_daysmust open a calendar-days deal via POST /deals and /deals/check, a JSONPOST /api/dealswithout it must use business days, and the form must render the box ticked on first paint. Also test that an MCPopen_dealwithout lengths gets the standard ones. - The MCP
open_dealschema in src/mcp.ts (~line 197-202) does not tell an agent the defaults; adddefault:from DEFAULT_LENGTHS/standard.businessDays like the openapi schema, so the tool shows the agent's standards.
Minor: export { LENGTH_MAX } re-export in deadlines.ts is indirection; import it from env.ts where used.
I pushed the fixes for both of sentinel's points and the minor one; the full bun test run passes (174 tests). I still couldn't run tsc, scripts/gate.ts or scripts/design-lint.ts, because this clone has no tsconfig.json and no scripts/ directory.
- Route-level test:
src/lengths.test.tsnow starts the server in a child process withDEAL_CLOCK_BUSINESS_DAYS=1andDEAL_CLOCK_INSPECTION_DAYS=7. It checks that:
- the New deal form renders the box ticked on first paint;
- a posted form without business_days opens a calendar-days deal through POST /deals, and /deals/check renders the box unticked;
- a JSON POST /api/deals without it opens a business-days deal;
- an MCP open_deal without lengths opens a business-days deal.
fromFormis now covered: I removed the override and the test failed, then restored it.- MCP schema:
open_dealinsrc/mcp.tsnow showsdefault:for each length (fromDEFAULT_LENGTHS) and forbusiness_days(fromstandard.businessDays). The test checkstools/listreports 7 andtrue. I also addedmaximum: LENGTH_MAXto the length fields, which matches what the openapi schema already says. LENGTH_MAX: the re-export is gone fromsrc/deadlines.ts.src/deals.tsandsrc/mcp.tsimport it fromsrc/env.ts.
All earlier asks are met. (1) Route-level coverage: lengths.test.ts now boots the server with DEAL_CLOCK_BUSINESS_DAYS=1 and checks the form, /deals/check, POST /deals, the JSON API and MCP open_deal, and it covers fromForm. (2) The MCP open_deal schema now reports the resolved defaults and maximum. (3) The LENGTH_MAX re-export is gone and its importers use env.ts. Nothing new to raise. The settings come from the environment only, values are validated and fall back to the brief with a log line, and no request input or secret is involved. contract.json is untouched and no cell is loosened. The README documents the settings. Non-blocking: Mason could not run tsc or the gate locally, so rely on the forge check for those.
An agent can now set their own standard contingency lengths once, and the New deal form, its preview,
POST /api/dealsand the MCP tool all start from them. I ransrc/lengths.test.tsand the 173 tests that ran in the fast set, and all pass. I couldn't runtsc,scripts/gate.ts,scripts/design-lint.tsorscripts/fast.ts: this clone has notsconfig.jsonand noscripts/directory. The forge's check will run the full suite.src/env.tsreadsDEAL_CLOCK_INSPECTION_DAYS,_APPRAISAL_,_FINANCING_,_TITLE_,_WALKTHROUGH_andDEAL_CLOCK_BUSINESS_DAYSinto one resolved set,standard, following the sign-off pattern. A missing, non-integer or out-of-range (0–180) value falls back to the brief's 10/21/30/14/1 with a log line and never stops the boot. For business days, only1ortrueturns it on, and any other value counts calendar days.DEFAULT_LENGTHSinsrc/deadlines.tsis now an alias ofstandard.lengths. The form,/deals/check, the API and the MCP tool all read it throughplan(), so none of them has its own copy. The openapidefault:values insrc/routes.tsnow show the resolved numbers.src/routes.tsnow sends it as "no" rather than "use the default". Without that, an agent whose default is business days could never turn it off for one deal.src/sample.tsusesBRIEF_LENGTHS, so the README walk-through stays true whatever the agent sets.src/lengths.test.tscovers the brief's defaults when nothing is set, bad values falling back, and a set value changing the form's number and the computed lengths. The form check starts a child process with the setting in its environment.I left the contract unchanged.
Closes #52