Skip to content

feat(fma): /fma-body organ search + zoom + clinical NARS reasoning#60

Merged
AdaWorldAPI merged 2 commits into
mainfrom
claude/charming-johnson-ufstpw
Jun 24, 2026
Merged

feat(fma): /fma-body organ search + zoom + clinical NARS reasoning#60
AdaWorldAPI merged 2 commits into
mainfrom
claude/charming-johnson-ufstpw

Conversation

@AdaWorldAPI

@AdaWorldAPI AdaWorldAPI commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Builds on the merged /fma-body plateau (#59). Two commits, additive only — no existing route, mesh, or page touched. Adds the two things the operator asked for on the full-body viewer (search-to-zoom + clinical NARS reasoning), plus the two requested architecture docs.

1 · /fma-body search + zoom + clinical NARS panel (b309cb56)

Search → zoom

cockpit_bake now emits fma_body.mesh.nodes.json — a row → {fma, name, tissue} index for the 768 FMA nodes that actually carry geometry in the mesh (name = deepest segment of the part_of distinguished name, e.g. FMA10014 → "ninth thoracic vertebra"). FmaBody.tsx reads it, groups vertices by the per-vertex node_row into client-side centroids, and a search box lerps the camera onto the picked organ. No mesh-byte change — the index rides alongside (the only bake write-path edit is an iteration-style fix that emits identical bytes).

Clinical NARS reasoning

New POST /api/clinical/reason (crates/cockpit-server/src/clinical.rs) compiles a {organ, condition, medication, labs} scenario into a small clinical graph of (subject —rel→ object, NarsTruth) statements from a hand-authored rule KB (condition→effects, drug→properties, (effect×property)→risk, lab→effect), then runs 2-hop NARS deduction A→B, B→C ⊢ A→C through the real planner algebra — lance_graph_planner::nars::truth::TruthValue::deduction (f = f1·f2, c = f1·f2·c1·c2), the same bridge graph_engine::nars_deduction uses.

cirrhotic liver + acetaminophen:
  acetaminophen —is→ hepatically_metabolized —confers→ drug_accumulation_toxicity
  ⊢ acetaminophen → drug_accumulation_toxicity   (f=0.81, c=0.58, via hepatically_metabolized)

FmaBody.tsx ships a SCENARIOS mock set (cirrhotic liver + acetaminophen, CKD + NSAID, etc.) so the panel is clickable for demo, renders the summary + derived deductions (truth_f/truth_c), and shows an in-view disclaimer: a NARS illustration over a tiny rule KB, not medical advice.

change file
search index emit (768 nodes) fma/src/bin/cockpit_bake.rs, cockpit/public/fma_body.mesh.nodes.json
search box + centroid zoom + NARS panel + SCENARIOS cockpit/src/FmaBody.tsx
clinical endpoint (real TruthValue::deduction) + unit test crates/cockpit-server/src/clinical.rs
mod clinical; + one route crates/cockpit-server/src/main.rs

2 · V3 (part_of:is_a) SoA wiring + OGAR consumer integration docs (0242f7af)

  • fma/docs/V3_SOA_WIRING.md — how the canonical NodeGuid's (part_of:is_a) tile lays into the SoA columns (high byte = part_of/where, low byte = is_a/what, cascading HEEL→HIP→TWIG), the Located-vs-Cascade classid dispatch, and what "guid-shaped AST" means for rails-style programs eventually running off the key (prerender / route / group with zero value decode).
  • fma/docs/OGAR_CONSUMER_INTEGRATION.md — per-consumer upgrade path to the (part_of:is_a) addressing + the new data-representation/AST superpowers (key-only SoA scan, prefix-routable subtree selection, the 89–130× key-vs-value scan from soa_scan). Surfaces that osint-bake still uses the 7-group NodeGuid v2 API (new_v2/.leaf()/.family_v2()) absent from the 6-group canonical_node.rs — flagged as an I-LEGACY-API-FEATURE-GATED follow-up.

Speculative claims in both docs are CONJECTURE-tagged rather than asserted as shipped behavior.

Verification — and one honest gap

Verified locally:

  • fma cargo clippy clean on the touched bins (cockpit_bake/converge/graph/soa_scan). The anchor(3)/mesh(1) warnings are byte-identical on origin/main — pre-existing, out of scope.
  • cockpit tsc + vite build green (102 modules).
  • Wire contract matched on both ends: handler emits summary / inferences[source, target, truth_f, truth_c, inference_type, via] / disclaimer; FmaBody reads exactly those and filters inference_type === 'Deduction'.
  • clinical.rs carries a unit test for the cirrhosis→accumulation chain.

Could NOT verify (env gap, pre-existing): cockpit-server does not compile in this environment — lance-graph-ogar is absent from the local lance-graph checkout, so the whole workspace manifest fails to load. clinical.rs is rustfmt-validated and its logic hand-traced; the route + module are wired. Backend compile + the NARS panel going live are CI / cockpit-redeploy-gated — the frontend and the bake artifact are fully verified, the backend is not.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GJ4NVBSjq1w5h7RmTbVafb


Generated by Claude Code

Summary by CodeRabbit

  • New Features

    • Added a searchable anatomy/organ list with click-to-focus behavior in the 3D viewer.
    • Introduced a demo clinical reasoning panel that returns scenario-based summaries and inferences.
  • Bug Fixes

    • Improved camera movement and transparency handling for smoother viewing when selecting anatomy.
  • Documentation

    • Added new guides covering the updated data model and integration details for the anatomy viewer.

claude added 2 commits June 24, 2026 15:45
Adds two things the operator asked for on the /fma-body full-body viewer:

1. Search + zoom. cockpit_bake now emits fma_body.mesh.nodes.json — a
   row→{fma, name, tissue} index for the 768 FMA nodes that actually carry
   geometry in the mesh (name = deepest segment of the part_of distinguished
   name). FmaBody.tsx reads it, groups vertices by node_row into per-node
   centroids client-side, and a search box lerps the camera to the picked
   organ's centroid. No mesh-byte change — the index rides alongside.

2. Clinical NARS reasoning panel. New /api/clinical/reason endpoint
   (crates/cockpit-server/src/clinical.rs) compiles a
   {organ, condition, medication, labs} scenario into a small clinical graph
   of (subject -rel-> object, NarsTruth) statements from a hand-authored rule
   KB (condition→effects, drug→properties, (effect×property)→risk,
   lab→effect), then runs 2-hop NARS deduction A→B, B→C ⊢ A→C through the
   REAL planner algebra (lance_graph_planner::nars::truth::TruthValue::
   deduction, f=f1·f2 c=f1·f2·c1·c2) — the same bridge graph_engine uses.
   e.g. cirrhotic liver + acetaminophen chains acetaminophen → hepatically
   _metabolized → drug_accumulation_toxicity. Returns inferences (truth_f/
   truth_c) + a plain-language summary. FmaBody ships a SCENARIOS mock set so
   the panel is clickable for demo; an in-view disclaimer marks it a NARS
   illustration over a tiny rule KB, NOT medical advice.

Additive only: new endpoint, new viewer state, new bake artifact — no
existing route, mesh, or page touched. Frontend (tsc+vite) builds green; the
wire contract (summary / inferences[source,target,truth_f,truth_c,
inference_type,via] / disclaimer) is matched on both ends. clinical.rs carries
a unit test for the cirrhosis→accumulation chain.

NOTE: cockpit-server could not be compiled in this environment —
lance-graph-ogar is absent from the local lance-graph checkout, so the whole
workspace manifest fails to load. clinical.rs is rustfmt-validated and its
logic hand-traced; the route + module are wired in main.rs. Backend
verification is CI/redeploy-gated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GJ4NVBSjq1w5h7RmTbVafb
Two architecture notes the operator requested alongside the V3 convergence:

- V3_SOA_WIRING.md — how the canonical NodeGuid's (part_of:is_a) tile is
  laid into the SoA columns (key = part_of high byte / is_a low byte,
  cascading HEEL→HIP→TWIG), the Located-vs-Cascade classid dispatch, and
  what "guid-shaped AST" means for rails-style programs eventually running
  off the key — prerender / route / group from the key with zero value
  decode. 8 claims tagged CONJECTURE.

- OGAR_CONSUMER_INTEGRATION.md — what each consumer must do to upgrade to
  the (part_of:is_a) addressing and what the new data-representation + AST
  superpowers are (key-only SoA scan, prefix-routable subtree selection,
  the 89-130× key-vs-value scan measured in soa_scan). 4 claims tagged
  CONJECTURE; surfaces that osint-bake still uses the 7-group NodeGuid v2
  API (new_v2/.leaf()/.family_v2()) not present in the 6-group
  canonical_node.rs — flagged as an I-LEGACY-API-FEATURE-GATED follow-up.

Docs only; no code touched. Speculative claims are CONJECTURE-marked rather
than asserted as shipped behavior.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GJ4NVBSjq1w5h7RmTbVafb
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 14d95ee2-9c7b-4f78-84ac-4e320162119e

📥 Commits

Reviewing files that changed from the base of the PR and between 03e8982 and 0242f7a.

📒 Files selected for processing (7)
  • cockpit/public/fma_body.mesh.nodes.json
  • cockpit/src/FmaBody.tsx
  • crates/cockpit-server/src/clinical.rs
  • crates/cockpit-server/src/main.rs
  • fma/docs/OGAR_CONSUMER_INTEGRATION.md
  • fma/docs/V3_SOA_WIRING.md
  • fma/src/bin/cockpit_bake.rs

📝 Walkthrough

Walkthrough

Adds a NARS clinical deduction backend (clinical.rs + Axum route) and a per-node mesh search index emitted by cockpit_bake.rs. FmaBody.tsx is extended to decode per-vertex nodeRow, compute organ centroids for camera focus, and render a searchable organ list plus a scenario-driven reasoning panel that posts to the new endpoint. Two documentation files describe the v3 NodeGuid/NodeRow SoA layout and OGAR consumer integration contract.

Changes

Node Search Index + Clinical Reasoning Feature

Layer / File(s) Summary
Node search index generation
fma/src/bin/cockpit_bake.rs, cockpit/public/fma_body.mesh.nodes.json
cockpit_bake builds an fma_name lookup from part_of distinguished names, computes the set of node rows present in the mesh, and writes a .nodes.json file with row/fma/name/tissue entries; the generated JSON is the resulting artifact.
NARS clinical reasoning backend
crates/cockpit-server/src/clinical.rs, crates/cockpit-server/src/main.rs
New clinical.rs defines CliInference, ClinicalScenario, LabValue, an embedded rule KB, nars_deduction, the 2-hop reason pipeline, and clinical_reason_handler; main.rs registers POST /api/clinical/reason.
FmaBody mesh decode, nodeRow, and camera focus
cockpit/src/FmaBody.tsx
decodeSpm1 decodes per-vertex nodeRow into a Uint16Array; RenderState gains a focus field; the animation tick lerps OrbitControls target/camera toward focused centroids; rowCentroid useMemo computes per-node centroid coordinates.
FmaBody search, selection, and reasoning UI
cockpit/src/FmaBody.tsx
Adds SCENARIOS, NodeInfo type, matches filtering memo, pick() for organ focus, runReason() posting to /api/clinical/reason, and JSX panels for organ search results, scenario buttons, and returned summaries/inferences.

V3 SoA Wiring and OGAR Consumer Integration Docs

Layer / File(s) Summary
V3 SoA wiring specification
fma/docs/V3_SOA_WIRING.md
Documents the canonical NodeGuid byte layout, 512-byte NodeRow SoA structure, (part_of:is_a) HEEL/HIP/TWIG tier encoding, EdgeBlock adjacency representation, key-only scan model, and GUID-shaped AST implications with a source map.
OGAR consumer integration guide
fma/docs/OGAR_CONSUMER_INTEGRATION.md
Specifies the NodeGuid/NodeRow/EdgeBlock/ValueSchema contract surface, zero-fallback adoption ladder, per-consumer upgrade paths for lance-graph/q2/fma converge, a 5-step integration recipe, data/AST superpowers, and migration safety rules.

Sequence Diagram(s)

sequenceDiagram
  actor User
  participant FmaBody as FmaBody (React)
  participant CockpitServer as Cockpit Server
  participant clinical_reason_handler

  User->>FmaBody: Select organ (pick)
  FmaBody->>FmaBody: Set stRef.focus → rowCentroid[node]
  FmaBody->>FmaBody: Lerp OrbitControls target + camera

  User->>FmaBody: Select scenario + click Run
  FmaBody->>CockpitServer: POST /api/clinical/reason {organ, condition, medication, labs}
  CockpitServer->>clinical_reason_handler: Deserialize ClinicalScenario
  clinical_reason_handler->>clinical_reason_handler: reason() — rule KB + 2-hop NARS deduction
  clinical_reason_handler-->>FmaBody: {inferences[], summary, engine, disclaimer}
  FmaBody-->>User: Render summaries + filtered inferences panel
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • AdaWorldAPI/q2#59: Introduces the initial FmaBody.tsx viewer and the cockpit_bake.rs step that generates the {out_path}.nodes.json file that this PR consumes via the new nodeRow decode and organ search UI.

Poem

🐇 Hop, hop! A new mesh to decode,
Each organ mapped by row and code.
NARS deduces risks with flair,
The camera glides through thorax air.
Centroid found, the query clear—
This rabbit's chart is engineered! 🧬

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@AdaWorldAPI AdaWorldAPI merged commit bf8764b into main Jun 24, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants