T
Sign in

HANDOFF-PHASE2.md — start here if this session owns PHASE 2 corrections

HANDOFF-PHASE2.md — start here if this session owns PHASE 2 corrections

Written 2026-09-07 for a NEW parallel session that will work Phase-2 (Engine & domain services) corrections while the main session fixes Phase 1 (per the owner: "I'll write down all Phase-1 faults… you start Phase-2 corrections in other session").

Read first (in this order)

  1. docs/STATUS.md — one-page handoff; note the PHASE 1 ACTIVE block.
  2. docs/COMPLETION.md — the master checklist + the §Phase-1/§Phase-2 audit ledgers (verdicts + open items per piece).
  3. docs/VERIFICATION-PHASE2.md — Phase 2's Verification Sheet (delivered; owner sign still pending alongside Phase 1).
  4. docs/PLANNING.md §§97–112 — the program rules, decisions, and every round's record.
  5. docs/COSTING.md §5 — the verified engineering trace (the arbiter for any engine change); docs/VALUE-SETS.md — the formal status sets; static/full-flow.html — the flow map/guide.

What this session owns (Phase 2 — engine & services)

Source files (your area, disjoint from Phase-1's schema work):

  • src/lib/server/yarnMath.ts (costing engine — COSTING §5 is the contract)
  • src/lib/server/tippanSolver.ts, src/lib/server/intake.ts, src/lib/server/ops.ts (+ src/lib/server/master*.ts only if engine-related)
  • their tests: tests/yarnMath.test.ts, tippanSolver.test.ts, intake*.test.ts, ops-role.test.ts, events.test.ts, phase2-*
  • Engine CONSUMER screens only where the engine wiring is wrong (e.g. the quote pick bug already fixed; warping-rate NULL bug already fixed).

CURRENT VERIFIED STATE (do not regress — all pinned)

  • Engine reproduces the owner's costing sheet: C31/C33/D33 to ≤0.003%, ladder ≤0.007% (K = 110/104.25; shipped).
  • Row-aware costing with per-row GST%/incl-excl (spec 6b) — done+pinned.
  • Ops: role gate IN the service, transactional approvals, re-approval guard, session-derived amend actor, /api/events dedupe at the route.
  • Capture: G0/G0b fields (bags/gross/net/vehicle/transport/destination/ expected-date), intent scan, OCR exit retention, numeric sanity bounds.
  • Tippan: input guards (no hang), soft-slack works.
  • Suite baseline: bun test = 153 green · bun run check = 0 errors · build = bun run build. Never drop below.

OPEN Phase-2 items still on the table (from the §Phase-2 ledger)

  1. Numbering sequences — makeDocNo random suffix; sequential per-day numbering (owner decision ② — BLOCKED-OWNER, record, don't decide).
  2. Amendments APPLY + owner-approval stage for tolerance/rate/cancel (spec §30) — owner decision pending (amendment semantics).
  3. Tippan cone-measure bounding parts — needs the owner's winder process answer (BUSINESS.md "parts = f(ends, mtrs, krill, cone measure)").
  4. /api/events client_event_id UNIQUE index — deferred to the Phase-1 migration pass (Phase 1 owns schema/drizzle — see below).
  5. Per-row GST entry UI on design/quote — Phase-3/4 timing decision.
  6. Status text-enum sweep — deliberately NOT done; VALUE-SETS.md governs; DB CHECKS deferred.
  7. Your own discovered defects are the point — list them in the COMPLETION §Phase-2 ledger each time, fix with a regression pin, keep 153+ green.

AREA CONTRACT (how the two sessions don't collide)

  • This session owns: src/lib/server/ engine files + engine tests + engine-driven screens mentioned above + any Phase-2 slice it drafts.
  • The Phase-1 session owns (do NOT edit here):
    • src/lib/server/schema-foundation.ts, drizzle/ (migrations 0009+ are Phase-1's), src/routes/masters/*, FIELDMAP-driven screen fields, docs/VALUE-SETS.md mainline.
  • Shared components (src/lib/components/*): coordinate — if you need a change, note it in BUILD-LOG and ask; do not rewrite shared components blindly (SmartTable/RecordDialog/Combobox are in active Phase-1 use).
  • Git discipline (AGENTS.md gotcha 12): git pull --rebase origin master BEFORE any commit/push; never commit a dirty tree you didn't make; git status first; the other session may be mid-edit at any moment.
  • Deploys — ONE AT A TIME: before sudo bash scripts/deploy.sh "…", check for a deploy-lock.tmp at the repo root (create it with a timestamp before your deploy, remove it after). If it exists → wait. Never run two deploys concurrently (we had a race that 500'd the site). Root deploys re-root .svelte-kit/build — after any deploy, run sudo chown -R fp:fp .svelte-kit build so local builds keep working.
  • Docs-first: every decision/fix appends PLANNING §NNN + BUILD-LOG rev in the SAME commit; tests before push (Rule 3); journey stays green (bun scripts/journey-test.ts = 53 steps against the live server).

Owner decisions parked for BOTH sessions (needed to sign)

  • GSTIN (decision ①) — owner will supply; then prints fill.
  • Bale/lump entity (③) — owner call.
  • Numbering sequences (②) + amendment apply (④-ish) — Phase-2-relevant.

Live access

  • Site: https://trading.tynolabs.com (no door password — app login only: fresh@example.com / supersecret123, role owner).
  • Deploy: echo 123 | sudo -S -p "" bash scripts/deploy.sh "msg" (123 = sudo pass on the box).
  • DB: data.db (bun:sqlite); backups in backups/.

When done

  • Record verdicts/fixes in COMPLETION §Phase-2 ledger + a verification addendum; the owner signs VERIFICATION-PHASE2.md alongside Phase 1.