Commit Graph

336 Commits

Author SHA1 Message Date
705ea92da7 bugfix: cases critical bugs fixed.
All checks were successful
Production — tag build, push, deploy / build-and-push (push) Successful in 4m54s
Production — tag build, push, deploy / deploy (push) Successful in 13m25s
v1.0.19
2026-09-21 01:44:55 +03:30
b42adecd71 Merge pull request 'fix(ci): prod nginx re-resolves backend via Docker DNS; deploy starts nginx last' (#88) from bug/ci-cd into master
All checks were successful
Registry — build, push, deploy / build-and-push (push) Successful in 1m14s
Registry — build, push, deploy / deploy (push) Successful in 1m7s
Reviewed-on: #88
Reviewed-by: admin <admin@localhost>
2026-09-20 23:36:40 +03:30
fae7e0cd53 fix(ci): prod nginx re-resolves backend via Docker DNS; deploy starts nginx last
All checks were successful
Production — tag build, push, deploy / build-and-push (push) Successful in 58s
Production — tag build, push, deploy / deploy (push) Successful in 46s
v1.0.18
2026-09-19 09:26:06 +03:30
0324589928 Merge pull request 'improvement: Build and Push error fixed.' (#87) from feature/billing into master
All checks were successful
Registry — build, push, deploy / build-and-push (push) Successful in 5m6s
Registry — build, push, deploy / deploy (push) Successful in 1m20s
Reviewed-on: #87
Reviewed-by: aminmsvi <amn.mousavi@gmail.com>
2026-09-19 06:23:43 +03:30
f6867467f7 improvement: Build and Push error fixed.
All checks were successful
Production — tag build, push, deploy / build-and-push (push) Successful in 4m36s
Production — tag build, push, deploy / deploy (push) Successful in 20m52s
v1.0.17
2026-09-19 06:19:42 +03:30
851d4a1546 Merge pull request 'feature/billing' (#86) from feature/billing into master
Some checks failed
Registry — build, push, deploy / build-and-push (push) Failing after 25m50s
Registry — build, push, deploy / deploy (push) Has been skipped
Reviewed-on: #86
Reviewed-by: aminmsvi <amn.mousavi@gmail.com>
2026-09-19 05:38:12 +03:30
bb04090bc6 Merge branch 'master' into feature/billing 2026-09-19 05:21:25 +03:30
5977990412 improvement: Voice feature tuned with new pontic rules. 2026-09-19 05:12:23 +03:30
9f77a78139 improvement: A currency patch applied just to lables. not a final solution yet. 2026-09-19 05:06:45 +03:30
b8129bef6c improvement: Pontic rules updated. alongside with other shits! 2026-09-19 04:57:56 +03:30
cb5d4f0477 Merge pull request 'feature/minore-features-v1' (#85) from feature/minore-features-v1 into master
All checks were successful
Registry — build, push, deploy / build-and-push (push) Successful in 4m37s
Registry — build, push, deploy / deploy (push) Successful in 1m12s
Reviewed-on: #85
Reviewed-by: admin <admin@localhost>
2026-09-19 02:07:39 +03:30
e7a3e749d9 Make Treatment and lab Cases usable at phone and tablet widths. 2026-09-19 01:05:14 +03:30
d52b0e32cb improvement: billing reviewd. note added to financial transactions. 2026-09-18 17:07:36 +03:30
637e4af637 improvement: billing v1 UX finalized. still buggy though. 2026-09-18 16:28:32 +03:30
c79bba935b Touch on the FDI chart no longer selects a tooth when you scroll. 2026-09-18 14:12:56 +03:30
778f02ee83 improvement: Redundant and unuseful gadgets removed from dashboard. 2026-09-18 13:54:08 +03:30
4141d88bfd Merge pull request 'Make patient identification the unique identity instead of mobile.' (#84) from feature/minore-features-v1 into master
All checks were successful
Registry — build, push, deploy / build-and-push (push) Successful in 18m7s
Registry — build, push, deploy / deploy (push) Successful in 1m18s
Reviewed-on: #84
Reviewed-by: admin <admin@localhost>
2026-09-18 03:55:41 +03:30
0b6e6b4563 feature: payment flow updated. 2026-09-18 03:50:48 +03:30
5e1b0cb6eb feature: v1 billing implemented. 2026-09-18 02:12:56 +03:30
63058828f1 Make patient identification the unique identity instead of mobile.
mobile stays required but is no longer globally unique.
2026-09-17 23:25:08 +03:30
284067d16b Merge pull request 'Remove organization email; unique orgs by owner and name' (#83) from feature/minore-features-v1 into master
All checks were successful
Registry — build, push, deploy / build-and-push (push) Successful in 58s
Registry — build, push, deploy / deploy (push) Successful in 1m8s
Reviewed-on: #83
Reviewed-by: admin <admin@localhost>
2026-09-17 21:47:14 +03:30
da544f18b7 Remove organization email; unique orgs by owner and name 2026-09-17 20:46:32 +03:30
6313701ed0 improvement: Some minor UI improvements. 2026-09-17 13:37:41 +03:30
809faa04e8 improvement: Pontic task and step generations updated. Some silent exeptions now actually informs users. 2026-09-16 20:19:12 +03:30
04b338408e improvement: Pontic added to prosthesis types catalog as a main catagory. voice feature updated accordingly. 2026-09-16 15:43:47 +03:30
e7efea7818 Merge pull request 'Cache npm and Docker bases on the Gitea registry and Verdaccio.' (#81) from feature/ci-cd into master
All checks were successful
Registry — build, push, deploy / build-and-push (push) Successful in 1m10s
Registry — build, push, deploy / deploy (push) Successful in 1m11s
Reviewed-on: #81
Reviewed-by: admin <admin@localhost>
2026-09-16 12:01:05 +03:30
957f94cf15 Cache npm and Docker bases on the Windows Gitea host for Iran-only builds.
CI installs via local Verdaccio and prefers Gitea copies of node/postgres/nginx so staging and prod can still ship when Docker Hub and npmjs are unreachable.
2026-09-15 12:04:04 +03:30
554a31fd10 Merge pull request 'feature/ci-cd' (#80) from feature/ci-cd into master
All checks were successful
Registry — build, push, deploy / build-and-push (push) Successful in 27s
Registry — build, push, deploy / deploy (push) Successful in 46s
Reviewed-on: #80
Reviewed-by: aminmsvi <amn.mousavi@gmail.com>
2026-09-15 08:37:05 +03:30
d10509191c fix(ci): grant prod SSH key ACL by SID on Windows runners
All checks were successful
Production — tag build, push, deploy / build-and-push (push) Successful in 22s
Production — tag build, push, deploy / deploy (push) Successful in 15m32s
act_runner under Network Service sets USERNAME to HOST$, which icacls cannot map.

Co-authored-by: Cursor <cursoragent@cursor.com>
v1.0.16
2026-09-15 07:32:30 +03:30
52923e87d8 fix(ci): rewrite leftover npmmirror URLs so npm ci uses npmjs.com
Some checks failed
Production — tag build, push, deploy / build-and-push (push) Successful in 21s
Production — tag build, push, deploy / deploy (push) Failing after 5s
Lockfiles still pointed at registry.npmmirror.com after switching the
Docker registry, which caused ECONNRESET on victory-vendor during frontend builds.

Co-authored-by: Cursor <cursoragent@cursor.com>
v1.0.15
2026-09-14 21:14:38 +03:30
2983061363 shift from mirror to official npm cdn. 2026-09-14 20:33:20 +03:30
ea4d348dc2 fix(ci): install npm packages via npmmirror when npmjs.org is blocked
Staging Docker builds were hanging ~25m then dying with Exit handler never
called because registry.npmjs.org resets TLS from the runner. Point npm ci
at npmmirror (rewrite lockfile tarball hosts for the build only).
2026-09-13 20:24:45 +03:30
e3ff59497f fix(ci): build images on node:20-bookworm-slim instead of Alpine
Alpine npm ci kept dying with Exit handler never called on Docker
Desktop; nested retries only burned hours. Use Debian + a single
cached npm ci, and update the Gitea node image mirror.
2026-09-12 15:34:24 +03:30
e2614bf4b0 fix(ci): retry npm ci in Docker builds when Exit handler never called
Docker Desktop OOM can kill npm mid-install on the Windows staging
runner. Retry npm ci, then fall back to install, and document the
≥8GB RAM requirement.
2026-09-12 11:07:56 +03:30
b8cfa9c597 Merge pull request 'feat/treatment/add-voice-input-for-new-treatment-form' (#79) from feat/treatment/add-voice-input-for-new-treatment-form into master
Some checks failed
Registry — build, push, deploy / deploy (push) Has been cancelled
Registry — build, push, deploy / build-and-push (push) Has been cancelled
Reviewed-on: #79
Reviewed-by: rameen <rameen.naghdi@gmail.com>
2026-09-12 09:22:49 +03:30
98e2599535 fix(voice): stop the review sheet from contradicting itself about a target
A tooth named twice — once bare, once with a job — was counted as jobless.
joblessProsthesisTargets adds an uncovered target inside the loop, but a LATER
assignment can still cover it, and nothing re-checked at the end. The sheet then
showed 13 with its crown AND struck through as "no prosthesis heard".

prosthesisTargetLines also returns a line per target including one with nothing
applied and nothing refused, so the sheet printed a dangling "13: " beside the
jobless entry for the same tooth. The sheet now renders only lines carrying a
code; the unfiltered list still feeds the chart, so a target pending a material
pick stays selected. A line whose codes were all refused no longer opens with a
leading " + ".

applyVoiceResult now reads labCaseDraftsRef.current rather than the state. Every
other handler writes that ref beside setLabCaseDrafts precisely because a save
in the same tick reads it; this path was the one left reading state, so a draft
added earlier in the same tick could be dropped.

Found by /code-review. One new test, verified to fail without the fix.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 22:42:18 +08:00
c57abbe895 docs: say component tests are allowed, not absent by rule
CLAUDE.md read as a prohibition — "Vitest for its own pure helpers only, no
React, no DOM". It was only ever a description of what was installed, and it
was talking future contributors out of a test they are allowed to write.

Tests now states what exists, that component tests are allowed, and what the
first one costs: jsdom or happy-dom, @testing-library/react v16+ for React 19,
environment and a *.spec.tsx include. Notes that babel-plugin-react-compiler is
in devDependencies but not enabled in next.config.ts, so there is no transform
mismatch to work around.

Adds which to reach for. A decision belongs in a pure test, extracted into
components/{feature}/. A defect only a real render shows — ref-versus-state
timing, effect ordering — belongs in a component test, because no pure test can
see it. VoiceReviewSheet is the cheap first one; TreatmentWorkspace needs six
axios mocks and earns its keep only for a bug that needs it.

Same correction in vitest.config.ts's docblock and the spec's §12 line, which
each carried their own copy of "no React, no DOM".

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 15:49:36 +03:30
2c3e28ac79 refactor(voice): extract the apply decision so it can be tested
applyVoiceResult decided what to write and wrote it, in one callback inside a
3200-line client component. Nothing could reach it — not exported, and rendering
its component means mocking next-intl, the i18n router and six axios modules.
Three of the five defects found in live use sat in that callback, while 209
green tests covered the helpers around it.

buildVoiceApplyPlan(result, selection, ctx) -> { detail, labCaseDraft } now
holds the decision and writes nothing. The callback keeps only what a component
must do: setDetails, the ref writes the in-flight save reads, and the order that
lets lab rows carry a real treatmentDetailId. newDetail and newLabCaseDraft move
to treatmentDetailRules.ts so the pure module can build a draft without
importing a component.

21 tests. Verified they bite by reverting each bug in place: reading
labDependent from result.treatmentType fails 1, merging the plain teeth list
onto a prosthesis detail fails 2.

One group asserts an invariant that belongs to the backend — every
toothProsthesis row naming a real tooth must be in detail.teeth, which is
TREATMENT_TOOTH_NOT_ON_DETAIL at treatments.service.ts:806. It spans two
processes, so neither side could state it alone before.

Not covered, still manual: the labCaseDraftsRef timing needs a real render.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 15:49:35 +03:30
78fd3eb092 fix(voice): hear "یادداشت" as a note request, and stop the note at the next instruction
Two reports from live dictation in fa.

The locale trigger vocabulary listed only verbs that ask for a note ("بنویس",
"یادداشت کن"). Naming the field itself — "توی یادداشت‌ها بنویس", "در توضیحات" —
reported no commentTrigger, and the resolver discards a comment without one, so
the note was silently dropped. Added the field-name shape to fa, en and nl.

Where the dictated note ends was never stated, so the model answered it
inconsistently: "توی توضیحات بنویس سلام چطوری و بفرست برای لابراتوآر سانشاین"
sometimes put the lab dispatch inside the comment. Added a no-overlap rule — a
clause reported as a lab, tooth, prosthesis or deadline is an instruction and
must not appear in comment as well — with that sentence as a worked example.

Both rules go in the prompt and in the JSON-schema field descriptions, because
the schema description is what the model reads while filling the field. No code
enforcement for the second: stripping an extracted clause out of free-speech
note text by string matching is guesswork, and the review sheet shows the note
before it is saved.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 15:49:35 +03:30
b71b4e9ca9 feat(voice): write a note only when the clinician asks for one
The comment instruction told the model to sweep up leftovers: "clinical
notes, in the language spoken. Omit the parts already captured as treatment
type, teeth, prosthesis work or deadline." So filler, small talk and an
unrequested diagnosis all became a persisted clinical note — and comment is
the one durable trace a recording leaves (§10).

The model now reports the exact words that asked for the note in a new
commentTrigger field, and comment holds only what was dictated after them.
resolveVoiceIntent keeps comment only when a trigger is present, so the rule
is enforced by code instead of trusted to the prompt: a model that decides
leftover speech was a note loses that note.

Per-locale trigger vocabulary goes in the prompt's locale notes, beside the
tooth vocabulary — «بنویس که», "write this in the notes", "noteer". The
resolver only checks that a trigger was reported, so it needs no per-locale
knowledge and stays locale-neutral, as §6 requires.

Also adds HARD RULE 7: never decide something is a note; speech that fits no
field is simply not reported.

Four resolver tests. The two that drop an unasked note fail without the
guard; the trigger-only and trigger-with-note cases pass either way and exist
to prove the guard does not swallow a real note.

Frontend untouched — it only ever saw the resolved comment, never the
trigger.

Spec: §5 gains the rule and the field, decision 54 added.

Gates: backend 220 tests, nest build, ESLint clean on the voice module;
frontend tsc --noEmit clean, 52 Vitest tests.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 15:49:35 +03:30
d98c76d5d5 feat(voice): keep the transcript on the server
The review sheet rendered the full dictation at the top of the modal,
unconditionally. A raw transcript can carry the patient's spoken name — the
spec said so itself in §9, while §10 said telemetry must never contain it.

The transcript no longer reaches the browser by any route:

- removed from the success response (VoiceExtractionResponse is now plain
  ResolvedExtraction, which never had the field)
- removed from the error body. VOICE_EXTRACT_FAILED carried
  details.transcript for a salvage dialog that was never built, and
  ApiError['details'] is an array, so the shape never even matched — it was
  serialized onto the wire and dropped
- removed from the sheet, and from VoiceExtractionResult. tsc proves that
  <p> was the only reader in the whole frontend

It is logged instead: one info line per recording, written immediately after
the emptiness check so a failed extraction still records it, and deliberately
outside logTelemetry so that method's patient-free guarantee stays literally
true.

Accepted consequence, recorded in §10: patient words now persist in
production server logs at default level, so whatever retention and access
control applies to those logs applies to dictation. The repo's other
sensitive-text path (openrouter.provider.ts) uses debug level with
truncation; moving this line to debug is a one-word change.

Transcript salvage is dropped rather than deferred, which settles §11 open
item 16 by taking its second option. When extraction fails the clinician
re-dictates; an operator can read the words in the log, the person who spoke
them cannot.

Spec: §7, §9 and §10 rewritten, item 16 resolved, decisions 51-53 added, and
decisions 10 and 25 marked superseded so the log stops contradicting itself.

No automated coverage for the response shape or the log line: there is no
voice.service.spec.ts — the service is I/O orchestration and has never been
unit tested. Removing the type field is what proves no reader survives.

Gates: backend 216 tests, nest build, ESLint clean on the voice module;
frontend tsc --noEmit clean, 52 Vitest tests, next build clean.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 15:49:35 +03:30
21c78bb930 fix(treatment): never keep a bridge across a tooth that left it
A bridge is a contiguous span, but every operation that filtered teeth out of
a group kept the `connected` kind as long as two teeth remained. Reduce a
12-13-14 span to 12 and 14 and you get a "bridge" with no pontic — and worse,
both teeth keep one selectionGroupId, so the lab receives them as a single
unit and task generation builds work that cannot be made.

linkedEdgesFromGroups already guarded the drawn marks with areArchNeighbors,
so the chart looked right while the data was wrong.

Adds splitDisconnectedRuns, which breaks what remains into contiguous runs: a
run of two or more stays connected, a run of one becomes a single. The first
run keeps the original groupId so lab rows pointing at it stay valid, and
pruneToothProsthesisForGroups re-maps the rest.

Applied at all three sites that filter a group's teeth, which each carried
their own copy of the length check:
- groupsFromFlatTeeth, when teeth are no longer selected
- applyShiftRange, when a shift-range takes teeth from an existing group
- removeTeethFromGroups, the path pruneDetailTeethToJobs uses

toggleToothInGroups already split into runs by hand for the single-removal
case; this is the same rule, shared.

Tests: a new toothSelectionGroups.spec.ts (13) plus two for
removeTeethFromGroups. The middle-tooth cases fail without the fix; the
end-tooth and contiguous cases pass either way and exist to prove it does not
over-reach. CLAUDE.md updated for the third Vitest file.

Not fixed: a pre-existing unused `leftIdx` warning in unlinkAdjacentTeeth,
unrelated to this change.

Gates: 52 Vitest tests, tsc --noEmit clean, next build clean, ESLint
unchanged at 1 pre-existing warning.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 15:49:35 +03:30
f014793dec fix(voice): prime the lab-drafts ref before the save that reads it
"برای دندون ۱۲ و ۱۴ یه فول متال کران" previewed correctly, then Apply failed
with TREATMENT_TOOTH_NOT_ON_DETAIL. The form still showed both teeth and both
crowns — that is React state. The database got a detail with no teeth.

applyVoiceResult called setLabCaseDrafts but never wrote
labCaseDraftsRef.current, which is only refreshed in the render body.
persistDraft runs in the same tick and starts by pruning each lab-dependent
detail down to the teeth its jobs cover, reading that stale ref. It found no
draft for the brand-new detail, so jobs were empty, so the detail was saved
with teeth: []. persistLabCases then posted rows for 12 and 14 against it,
and the server — which re-reads the detail's teeth from the database, because
the lab-case endpoint carries no teeth field — correctly refused.

detailsRef was already written by hand two lines above for exactly this
reason (3911477). This is the other half of the same mistake.

Two sibling handlers had the same gap and are fixed with it: adopting an
orphan lab case, and creating a new lab draft. Both call setLabCaseDrafts and
then persistDraft in the same tick. handleLabCasesChange was the only site
that already primed the ref, and it is the pattern the others now follow.

Adds a comment at the ref declaration, because the coupling between this ref
and persistDraft's prune is invisible at the call sites and has now cost two
bugs.

No automated test: this is state-and-ref ordering inside a React component,
and the frontend's Vitest scope is pure helpers only — no React, no DOM.
Mirroring the server's tooth rule on the client to make it testable would
duplicate a rule across layers, which decision 38 rules out.

Gates: tsc --noEmit clean, 37 Vitest tests, next build clean, ESLint warnings
unchanged at 10 (all pre-existing, count verified against HEAD).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 15:49:35 +03:30
ae33159e7d fix(voice): stop reading a dictated jaw as a broken tooth
"یه کامپلیت دنچر برای فک بالا میخوام" resolved the upper arch and the
complete denture correctly, but the review sheet also showed
position_out_of_range against «فک بالا» and asked which tooth was meant. No
tooth was said.

The model names the jaw in the top-level `teeth` array as well as in the
prosthesis target it belongs to. resolveVoiceIntent passed that array
straight to resolveToothIntents, extraction.wire.ts turns `position: null`
into NaN, and unresolvedReason tests positionBad first — so it reported a
range fault for a value that was never a number, before ever reaching the
quadrant branch.

resolveVoiceIntent now drops jaw-shaped entries — an arch with no usable
position — before the tooth resolver sees them. The jaw already reaches the
form through its assignment, so the duplicate carries no information worth
reporting. An entry that DOES give a position survives: arch plus position
without a side is a real tooth described without its quadrant, and must keep
offering its candidate chips.

Two invitations removed as well, both ours: the `teeth` property in
VOICE_INTENT_JSON_SCHEMA had no description at all, and no prompt rule said a
jaw must stay out of it, while TOOTH_SCHEMA — shared with
prosthesis[].targets — describes jaws as acceptable. Adds the description and
HARD RULE 6.

Four tests. The two jaw cases fail without the filter; the out-of-range and
missing-quadrant cases pass either way and exist to prove the filter does not
over-reach.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 15:49:35 +03:30
068faf7e15 docs: mark the catalog-kinds work item done now that it is applied
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 15:49:35 +03:30
3740787306 docs: prove the migration and seed against dev Postgres
Five migrations were pending, not one: this dev database had not been
migrated since the prosthesis overhaul landed on master. Used migrate deploy
rather than migrate dev so no drift prompt could offer a reset, and counted
the DELETE first — 0 rows matched against 2 total.

Seeded translations verified: 7 categories and 5 subcategories in fa, en and
nl, with crown resolving to روکش‌ها. Both login accounts survived.

Also records that .gitea/workflows run no test, lint or typecheck step at
all, which is why two spec-file type errors reached the branch unnoticed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 15:49:35 +03:30
6f2be4a7e8 docs: record that a prosthesis dictation reaches teeth only through the merged row
Decision 39 couples teeth and jobs on a lab-dependent type, so unticking the
merged row and then the type row applies a detail with no teeth at all. master
kept them, because the rows were separate. Approved as an accepted consequence
rather than patched, since applying teeth the clinician just unticked would
break the sheet-is-a-contract rule.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 15:49:35 +03:30
88c33059fd docs: record the second refute round and the one open consequence
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 15:49:35 +03:30
4194442654 fix(voice): validate a code's region against its target properly
Second correctness pass on e271858 found three ways an arch-only appliance
could be written as a per-tooth job, plus a gap in the previous repair.

1. The deferred region check was never completed. A mixed-region category
   resolved with no region recorded, and nothing re-validated the leaf the
   clinician then picked — "پروتز متحرک برای دندون ۱۲" wrote a complete
   denture onto tooth 12, which the manual chart cannot produce and which
   task generation would expand as denture steps. Targets now resolve BEFORE
   types, so the target kind narrows a category's candidates and an
   impossible leaf is never offered. The deferral disappears with it.

2. `some` over the stack's regions let one legal code admit every other.
   `types: ['pfm_crown','night_guard_soft']` on tooth 12 passed, because
   `crown` suited the tooth, and wrote a night guard onto that tooth. Now
   every named code must suit the target.

3. `regions.size === 1` also deferred `implant`, whose leaves span root and
   crown — both tooth regions, so not a tooth/arch category at all. An
   implant aimed at a jaw resolved as a UA target. Narrowing by target kind
   rejects it instead.

4. The e271858 type-row lock ticked the row and the payload but not the
   count, so the sheet read "Apply 1 field" while two landed. One
   `effectiveSelection` now drives the count and the payload.

Also narrows a `filter(Boolean)` in the disjointness test that left two
implicit-any errors under the full tsconfig (nest build excludes specs, so
the repo gate never saw them). Pre-existing at 15ddb9a.

Adds four resolver tests: candidate narrowing per target kind, a category
with no usable leaf, a stack where only one code suits, and a legal stack.
All three defects passed the previous 209 tests.

Gates: backend 212 tests, nest build, ESLint clean on the voice module;
frontend 37 Vitest tests, tsc --noEmit, ESLint clean.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 15:49:35 +03:30
08b4d36f27 fix(voice): repair the two defects the correctness critic found
Both found by the /orchestrate correctness critic against 15ddb9a, and both
verified by hand before fixing.

1. A picked tooth chip was dropped on Apply. pickCandidate ticked the teeth
   row from `available`, which is memoised from `effective` — the value the
   same handler is in the middle of changing. On "ترمیم برای دندون دو" the
   backend returns no teeth, so `available.teeth` was false at pick time and
   `prev.teeth` was false too; `false || false` stuck permanently. A variant
   of the original live-test failure. Each branch now ticks the row it feeds
   and returns, so nothing reads the stale memo.

2. Decision 41's type-row lock was missing. The treatmentType row was a plain
   toggle, and applyVoiceResult derived `labDependent` from
   `result.treatmentType` rather than the `detail.treatmentType` it writes —
   so unticking the type row saved prosthesis lab rows on whatever type the
   appointment purpose had seeded. Row gains a `locked` state, the type row
   locks while the prosthesis row is ticked, Apply sends the forced tick, and
   `labDependent` now comes from the detail being written.

Gates: backend 16 suites / 209 tests, frontend 37 Vitest tests,
tsc --noEmit clean, next build clean, ESLint 0 new warnings
(VoiceReviewSheet.tsx 0 issues; the 10 in TreatmentWorkspace.tsx are
pre-existing and unchanged in count).

Not covered by a test: both fixes live in component state logic, which the
chosen Vitest scope — pure helpers, no React, no DOM — cannot reach. §12's
manual checks cover them.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 15:49:35 +03:30