Skip to content

Commit 6a81bf7

Browse files
committed
feat(v7-f56b): UI badge + verify RPC gotcha for dim_env mismatch
cppmega_v4/jsonrpc/methods.py: - verify RPC now appends a 'v7_f56b_dim_env_mismatch' gotcha (severity=warning) whenever dim_env pins all three of (H, nh, head_dim) and nh*head_dim ≠ H. Reuses the existing gotcha payload channel so the UI GotchasTab renders it without any new plumbing. vbgui/src/App.tsx: - New absolutely-positioned banner inside the canvas pane: data-testid='symbolic-dim-warn-badge', visible iff the gotcha is present in spec.gotchas. Renders a yellow-amber alert with the message text (data-testid='symbolic-dim-warn-message'), positioned top-right of the canvas so it overlays without obscuring bricks. - FlowCanvas now sits inside a relative-positioned wrapper to anchor the badge; existing flex layout preserved (FlowCanvas keeps flex:1 inside the wrapper). Existing App.integration + FlowCanvas vitest pass (10/10). Ref: cppmega-mlx-j3qa.2
1 parent 2040299 commit 6a81bf7

2 files changed

Lines changed: 58 additions & 6 deletions

File tree

cppmega_v4/jsonrpc/methods.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,30 @@ def verify(params: VerifyParams, *, cache: LRUCache | None = None) -> VerifyResu
375375
gotcha_payloads.extend(
376376
_side_channel_policy_gotchas(params.side_channels, available)
377377
)
378+
# V7-F56b: surface the symbolic-dim mismatch as a gotcha so the
379+
# vbgui GotchasTab + per-brick badge render it without needing
380+
# a separate WS channel.
381+
de = params.dim_env if isinstance(params.dim_env, dict) else (
382+
params.dim_env.model_dump()
383+
if hasattr(params.dim_env, "model_dump") else {}
384+
)
385+
f56b_H = de.get("H")
386+
f56b_nh = de.get("nh")
387+
f56b_hd = de.get("head_dim")
388+
if (f56b_H is not None and f56b_nh is not None and f56b_hd is not None
389+
and f56b_nh * f56b_hd != f56b_H):
390+
gotcha_payloads.append(GotchaPayload(
391+
id="v7_f56b_dim_env_mismatch",
392+
severity="warning",
393+
message=(
394+
f"dim_env.H={f56b_H} but nh*head_dim = "
395+
f"{f56b_nh}*{f56b_hd} = {f56b_nh * f56b_hd}. "
396+
"Attention still runs via internal Q projection, but "
397+
"this almost always means the architect mis-pinned a "
398+
"dim_env value."
399+
),
400+
reference=None,
401+
))
378402

379403
edge_payloads: list[EdgeResolution] = []
380404
for re in resolved.edges:

vbgui/src/App.tsx

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -626,12 +626,40 @@ export function App(): JSX.Element {
626626
{activeTab === "canvas" && (
627627
<>
628628
<Palette />
629-
<FlowCanvas
630-
nodes={nodes} edges={edges}
631-
onConnect={handleConnect}
632-
onDropBrick={handleDropBrick}
633-
onNodeClick={setSelectedBrickId}
634-
/>
629+
<div style={{ flex: 1, position: "relative", display: "flex",
630+
minHeight: 0 }}>
631+
{spec.gotchas.some(
632+
(g) => g.id === "v7_f56b_dim_env_mismatch") && (
633+
<div
634+
data-testid="symbolic-dim-warn-badge"
635+
role="alert"
636+
style={{
637+
position: "absolute", top: 8, right: 8, zIndex: 5,
638+
background: "#fef3c7", color: "#92400e",
639+
borderLeft: "4px solid #d97706",
640+
borderRadius: 4, padding: "6px 10px",
641+
fontSize: 12, fontFamily: "system-ui, sans-serif",
642+
boxShadow: "0 1px 2px rgba(0,0,0,0.08)",
643+
maxWidth: 320,
644+
}}
645+
>
646+
<strong data-testid="symbolic-dim-warn-title">
647+
⚠ Symbolic-dim mismatch
648+
</strong>
649+
<div data-testid="symbolic-dim-warn-message"
650+
style={{ marginTop: 2 }}>
651+
{spec.gotchas.find(
652+
(g) => g.id === "v7_f56b_dim_env_mismatch")?.message}
653+
</div>
654+
</div>
655+
)}
656+
<FlowCanvas
657+
nodes={nodes} edges={edges}
658+
onConnect={handleConnect}
659+
onDropBrick={handleDropBrick}
660+
onNodeClick={setSelectedBrickId}
661+
/>
662+
</div>
635663
{selectedBrickId && (() => {
636664
const selected = nodes.find((n) => n.id === selectedBrickId);
637665
if (!selected) return null;

0 commit comments

Comments
 (0)