Repository navigation
feat(checklist): turn checklists carry the property's amenity inspection sections [TURNWRK-805] - #49
Conversation
…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
left a comment
There was a problem hiding this comment.
✅ 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 ·
|
🤖 alan+factory's merge:on-approve on TURNWRK-805, checks green, queued for merge ( |
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.
buildWorkOrderChecklistFromPartscomposes 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):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
externalListingUrlon property docs, but no shared type declares it.What changed
Net source lines vs main: +21 (tests excluded): the composer reuses
planForPropertyandnormalizeAmenitiesfor 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.buildWorkOrderChecklistFromPartsnow acceptsproperty.supply.amenities(readonly string[], which takes amenity classes or free-text labels). On Turnover and GuestExperience work orders, it appends the per-turn sectionsplanForPropertyyields for those amenities. They come after the template's sections and before the stay-specific items. Section ids areamenity.<class>, and item ids areamenity.<class>.<item>.checklistTemplateId: ''(the dispatcher's "no checklist") opts out of the amenity sections too.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.src/intake/accept.tspasses itschecklist.propertystraight 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
amenity.*id. No template carries those ids today, because nothing in dispatch callsplanForProperty. If a future plan route writes them into a cmms_pmTemplates doc, the composer would need to skip ids it already has.seedChecklistFromTemplate,composeWorkOrderChecklistandplanForPropertyare unchanged.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
amenitiesreaches 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[] } }(orPick<Property, 'supply'>):app/api/v1/dispatch/work-orders/route.ts:369src/services/vendorIngestCore.ts:543These are already typed
Pick<Property, 'supply'>and need no change, because dispatch'sPropertyis shared's (types.ts:18):lib/appInline/checklistSeedOnApprove.ts:53lib/intake/triage.ts:114and:130lib/intake/createIntakeItem.ts:196Turnover 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-183and:290(the CFmaybeCreateTurnoverFromBooking) seeds withseedChecklistFromTemplatedirectly.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-357composes only when achecklistTemplateIdor custom items are sent. An API-created Turnover or GuestExperience with neither still gets no amenity sections.lib/inngest/functions/cleanJobs.ts:264-299seeds 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.tsgave 5 failed | 6 passed (11). These failed:The Repair,
''and no-amenities tests passed on old code, as pins should.The type-level check fails on old
property.tstoo.tscon 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:true &&)''opt-out droppedArray.isArrayguard deletedamenity.prefixAll 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 0tsc -p <scratch>/tsconfig.tests.json: exit 0. This is the repo's tsconfig plustests/checklist/fromParts.test.ts, because the repo's tsconfig covers onlysrc/**.npm run test:run: 79/79 files, 839/839 tests passednpm run build: exit 0cd email && npm run typecheck: exit 0npm run check:vendored: exit 0, but it skips all three checks because awt/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 guardrailscommit-msgpassed.pre-pushis 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-sectionsgives 182e64c, the same asgit rev-parse HEAD.Refs: TURNWRK-805
🤖 Generated with Claude Code