docs(voice): one flat spec file, no progress note
Amin's call: specs live at docs/specs/<slug>.md, and the repo does not carry a progress ledger. The ledger was an /orchestrate requirement, not something the codebase needs to keep. The link to voice-treatment-entry is repointed — that spec still sits in its own folder on master. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,258 +0,0 @@
|
||||
---
|
||||
type: task-progress
|
||||
status: active
|
||||
repos:
|
||||
- repo: dyolink
|
||||
path: ~/PersonalProjects/dyolink
|
||||
branch: feat/cases/add-voice-input-for-lab-case-line
|
||||
base: origin/master
|
||||
role: lab-mode extraction catalog + lab line apply + shared review sheet
|
||||
spec_slug: voice-lab-case-entry
|
||||
merge_after: []
|
||||
---
|
||||
|
||||
# Voice entry for a lab case line — progress
|
||||
|
||||
Ledger for [`spec.md`](spec.md). Every `/orchestrate` stop path appends here.
|
||||
|
||||
## Ledger
|
||||
|
||||
| # | Item | State |
|
||||
|---|---|---|
|
||||
| 1 | `narrowCatalogForOrgType` + spec | done |
|
||||
| 2 | `ClinicOrgGuard` off the controller; `extract` branches on org type | done |
|
||||
| 3 | `assertCanEditTreatment` generalised to take a permission code | done |
|
||||
| 4 | `voiceRowAvailability(result, codes, mode)` | done |
|
||||
| 5 | `mode` prop on `VoiceReviewSheet` | done |
|
||||
| 6 | `buildLabLineFromVoice` + spec | done |
|
||||
| 7 | Mic beside Add Line in `CaseCreatePanel` | done |
|
||||
| 8 | Manual pass, `fa`, both org types (§10) | not started |
|
||||
|
||||
## 2026-09-16 — spec written, branch cut
|
||||
|
||||
`/grill-me` settled 14 decisions across 10 questions. Spec committed as `93c592f` on
|
||||
`feat/cases/add-voice-input-for-lab-case-line`, branched from `master` at `554a31f` — which
|
||||
already carries the merged `voice-treatment-entry` work this depends on.
|
||||
|
||||
Four findings from reading the code shaped the design, each cited in the spec:
|
||||
|
||||
| Finding | Where |
|
||||
|---|---|
|
||||
| `ClinicOrgGuard` on the whole controller, so a LAB org gets 403 on both voice routes | `voice.controller.ts:22` |
|
||||
| `listLinkedLabs` does not filter by org type — a LAB org is handed its linked **clinics** under the heading "LABS THIS CLINIC CAN SEND TO" | `voice.service.ts:272` |
|
||||
| The lab write validates only the prosthesis code, so a teeth/jobs mismatch is written silently rather than rejected | `cases.service.ts:481` |
|
||||
| `TAB_TREATMENT_EDIT` is clinic-only, so reusing it would 403 every lab member including the owner | `organization-type.ts:14` |
|
||||
|
||||
No code yet.
|
||||
|
||||
## 2026-09-16 — `/orchestrate --dry` preflight
|
||||
|
||||
Two blockers found before any agent was spawned.
|
||||
|
||||
1. **No merge request template.** `.gitlab/merge_request_templates/*.md` does not exist, and
|
||||
neither does `.github/`. The repo is on **Gitea** (`origin` is
|
||||
`http://178.131.50.201:3000/admin/dyolink.git`), and `/orchestrate` ends in GitLab-shaped
|
||||
merge requests. This is the same blocker that ended the 2026-09-06 run at 1 h 31 m and
|
||||
116 M tokens, that time discovered at Ship rather than at preflight.
|
||||
2. **No progress note.** Created by this entry.
|
||||
|
||||
Blocker 1 is not fixable inside this repo — the Ship phase targets the wrong forge, so a
|
||||
template alone would not be enough. Amin chose to run everything except Ship: `dry: true`
|
||||
commits locally and never pushes, so the run never reaches the phase that needs a template.
|
||||
Teaching the clerk and courier about Gitea is its own task, upstream in `~/.claude`.
|
||||
|
||||
## 2026-09-16 — implementation, repo `dyolink`
|
||||
|
||||
All seven code items landed on `feat/cases/add-voice-input-for-lab-case-line`. Not committed.
|
||||
|
||||
### Backend
|
||||
|
||||
| File | Change |
|
||||
|---|---|
|
||||
| `backend/src/modules/voice/narrowCatalogForOrgType.ts` | **new** — `LAB` empties `treatmentTypes` and `labs`, `CLINIC` passes through |
|
||||
| `backend/src/modules/voice/narrowCatalogForOrgType.spec.ts` | **new** — the three §10 cases plus a no-mutation case |
|
||||
| `backend/src/modules/voice/voice.controller.ts` | `ClinicOrgGuard` removed; `JwtAuthGuard` stays |
|
||||
| `backend/src/modules/voice/voice.service.ts` | `assertCanEditTreatment` → `assertCanDictate`, which resolves the org type, asserts `TAB_TREATMENT_EDIT` (CLINIC) or `TAB_CASES_EDIT` (LAB), and returns the type so `extract` narrows the catalog with it |
|
||||
| `backend/src/modules/voice/voice.service.spec.ts` | **new** — the four matrix cells through `extract`, with the OpenRouter providers mocked so the catalog handed to the model is asserted |
|
||||
|
||||
The LAB denial code is `PERMISSION_ACCESS_CASES`, matching `cases.service.ts:1391`. The spec did
|
||||
not name one and no `PERMISSION_EDIT_CASES` exists; reusing the existing code keeps decision 14
|
||||
(no new i18n keys) intact.
|
||||
|
||||
### Frontend
|
||||
|
||||
| File | Change |
|
||||
|---|---|
|
||||
| `frontend/src/types/voice.ts` | **new** `VoiceEntryMode = 'clinic' \| 'lab'` |
|
||||
| `frontend/src/components/treatment/voiceReviewRows.ts` | `voiceRowAvailability` / `initialVoiceSelection` / `hasAnythingToApply` take `mode`, defaulting to `'clinic'`; lab mode forces `labDependent` true and hides the type and lab rows |
|
||||
| `frontend/src/components/ui/treatment/VoiceReviewSheet.tsx` | `mode` prop; `treatmentCatalog`, `labs` and `labDependentCodes` are now optional, since lab mode renders none of the rows that need them |
|
||||
| `frontend/src/components/lab/caseLineDraft.ts` | **new** — `LineDraft`, `newLine` and `isBlankLine`, moved out of `CaseCreatePanel` so the pure apply helper can use them without importing from `ui/` |
|
||||
| `frontend/src/components/lab/voiceLine.ts` | **new** `buildLabLineFromVoice`, through the shared `prosthesisTargetLines` and `groupsFromFlatTeeth` |
|
||||
| `frontend/src/components/lab/voiceLine.spec.ts` | **new** — the six §10 rules plus the `isBlankLine` bounds |
|
||||
| `frontend/src/components/treatment/voiceReviewRows.spec.ts` | lab-mode rows added |
|
||||
| `frontend/src/components/ui/lab/CaseCreatePanel.tsx` | `useVoiceCapture` + `VoiceRecordingBar` + `VoiceReviewSheet mode="lab"`; `AddLineWithVoice` split button beside Add Line, sharing its `disabled` |
|
||||
|
||||
### Verification
|
||||
|
||||
| Command | Result |
|
||||
|---|---|
|
||||
| `cd backend && npm test` | 230 passed, 18 suites |
|
||||
| `cd backend && npm run build` | clean |
|
||||
| `cd frontend && npx vitest run` | 98 passed, 5 files |
|
||||
| `cd frontend && npx tsc --noEmit` | clean |
|
||||
| `cd frontend && npm run build` | clean |
|
||||
| `cd frontend && npm run lint` | 0 errors and 0 warnings on every touched file |
|
||||
|
||||
Matrix cells recorded through `gate-run` (`.git/orchestrate/ledger.jsonl`), each running exactly
|
||||
one test: C01 CLINIC granted, C02 CLINIC denied, C03 LAB granted, C04 LAB denied.
|
||||
|
||||
Every new rule was also shown to fail when reverted: the decision-40 filter, the
|
||||
`splitDisconnectedRuns` seeding, the forced `labDependent`, the hidden type/lab rows, the
|
||||
catalog narrowing, and the per-org-type permission branch.
|
||||
|
||||
### Left for the manual pass
|
||||
|
||||
- §10 items 1–12, `fa`, a LAB org with a linked clinic.
|
||||
- `treatment.voiceStart` reads "Record treatment" beside Add Line. It is reused rather than
|
||||
duplicated, per decision 14. Rename it later if it reads wrong in `fa`.
|
||||
- If the model emits a `labId` or a `treatmentType` despite the emptied lists, the resolver
|
||||
still pushes an `unknown_catalog_code` unresolved item, which the sheet renders. The spec
|
||||
does not say lab mode should drop those, so nothing does. Watch for it at §10 item 8.
|
||||
|
||||
## 2026-09-16 — Verify phase, repo `dyolink` — FAILED, nothing pushed
|
||||
|
||||
An unattended `/orchestrate` run stopped in the **Verify** phase. The verifier FAILED `dyolink`
|
||||
against observed ground truth. No commit was pushed.
|
||||
|
||||
### Failed because
|
||||
|
||||
- AC11 has no executing check: no component test renders VoiceRecordingBar, and vitest.config.ts includes only 'src/**/*.spec.ts' with no jsdom environment.
|
||||
- AC12 has no executing check: nothing observed a clip being posted to POST /voice/extract — no test, no browser run, and the API is not running (curl exit 7).
|
||||
- AC28 has no executing check: the debounced autosave and a reload were never exercised; no frontend integration test and no live system available.
|
||||
- AC32 has no executing check: no test or live query observed task generation from a dictated case line.
|
||||
- AC4 is PASS but guarded:false — only the diff removing ClinicOrgGuard stands behind it; re-adding the guard would break no test.
|
||||
- AC9 is PASS but guarded:false — getAvailability takes no org argument, but no test or request ever calls the route as a LAB org.
|
||||
- AC10 is PASS but guarded:false — the split mic control is only readable in JSX; no render is executed.
|
||||
- AC24 is PASS but guarded:false — the applyVoice-to-setDueDate wiring has no test.
|
||||
- AC25 is PASS but guarded:false — isBlankLine is tested, but the fill-the-blank-line branch inside applyVoice is not.
|
||||
- AC26 is PASS but guarded:false — the append-and-activate branch inside applyVoice is not executed by any test.
|
||||
- AC31 is PASS but guarded:false — the arch-highlight clause depends on ProsthesisAssignChart, which no executed test renders.
|
||||
- AC33 is PASS but guarded:false — VoiceReviewSheet.tsx (a clinic component) changed and no test renders it; only tsc covers the prop change.
|
||||
- Ledger entries 0026 (backend `npx eslint {src,apps,libs,test}/**/*.ts`) and 0028 (frontend `npm run lint`) are verification commands recorded with exit 1.
|
||||
|
||||
### Unguarded criteria
|
||||
|
||||
| ID | Behaviour | Evidence only from |
|
||||
|---|---|---|
|
||||
| AC4 | A LAB org can call both voice routes; the controller no longer rejects a LAB org with 403 through ClinicOrgGuard. | `git diff origin/master...HEAD -- backend/src/modules/voice/voice.controller.ts`; `grep -rn 'ClinicOrgGuard\|LabOrgGuard' backend/src/modules/voice/` |
|
||||
| AC9 | GET /voice/availability returns the same configuration for a LAB org as for a CLINIC org, with no separate lab toggle. | `git diff origin/master...HEAD -- backend/src/modules/voice/voice.service.ts`; `sed -n '55,80p' backend/src/modules/voice/voice.service.ts` |
|
||||
| AC10 | A mic control sits beside Add Line in CaseCreatePanel and is disabled whenever Add Line is disabled. | `git diff origin/master...HEAD -- frontend/src/components/ui/lab/CaseCreatePanel.tsx` |
|
||||
| AC24 | Ticking the due-date row writes the case header's due-date field, the same state AppDateInput writes. | `grep -n 'setDueDate\|dueDate' frontend/src/components/ui/lab/CaseCreatePanel.tsx` |
|
||||
| AC25 | Applying a dictation fills the active line when that line is blank (no teeth, no jobs, no comment, no attachments). | `git diff origin/master...HEAD -- frontend/src/components/ui/lab/CaseCreatePanel.tsx`; `npx vitest run src/components/lab/voiceLine.spec.ts` |
|
||||
| AC26 | Applying a dictation onto a non-blank active line appends a new line and makes it the active line. | `git diff origin/master...HEAD -- frontend/src/components/ui/lab/CaseCreatePanel.tsx` |
|
||||
| AC31 | A dictated arch selects the jaw, invents no tooth, and the chart shows the arch highlight. | `cd frontend && npx vitest run --reporter=verbose src/components/lab/voiceLine.spec.ts src/components/treatment/voiceReviewRows.spec.ts` |
|
||||
| AC33 | The clinic treatment workspace mic behaves exactly as it did before this change. | `cd frontend && npx vitest run` (98 tests) ; `git diff --name-only origin/master...HEAD` |
|
||||
|
||||
### Failing criteria
|
||||
|
||||
**AC11** — While recording on the lab side, VoiceRecordingBar shows the elapsed time and the level meter as on the clinic side.
|
||||
- result: FAIL · evidence_kind: test_stdout · guarded: false · exit_code: 0
|
||||
- command: `cd frontend && npx vitest run`
|
||||
- evidence: Looked for an executed render of VoiceRecordingBar and found none. The suite is 5 files / 98 tests, all pure helpers: toothSelectionGroups, prosthesisTree, voiceReviewRows, voiceLine, voiceApply. vitest.config.ts: include ['src/**/*.spec.ts'], no environment set. The only trace of the criterion is the JSX `{voiceEnabled ? <VoiceRecordingBar voice={voice} /> : null}` in the diff.
|
||||
- log: `/Users/aminmsvi/PersonalProjects/dyolink/.git/orchestrate/logs/0024-test.log`
|
||||
|
||||
**AC12** — Stopping the lab recording posts the clip to POST /voice/extract.
|
||||
- result: FAIL · evidence_kind: test_stdout · guarded: false · exit_code: 0
|
||||
- command: `cd frontend && npx vitest run; grep -n 'voice/extract' frontend/src/lib/api/voice.ts`
|
||||
- evidence: Looked for an executed check of the stop-to-POST path and found none. Static chain only: CaseCreatePanel wires `onClick={isRecording ? voice.onStop : voice.onStart}` to useVoiceCapture, and frontend/src/lib/api/voice.ts:26 does `apiClient.post('/voice/extract', payload, ...)`. No test, no browser run, no server request observed (API not running, curl exit 7).
|
||||
- log: `/Users/aminmsvi/PersonalProjects/dyolink/.git/orchestrate/logs/0024-test.log`
|
||||
|
||||
**AC28** — After confirming the sheet, the debounced autosave persists the case, so reloading it shows the dictated line.
|
||||
- result: FAIL · evidence_kind: test_stdout · guarded: false · exit_code: 7
|
||||
- command: `cd frontend && npx vitest run ; curl --max-time 3 http://localhost:3000/api/voice/availability`
|
||||
- evidence: Looked for an executed persistence check and found none. No frontend component or integration test exists; the backend suite (18 suites, 230 tests) holds no case-autosave-from-voice test; the API is not running (curl exit 7, HTTP code 000), so no live query could confirm a reload. The 500 ms autosave effect is only visible as source at CaseCreatePanel.tsx:247-252.
|
||||
- log: (none)
|
||||
|
||||
**AC32** — Starting a case built by dictation generates tasks whose groups match the lines.
|
||||
- result: FAIL · evidence_kind: test_stdout · guarded: false · exit_code: 0
|
||||
- command: `cd backend && npm test`
|
||||
- evidence: Looked for an executed start-case / task-generation check driven by a dictated line and found none. The backend suite passes 230 tests in 18 suites, but no ledger entry and no suite exercises LabCase start with a voice-built line; the API and database are not running, so no live query could observe the generated task groups.
|
||||
- log: `/Users/aminmsvi/PersonalProjects/dyolink/.git/orchestrate/logs/0022-test.log`
|
||||
|
||||
### Unexecuted cells
|
||||
|
||||
None.
|
||||
|
||||
### Stale evidence
|
||||
|
||||
- ledger 0001-0008 (ts 1789505529-1789505699, cells C01-C04, `npm test -- voice.service.spec -t C0x`) ran BEFORE the last edit of backend/src/modules/voice/voice.service.ts, voice.service.spec.ts and narrowCatalogForOrgType.spec.ts (mtime 1789505987). Superseded by fresh entries 0018-0021 (ts 1789506102-1789506123).
|
||||
- ledger 0012 (ts 1789505763, `npx eslint src/modules/voice/...`, exit 1) is stale and superseded by 0027 (ts 1789506206, exit 0).
|
||||
- ledger 0013 (ts 1789505784, cell C03, `npx vitest run`), 0014 (ts 1789505792, cell C01, `npx tsc --noEmit`), 0017 (ts 1789505820, cell C03, `npm run build`) are stale and mis-tagged: whole-suite frontend commands carrying single cell ids that do not describe them. Superseded by untagged fresh runs 0024, 0025, 0030.
|
||||
|
||||
### git_status
|
||||
|
||||
(empty)
|
||||
|
||||
### Why
|
||||
|
||||
The earlier gates passed on what agents said about their own work. This one passed nothing.
|
||||
|
||||
## 2026-09-16 — the blank-line bug, and the lint gate left red
|
||||
|
||||
### Fixed: a dictation that built no line still appended one
|
||||
|
||||
The `/orchestrate` correctness critic refuted, and the finding held up when checked by hand.
|
||||
|
||||
`applyVoice` tested `isBlankLine` on the **target** line but never on the line it had just
|
||||
**built**. A dictation carrying no line content — a due date alone, or one whose codes were all
|
||||
refused — returned a blank `newLine()`, fell past the blank-target branch and was appended, made
|
||||
active, and autosaved. `start` only requires that *some* line carries jobs
|
||||
(`cases.service.ts:549`), so the empty line shipped to the floor. That is what decision 9 exists
|
||||
to prevent; decision 9 only ever covered *filling* a blank target, not *appending* one.
|
||||
|
||||
The spec's own §10 manual step 7 triggers it: dictate «تا پنجشنبه» with line 1 already filled.
|
||||
|
||||
Fixed in the pure layer rather than guarded in the component: `buildLabLineFromVoice` returns
|
||||
`line: null` when the line is blank, so a test can hold the rule. The due date still lands, since
|
||||
it belongs to the case header. Six tests that asserted an empty line now assert null, one new test
|
||||
covers a due date riding along with real work, and reverting the guard fails five of them.
|
||||
Commit `c881fdf`.
|
||||
|
||||
### Left red: the repo-wide lint gate
|
||||
|
||||
| Command | Exit | On `origin/master` |
|
||||
|---|---|---|
|
||||
| `npx eslint "{src,apps,libs,test}/**/*.ts"` (backend) | 1 — 1285 errors, 95 warnings | identical, byte for byte |
|
||||
| `npm run lint` (frontend) | 1 | identical |
|
||||
|
||||
**No error is in a file this branch touched.** Verified by running both commands against
|
||||
`origin/master` in a throwaway worktree.
|
||||
|
||||
- **Backend:** 1109 of the 1285 are auto-fixable; **176 survive `--fix`**, across 25 files, 74 of
|
||||
them in `auth/` — mostly `no-unsafe-member-access` on what looks like an untyped `req.user`.
|
||||
The repo's own pinned script already carries `--fix`, so even that exits 1.
|
||||
- **Frontend:** `npm run lint` runs `next lint`, which Next 16 removed, so it reads `lint` as a
|
||||
directory and has never linted anything. Repointing it at `eslint` surfaces 22 errors: 10
|
||||
`react-hooks/set-state-in-effect` in `useAuth`, `RealtimeProvider`, `ToastProvider`,
|
||||
`ThemeToggle`, `AppDateInput` and the badge hooks; 7 `no-explicit-any` in the auth layer; 3
|
||||
`static-components`; 2 trivial.
|
||||
|
||||
**This repo has never had a green lint gate on either side**, and `.gitea/workflows/*` runs no
|
||||
lint step, so nothing ever reported it. `/orchestrate` is the first thing to run it.
|
||||
|
||||
Amin's call, 2026-09-16: **leave it.** The repair means restructuring effects in authentication,
|
||||
realtime and toast providers, and the frontend has no component tests to catch a regression — a
|
||||
broken `useAuth` effect would first be noticed by a human unable to sign in. It is its own task,
|
||||
on its own branch, done attended.
|
||||
|
||||
Consequence to expect: `test-exit-guard.mjs --stop` blocks on this ledger, and every future
|
||||
`/orchestrate` in this repo inherits the same red, until that task is done.
|
||||
|
||||
### State
|
||||
|
||||
Branch `feat/cases/add-voice-input-for-lab-case-line` at `c881fdf`, **not pushed**.
|
||||
Green: backend 230 tests / 18 suites, `nest build`; frontend 99 tests, `tsc --noEmit`,
|
||||
`next build`; eslint clean on each of the 13 touched files.
|
||||
Red: the two repo-wide lint commands above.
|
||||
Outstanding: §10 manual pass, and the verifier's 4 FAILs / 8 unguarded criteria, which need
|
||||
either component tests or a running API — see the Verify entry above.
|
||||
Reference in New Issue
Block a user