Skip to content

feat(checklist): turn checklists carry the property's amenity inspection sections [TURNWRK-805] - #49

Merged
practical-bot merged 1 commit into
mainfrom
turnwrk-805-amenity-turn-sections
Dec 3, 2026
Merged

practical-bot merged 1 commit into
mainfrom
turnwrk-805-amenity-turn-sections

Conversation

@Echobob

@Echobob Echobob commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Why

PR 1 of 3: shared composer adds amenity inspection sections, and Property gains externalListingUrl (PRs 2 and 3 are the dispatch and cortex vendor syncs that adopt it)

This is PR 1 of N (shared): the plan is this shared PR, then one vendor-sync-and-adopt PR each in dispatch and cortex. If adoption needs more PRs, the next PR states the new count.

buildWorkOrderChecklistFromParts composes every new work order's checklist for dispatch (API create, approval, Accept) and for cortex auto-accept. On main 807a26f its property part reads only beds and baths (src/checklist/fromParts.ts:29):

property: { supply?: { beds?: number; baths?: number } } | null | undefined;

So a pool or hot-tub property gets no amenity inspection on a turn, even though planForProperty (src/maintenance/plan.ts:104-109) already yields a per-turn section for each amenity class. TURNWRK-631 planned to hand these sections to this composer, and this PR does that.

Separately, dispatch#279 (TURNWRK-633, still open) writes externalListingUrl on property docs, but no shared type declares it.

What changed

Net source lines vs main: +21 (tests excluded): the composer reuses planForProperty and normalizeAmenities for the sections, so the only new code is the work-order type gate, the opt-out, a guard against junk Firestore data, and one optional field.

  • buildWorkOrderChecklistFromParts now accepts property.supply.amenities (readonly string[], which takes amenity classes or free-text labels). On Turnover and GuestExperience work orders, it appends the per-turn sections planForProperty yields for those amenities. They come after the template's sections and before the stay-specific items. Section ids are amenity.<class>, and item ids are amenity.<class>.<item>.
  • No other work-order type gets them. Repair, PreventativeMaintenance, Cleaning, Resupply and Onboarding compose exactly as before.
  • checklistTemplateId: '' (the dispatcher's "no checklist") opts out of the amenity sections too.
  • Unknown amenities are ignored. Labels go through normalizeAmenities, so unmapped and non-maintenance labels add nothing. Non-string entries in a cast Firestore doc are dropped instead of throwing inside an Accept transaction.
  • Property.externalListingUrl?: string: a type only. Nothing reads it yet.
  • The signature is backward compatible. The property part only gains an optional field. src/intake/accept.ts passes its checklist.property straight through (Omit<WorkOrderChecklistParts, ...>), so cortex auto-accept and dispatch Accept pick this up with no change in shared. Nothing else in shared builds the property part by hand.

What deliberately did NOT change

  • The dispatch and cortex call sites. They change in PRs 2 and 3, after the vendor sync. See Adoption below.
  • No dedupe against template sections with the same amenity.* id. No template carries those ids today, because nothing in dispatch calls planForProperty. If a future plan route writes them into a cmms_pmTemplates doc, the composer would need to skip ids it already has.
  • seedChecklistFromTemplate, composeWorkOrderChecklist and planForProperty are unchanged.
  • The Cloud Functions mirror (dispatch/functions/src/checklistSeed.ts) is not shared code and is not touched here.

Adoption

The refs are on dispatch main 2858113 and cortex main df3510d. Cortex main has since moved to 0d45a80, and the cortex line is unchanged there.

At runtime both apps already pass the whole property doc, so amenities reaches the composer as soon as the sync lands. The cast widenings below are type honesty, not behaviour. The turnover paths are the real adoption work.

Casts that need widening to { supply?: { beds?: number; baths?: number; amenities?: readonly string[] } } (or Pick<Property, 'supply'>):

  • dispatch app/api/v1/dispatch/work-orders/route.ts:369
  • cortex src/services/vendorIngestCore.ts:543

These are already typed Pick<Property, 'supply'> and need no change, because dispatch's Property is shared's (types.ts:18):

  • dispatch lib/appInline/checklistSeedOnApprove.ts:53
  • dispatch lib/intake/triage.ts:114 and :130
  • dispatch lib/intake/createIntakeItem.ts:196

Turnover work orders do not go through this composer today. The card's Done-when ("a turnover work order on a pool property carries the pool inspection section") needs dispatch to route them through it:

  • functions/src/cleanWorkers.ts:161-183 and :290 (the CF maybeCreateTurnoverFromBooking) seeds with seedChecklistFromTemplate directly.
  • lib/appInline/bookingCheckoutCreateTurnover.ts:113-130 (the app-inline replacement, TURNWRK-135) writes a Turnover with no checklist at all.
  • app/api/v1/dispatch/work-orders/route.ts:354-357 composes only when a checklistTemplateId or custom items are sent. An API-created Turnover or GuestExperience with neither still gets no amenity sections.

lib/inngest/functions/cleanJobs.ts:264-299 seeds the Cleaning series, which is out of scope because Cleaning is not a turn type here.

Proof

Old code first. I ran the new tests against main's fromParts.ts, with only the test file changed: npx vitest run tests/checklist/fromParts.test.ts gave 5 failed | 6 passed (11). These failed:

  • adds a section per amenity on a Turnover
  • copies planForProperty's per-turn sections
  • GuestExperience with no template
  • ignores unknown amenities and junk
  • takes a whole Property document

The Repair, '' and no-amenities tests passed on old code, as pins should.

The type-level check fails on old property.ts too. tsc on a scratch config that includes the test file gives:
tests/checklist/fromParts.test.ts(140,7): error TS2353: ... 'externalListingUrl' does not exist in type 'Property'.

Mutations. Each row breaks one line, runs npx vitest run tests/checklist/fromParts.test.ts, then restores the file:

Mutation Result Tests
gate: Repair added to the type set KILLED 1 failed / 10 passed
gate: type check dropped (true &&) KILLED 1 failed / 10 passed
gate: Turnover dropped from the set KILLED 3 failed / 8 passed
gate: '' opt-out dropped KILLED 1 failed / 10 passed
empty: Array.isArray guard deleted KILLED 3 failed / 8 passed
empty: no amenities falls back to a default KILLED 1 failed / 10 passed
empty: junk filter dropped KILLED 1 failed / 10 passed
mapping: amenity sections before the template KILLED 1 failed / 10 passed
mapping: section ids lose the amenity. prefix KILLED 5 failed / 6 passed
mapping: first item of each section dropped KILLED 1 failed / 10 passed
mapping: labels not normalized (classes only) KILLED 1 failed / 10 passed

All 11 mutations were killed.

The work-order type gate adds sections and withholds nothing that used to pass, so it is not a new gate in the blocking sense. A property with no amenities composes byte-for-byte as before, and a test pins that.

Verification

All of these ran on head 182e64c, after the last edit:

  • npm run typecheck: exit 0
  • tsc -p <scratch>/tsconfig.tests.json: exit 0. This is the repo's tsconfig plus tests/checklist/fromParts.test.ts, because the repo's tsconfig covers only src/**.
  • npm run test:run: 79/79 files, 839/839 tests passed
  • npm run build: exit 0
  • cd email && npm run typecheck: exit 0
  • npm run check:vendored: exit 0, but it skips all three checks because a wt/ worktree has no sibling apps. The vendored copies will differ from this branch until PRs 2 and 3 sync them.

Hooks: git runs none in a wt/ worktree, so I ran them by hand. The guardrails commit-msg passed. pre-push is a no-op here, because this repo has no .guardrails/pre-push.

The pushed branch matches the local head: git ls-remote origin turnwrk-805-amenity-turn-sections gives 182e64c, the same as git rev-parse HEAD.

Refs: TURNWRK-805

🤖 Generated with Claude Code

…ion sections [TURNWRK-805]

buildWorkOrderChecklistFromParts read only beds and baths from the
property, so a pool or hot-tub property got no amenity inspection on a
turn. Turnover and GuestExperience work orders now get the per-turn
sections planForProperty yields for the property's amenities, after the
template and before stay-specific items. Repair and the other types get
none; '' (no checklist) opts out; no amenities composes as before.

Property also gains externalListingUrl, which dispatch already writes.

Refs: TURNWRK-805

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 composer reuses planForProperty for amenity sections, keeping checklist content aligned with the existing maintenance plan instead of creating a second amenity definition.

Check Result Ref
changed-surface tests ✅ 11/11 tests passed npx vitest run tests/checklist/fromParts.test.ts
typecheck + unit CI ✅ GitHub Actions SUCCESS; typecheck, test:run, build, vendored checks 47052721138/job/144068394012
firestore rules behavior tests ✅ GitHub Actions SUCCESS 47052721138/job/144068596055
secret scan ✅ GitHub Actions SUCCESS 47052721138/job/144068394269
PR body mutation ledger ⚪ The 11 mutation commands in the PR body were not independently replayed; the changed-surface tests and exact-head CI passed. PR body Mutations section
diff whitespace ✅ no whitespace errors git diff --check origin/main...HEAD
Review record

DESIGN: DESIGN: Put amenity-section composition in shared buildWorkOrderChecklistFromParts, reusing planForProperty and the property's supply data so dispatch and cortex share one implementation.
DESIGN: DESIGN: Preserve existing template, custom-item, no-checklist, and non-turn work-order behavior; unknown or malformed amenity data must be ignored without throwing.
DESIGN: DESIGN: Add focused tests covering pool plus hot-tub, GuestExperience and Turnover ordering, Repair exclusion, explicit no-checklist, no amenities, unknown/junk values, and Property typing.
ADVERSARIAL: The strongest case against approval is that the new amenity path could change legacy checklist composition or throw on cast Firestore junk; npx vitest run tests/checklist/fromParts.test.ts passed all 11 focused cases, including byte-equivalence for no amenities, Repair exclusion, explicit '' opt-out, and junk filtering, while exact-head CI passed typecheck, unit tests, build, and vendored checks.
REVIEW VERDICT: approve
REVIEWED DIFF: base=main files=3 lines=126
REVIEW RUN: dispatch=rev-sweep-turnwrk-shared-49-182e64c thread=c36a4324-0df1-41e6-9553-5efd04193a80 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-805, checks green, queued for merge (merge:queued).

@practical-bot
practical-bot merged commit b6ec869 into main Dec 3, 2026
3 checks passed
@practical-bot
practical-bot deleted the turnwrk-805-amenity-turn-sections branch December 3, 2026 06:52
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