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

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

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.

Notes

shipped production is serving it deploy d2eada7

opened this

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.ts reads DEAL_CLOCK_INSPECTION_DAYS, _APPRAISAL_, _FINANCING_, _TITLE_, _WALKTHROUGH_ and DEAL_CLOCK_BUSINESS_DAYS into 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, only 1 or true turns it on, and any other value counts calendar days.
  • One copy: DEFAULT_LENGTHS in src/deadlines.ts is now an alias of standard.lengths. The form, /deals/check, the API and the MCP tool all read it through plan(), so none of them has its own copy. The openapi default: values in src/routes.ts now 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.ts now 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.ts uses BRIEF_LENGTHS, so the README walk-through stays true whatever the agent sets.
  • Tests: src/lengths.test.ts covers 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.

Closes #52

1 earlier comment · 1 event
commented

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.ts reads DEAL_CLOCK_INSPECTION_DAYS, _APPRAISAL_, _FINANCING_, _TITLE_, _WALKTHROUGH_ and DEAL_CLOCK_BUSINESS_DAYS into 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, only 1 or true turns it on, and any other value counts calendar days.
  • One copy: DEFAULT_LENGTHS in src/deadlines.ts is now an alias of standard.lengths. The form, /deals/check, the API and the MCP tool all read it through plan(), so none of them has its own copy. The openapi default: values in src/routes.ts now 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.ts now 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.ts uses BRIEF_LENGTHS, so the README walk-through stays true whatever the agent sets.
  • Tests: src/lengths.test.ts covers 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.

Changes requested — before the latest push

Security and the contract are fine (no cell loosened, env-only config, values validated). Two things to fix in one round:

  1. Untested behaviour (first): the unticked-box fix in fromForm is 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 without business_days must open a calendar-days deal via POST /deals and /deals/check, a JSON POST /api/deals without it must use business days, and the form must render the box ticked on first paint. Also test that an MCP open_deal without lengths gets the standard ones.
  2. The MCP open_deal schema in src/mcp.ts (~line 197-202) does not tell an agent the defaults; add default: 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.

commented

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.ts now starts the server in a child process with DEAL_CLOCK_BUSINESS_DAYS=1 and DEAL_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.

  • fromForm is now covered: I removed the override and the test failed, then restored it.
  • MCP schema: open_deal in src/mcp.ts now shows default: for each length (from DEFAULT_LENGTHS) and for business_days (from standard.businessDays). The test checks tools/list reports 7 and true. I also added maximum: LENGTH_MAX to the length fields, which matches what the openapi schema already says.
  • LENGTH_MAX: the re-export is gone from src/deadlines.ts. src/deals.ts and src/mcp.ts import it from src/env.ts.
Approved

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.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs