Repository navigation
feat(property): add a prospect lifecycle status [TURNWRK-633] - #48
Conversation
str-manager and Hermes need to create a not-yet-signed property to plan and quote it. PropertyLifecycleStatus gains `prospect`, and the type is now derived from a runtime PROPERTY_LIFECYCLE_STATUSES list (the DISPATCH_LEAD_STATUSES pattern) so consumers can validate API input against one canonical set. isPropertyDispatchable already admits only `active`; a test pins prospect as non-dispatchable for every status. PR 1 of 2: the dispatch half follows after the vendor sync. Refs: TURNWRK-633 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
practical-bot
left a comment
There was a problem hiding this comment.
✅ Approve
The shared contract change is narrowly scoped, preserves legacy unset-status behavior, and its changed-surface tests and exact-head CI checks pass.
| Check | Result | Ref |
|---|---|---|
| working tree and reviewed head | ✅ clean; HEAD 4776c99 | git status --porcelain; git rev-parse HEAD |
| changed-file diff | ✅ 2 files, 61 additions and 7 deletions (68 changed lines) | git diff --stat origin/main...HEAD; git diff --numstat origin/main...HEAD |
| property lifecycle tests | ✅ 1 file, 11 tests passed | npm exec vitest run tests/propertyLifecycle.test.ts |
| typecheck | ✅ exit 0 | npm run typecheck |
| build | ✅ exit 0 | npm run build |
| PR CI typecheck + unit | ✅ success; exact head; typecheck, full test run, build, email typecheck, vendored checks all succeeded | GitHub Actions run 47046830926 |
| PR CI firestore rules | ✅ success | GitHub Actions run 47046830926 |
| PR CI secret scan | ✅ success | GitHub Actions run 47046830926 |
| guard mutation: remove prospect status | PR body Proof mutation ledger | |
| guard mutation: invert dispatchability predicate | PR body Proof mutation ledger | |
| guard mutation: admit prospect | PR body Proof mutation ledger | |
| guard mutation: default unset to prospect | PR body Proof mutation ledger | |
| PR state immediately before verdict | ✅ ["open",false] | gh api repos/TurnWrk/shared/pulls/48 --jq '[.state,.merged]' |
Review record
DESIGN: DESIGN: Put the new lifecycle value in TurnWrk/shared's property contract and expose one canonical runtime status list so dispatch consumers cannot drift.
DESIGN: DESIGN: Preserve active and legacy-unset behavior while ensuring prospect is non-dispatchable; do not implement the separate dispatch API and UI work in this shared-contract PR.
DESIGN: DESIGN: Add type-exhaustive and runtime tests for the status list, defaulting, and dispatchability, then run the repository's declared typecheck, build, and CI suite.
ADVERSARIAL: ADVERSARIAL: The strongest case against approval is that widening the shared type could break consumers or accidentally make prospects operational; exact-head CI's vendored checks plus the 11 changed-surface tests, typecheck, build, and the explicit prospect=false assertions rule that out.
REVIEW VERDICT: approve
REVIEWED DIFF: base=main files=2 lines=68
REVIEW RUN: dispatch=rev-sweep-turnwrk-shared-48-4776c99 thread=5c5482e8-c98e-4dc0-b7d9-3a760b4842e8 model=codex/gpt-5.6-luna
NOT READ: none
Legend: ✅ approve or pass · ❌ changes requested or fail · 👤 a person approves too ·
|
🤖 alan+factory's merge:on-approve on TURNWRK-633, checks green, queued for merge ( |
Why
PR 1 of 2: add the
prospectlifecycle status to the shared Property contract.Integrations and agents need to create a property that is not signed yet, so it can be planned and quoted.
PropertyLifecycleStatushas no state for that (src/types/property.ts:31on52f0a92):Consumers also have no canonical runtime list to validate an API's
lifecycleStatusagainst. Dispatch currently derives one from its own label table.What changed
Net source lines vs main: +5 (tests excluded): one status added, and the type is now derived from a runtime list instead of a hand-written union.
PROPERTY_LIFECYCLE_STATUSES: a newas constlist insrc/types/property.ts, withprospectadded.PropertyLifecycleStatusis(typeof PROPERTY_LIFECYCLE_STATUSES)[number], the same pattern asDISPATCH_LEAD_STATUSES, which dispatch already validates against.active, it is never dispatchable.tests/propertyLifecycle.test.ts(new): checks that the list containsprospectand matches the type exactly. It runsisPropertyDispatchableagainst every status using a table keyed by the type, so a new status without a row failstsc. It pinsprospectas non-dispatchable and unset asactive.What deliberately did NOT change
isPropertyDispatchable: it is already=== 'active', so a prospect is non-operational with no logic change. The new test pins that behavior.LIFECYCLE_LABELS/LIFECYCLE_VARIANT) live in dispatch'slib/propertyLifecycle.ts. Itsprospectentries land in PR 2.firebase/firestore.rulesdoes not validatelifecycleStatusvalues. No rules change, so there is no rules test.RecordbyPropertyLifecycleStatus. Cortex compares against its own string set. Their syncs need nothing extra.Safety invariants touched
PropertyLifecycleStatuswidens by one member, and every existing value keeps compiling. The one consumer that breaks on sync is dispatch's twoRecord<PropertyLifecycleStatus, …>tables (see Next).as constarray and no Firebase import.Proof
Failing run on old code (the test file applied to
52f0a92, before the source change):After the change:
Tests 11 passed (11), andtscis clean with the test file included.Mutations, each run against
tests/propertyLifecycle.test.tsand then restored:prospectinPROPERTY_LIFECYCLE_STATUSES'prospect'lineisPropertyDispatchableadmits only active=== 'active'→!== 'churned'['active','prospect']?? 'active'→?? 'prospect'Verification
npm run typecheck: exit 0npm run test:run: 79 files, 831/831 passednpm run build: exit 0cd email && npm run typecheck: exit 0wt/worktree, so I ran guardrailscommit-msgandpre-pushby hand: both exited 0.git ls-remote origin turnwrk-633-prospect-lifecycle-shared=4776c9997998e83d2788ff67ac31b84fda93f7d4= local HEADNext
Consumer impact. Dispatch's
LIFECYCLE_LABELSandLIFECYCLE_VARIANT(lib/propertyLifecycle.ts:27,35) are typedRecord<PropertyLifecycleStatus, …>. A vendor sync of this PR into dispatch fails its typecheck until those tables gain aprospectkey. The sync and PR 2 should land together.PR 2 of 2 (TurnWrk/dispatch, after this merges and is vendor-synced):
create-and-maponPOST /api/v1/dispatch/property-mappingsacceptssupply.amenities,maintenance.assets,externalListingUrlandlifecycleStatus.runFeedSync) skip prospects, each with a test.prospectlabel and variant.Refs: TURNWRK-633
🤖 Generated with Claude Code