Skip to content

feat(property): add a prospect lifecycle status [TURNWRK-633] - #48

Merged
practical-bot merged 1 commit into
mainfrom
turnwrk-633-prospect-lifecycle-shared
Dec 3, 2026
Merged

practical-bot merged 1 commit into
mainfrom
turnwrk-633-prospect-lifecycle-shared

Conversation

@Echobob

@Echobob Echobob commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Why

PR 1 of 2: add the prospect lifecycle 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. PropertyLifecycleStatus has no state for that (src/types/property.ts:31 on 52f0a92):

export type PropertyLifecycleStatus =
  | 'active' | 'onboarding' | 'churned' | 'out_of_scope' | 'access_blocked';

Consumers also have no canonical runtime list to validate an API's lifecycleStatus against. 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 new as const list in src/types/property.ts, with prospect added. PropertyLifecycleStatus is (typeof PROPERTY_LIFECYCLE_STATUSES)[number], the same pattern as DISPATCH_LEAD_STATUSES, which dispatch already validates against.
  • Doc comment: a prospect can be planned and quoted. Like every status except active, it is never dispatchable.
  • tests/propertyLifecycle.test.ts (new): checks that the list contains prospect and matches the type exactly. It runs isPropertyDispatchable against every status using a table keyed by the type, so a new status without a row fails tsc. It pins prospect as non-dispatchable and unset as active.

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.
  • No label table in shared. The labels (LIFECYCLE_LABELS / LIFECYCLE_VARIANT) live in dispatch's lib/propertyLifecycle.ts. Its prospect entries land in PR 2.
  • Firestore rules: firebase/firestore.rules does not validate lifecycleStatus values. No rules change, so there is no rules test.
  • restock, clean, turnwrk-cortex: none of them key a Record by PropertyLifecycleStatus. Cortex compares against its own string set. Their syncs need nothing extra.

Safety invariants touched

  • Type contract: PropertyLifecycleStatus widens by one member, and every existing value keeps compiling. The one consumer that breaks on sync is dispatch's two Record<PropertyLifecycleStatus, …> tables (see Next).
  • Framework-free: this adds a plain as const array and no Firebase import.

Proof

Failing run on old code (the test file applied to 52f0a92, before the source change):

vitest run tests/propertyLifecycle.test.ts
 FAIL  tests/propertyLifecycle.test.ts
TypeError: Cannot read properties of undefined (reading 'map')

tsc --noEmit (test file included)
error TS2724: '"../src/types/property"' has no exported member named 'PROPERTY_LIFECYCLE_STATUSES'.
error TS2353: Object literal may only specify known properties, and 'prospect' does not exist in type 'Record<PropertyLifecycleStatus, boolean>'.
error TS2322: Type '"prospect"' is not assignable to type 'PropertyLifecycleStatus | undefined'.

After the change: Tests 11 passed (11), and tsc is clean with the test file included.

Mutations, each run against tests/propertyLifecycle.test.ts and then restored:

Guard Mutation Result
prospect in PROPERTY_LIFECYCLE_STATUSES delete the 'prospect' line killed, 2 failed
isPropertyDispatchable admits only active === 'active' → !== 'churned' killed, 5 failed
prospect is not dispatchable admit ['active','prospect'] killed, 2 failed
unset reads as active ?? 'active' → ?? 'prospect' killed, 1 failed

Verification

  • npm run typecheck: exit 0
  • npm run test:run: 79 files, 831/831 passed
  • npm run build: exit 0
  • cd email && npm run typecheck: exit 0
  • Hooks do not run in a wt/ worktree, so I ran guardrails commit-msg and pre-push by hand: both exited 0.
  • git ls-remote origin turnwrk-633-prospect-lifecycle-shared = 4776c9997998e83d2788ff67ac31b84fda93f7d4 = local HEAD

Next

Consumer impact. Dispatch's LIFECYCLE_LABELS and LIFECYCLE_VARIANT (lib/propertyLifecycle.ts:27,35) are typed Record<PropertyLifecycleStatus, …>. A vendor sync of this PR into dispatch fails its typecheck until those tables gain a prospect key. The sync and PR 2 should land together.

PR 2 of 2 (TurnWrk/dispatch, after this merges and is vendor-synced):

  • create-and-map on POST /api/v1/dispatch/property-mappings accepts supply.amenities, maintenance.assets, externalListingUrl and lifecycleStatus.
  • The route materializer and the occupancy feed sync (runFeedSync) skip prospects, each with a test.
  • A pinned test for the PM generator's existing non-active skip.
  • A Prospects filter on the property list, plus the prospect label and variant.

Refs: TURNWRK-633

🤖 Generated with Claude Code

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 practical-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 ⚠️ not re-run because the claimed mutation requires editing the reviewed source; the restored guard passes on this head PR body Proof mutation ledger
guard mutation: invert dispatchability predicate ⚠️ not re-run because the claimed mutation requires editing the reviewed source; the restored guard passes on this head PR body Proof mutation ledger
guard mutation: admit prospect ⚠️ not re-run because the claimed mutation requires editing the reviewed source; the restored guard passes on this head PR body Proof mutation ledger
guard mutation: default unset to prospect ⚠️ not re-run because the claimed mutation requires editing the reviewed source; the restored guard passes on this head 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 · ⚠️ could not run here · ⚪ not re-run

@practical-bot practical-bot added the merge:queued Hand this PR to the factory merge queue label Dec 3, 2026
@practical-bot

Copy link
Copy Markdown

🤖 alan+factory's merge:on-approve on TURNWRK-633, checks green, queued for merge (merge:queued).

@practical-bot
practical-bot merged commit 807a26f into main Dec 3, 2026
3 checks passed
@practical-bot
practical-bot deleted the turnwrk-633-prospect-lifecycle-shared branch December 3, 2026 06:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge:queued Hand this PR to the factory merge queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants