feat: probe/teach agent split — explicit phase markers, position-only plan map
Diagnosis (2026-09-11 user testing, minimal-effort GLM): sessions stuck on 'plan' forever. Two causes: (1) the three-phase view read the stored tree's currentNodeId, which nothing ever writes post author-once (2026-09-03) — a structural dead seam; (2) the teacher stochastically left quiz.nodeId untagged, and done-by-quiz-result semantics would have falsely completed nodes anyway. The redesign (docs/probe-teach-split.md) abolishes derived occupancy in favor of explicit events: - Two agents over one transcript: createProberAgent (quiz without a nodeId field, ask, probe_done) and createTeacherAgent (full toolset, plan_init onward). The chat-handler construction branch keys on a probe_done part in the transcript. MODELS.prober added. - probe_done: server-side seam tool — carries the learner assessment (strands + free-form edge read), refuses while a question is open or the probe is already concluded, and queues a handoff steer through the generalized wake pipeline (steers now dedupe by id, not jobId; job finalization only for job steers). The teacher auto-wakes and authors the plan; the learner sees the assessment via the probe-done card. - phases: probe ends at a concluded probe_done, plan ends at a successful plan_init — strictly sequential, no skipping, no legacy compatibility (data wiped at the pivot per doctrine). - Plan map = position, not completion: derivePlanStatuses reads only tagged quiz CALLS (state/outcome feed nothing); current = latest tagged node with consecutive duplicates collapsed, visited = earlier distinct stays (a revisit stays in both — current wins at render). PlanTree is structure-only; currentNodeId/doneNodeIds and the dead mutation helpers are gone. No fallback current. - Prompts split per agent (prompts/prober/, prompts/teacher/ over the trimmed shared base); graph-context injection removed entirely (shelved, docs/probe-teach-split.md §5); knowledge-graph context no longer reaches either agent. - Plan blocks are full-only snapshots at plan_init (neighborhood machinery retired; the persistent DAG window is the future UI wave); usage capture unchanged. Gates: tsc clean, 294/294 tests (phases/plan-tree/plan-blocks/question- tools rewritten to the new semantics; probe-done + handoff-wake tests added), lint, build. Live GLM smoke PASS: prober concluded with an honest assessment, teacher auto-woke, authored a 10-node plan with the block attached, then tagged checks on slope-instinct → secant derived current/ visited exactly as designed; grading honest both ways (driver off-by-one proved a wrong answer grades false).
This commit is contained in:
@@ -3,6 +3,7 @@ import type { ArtifactPartProps } from "@/src/core";
|
||||
import { DemoCard } from "@/components/artifacts/demo-card";
|
||||
import { JobCard } from "@/components/artifacts/job-card";
|
||||
import { VisualCard } from "@/components/artifacts/visual-card";
|
||||
import { ProbeDoneCard } from "@/components/artifacts/probe-done-card";
|
||||
|
||||
/**
|
||||
* Artifact renderer registry — the extension point for tool-part UI.
|
||||
@@ -24,4 +25,7 @@ export const artifactRenderers: Record<string, ComponentType<ArtifactPartProps>>
|
||||
// Artifacts (W6 fills in the components):
|
||||
demo: DemoCard,
|
||||
visual: VisualCard,
|
||||
// The probe conclusion: the assessment belongs to the learner as much as
|
||||
// to the transcript (docs/probe-teach-split.md §2). Plain v1 card.
|
||||
probe_done: ProbeDoneCard,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
"use client";
|
||||
|
||||
import { ClipboardCheckIcon } from "lucide-react";
|
||||
import type { ProbeDoneResult, ProbeDoneInput } from "@/src/core";
|
||||
|
||||
/**
|
||||
* The probe conclusion card (docs/probe-teach-split.md §2): renders the
|
||||
* prober's probe_done call. The INPUT is the learner assessment — strand by
|
||||
* strand, where his edge sits — and it belongs to the learner as much as to
|
||||
* the transcript: it streams live while the prober writes it and stays as
|
||||
* the handoff artifact. The OUTPUT is the seam's ack (ok) or the refusal
|
||||
* the prober retried on (rendered quiet and small — it is model-facing
|
||||
* bookkeeping, kept only for transcript honesty).
|
||||
*
|
||||
* Deliberately plain v1: the proper assessment viewer design is deferred to
|
||||
* the UI wave; this card just guarantees the data is never invisible.
|
||||
*/
|
||||
export function ProbeDoneCard({ part }: { part: { input?: unknown; output?: unknown } }) {
|
||||
const input = part.input as ProbeDoneInput | undefined;
|
||||
const output = part.output as ProbeDoneResult | undefined;
|
||||
const assessment = output?.ok ? output.assessment : (input?.assessment ?? null);
|
||||
|
||||
return (
|
||||
<div data-testid="probe-done-card" className="my-3 rounded-xl border bg-card/60 p-3">
|
||||
<div className="mb-2 flex items-center gap-2 text-xs font-medium uppercase tracking-wide text-muted-foreground">
|
||||
<ClipboardCheckIcon className="size-3.5 text-primary" />
|
||||
Probe concluded — your assessment
|
||||
</div>
|
||||
{output && !output.ok ? (
|
||||
<p className="text-sm text-muted-foreground">The prober retried: {output.error}</p>
|
||||
) : assessment ? (
|
||||
<div className="space-y-2">
|
||||
{assessment.strands.map((s, i) => (
|
||||
<div key={i} className="rounded-lg bg-background/60 px-3 py-2">
|
||||
<div className="text-sm font-medium">{s.strand}</div>
|
||||
<div className="mt-0.5 text-sm text-muted-foreground">{s.assessment}</div>
|
||||
</div>
|
||||
))}
|
||||
{assessment.summary && (
|
||||
<p className="px-1 text-sm text-muted-foreground">{assessment.summary}</p>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<p className="text-sm text-muted-foreground">Writing the assessment…</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+16
-36
@@ -14,9 +14,7 @@ import { derivedNodeStatus, derivePlanStatuses } from "@/src/core";
|
||||
* - kind "full": the whole DAG, BORDERLESS — no wrapping chrome, the SVG
|
||||
* scales to the full column width (viewBox = layout extent, so the
|
||||
* leftmost/rightmost nodes hug the edges), natural height, no cap.
|
||||
* - kind "neighborhood": the fragment in its own small container, labeled
|
||||
* as a FRAGMENT (clearly not the whole plan), the current node glowing.
|
||||
* - Clicking either opens the full plan in a full-screen popup overlay —
|
||||
* - Clicking opens the full plan in a full-screen popup overlay —
|
||||
* the LIVE plan: the latest tree from the transcript with statuses
|
||||
* derived at click time (contracts/plan.ts derivePlanStatuses). Blocks
|
||||
* are frozen snapshots rendered exactly as carried (never re-derived);
|
||||
@@ -134,12 +132,12 @@ export function wrapTitle(title: string, maxChars = 20, maxLines = 2): string[]
|
||||
// ─── Status styling (the retired panel's color language, unchanged) ──────────
|
||||
|
||||
const BOX: Record<PlanNodeStatus, string> = {
|
||||
done: "fill-phase-teach/10 stroke-phase-teach/50",
|
||||
visited: "fill-phase-teach/10 stroke-phase-teach/50",
|
||||
current: "fill-primary/10 stroke-primary",
|
||||
upcoming: "fill-card stroke-border",
|
||||
};
|
||||
const TEXT: Record<PlanNodeStatus, string> = {
|
||||
done: "fill-muted-foreground text-xs",
|
||||
visited: "fill-muted-foreground text-xs",
|
||||
current: "fill-foreground text-xs font-medium",
|
||||
upcoming: "fill-muted-foreground/80 text-xs",
|
||||
};
|
||||
@@ -236,43 +234,25 @@ function PlanDiagram({
|
||||
|
||||
/**
|
||||
* A persisted plan-block part, rendered as carried (snapshot statuses,
|
||||
* never re-derived). Full = borderless and column-filling; neighborhood =
|
||||
* a labeled fragment container with the current node glowing. Either
|
||||
* opens the live plan popup.
|
||||
* never re-derived): borderless and column-filling, it opens the live plan
|
||||
* popup. Full-only by design since the 2026-09-11 pivot (the neighborhood
|
||||
* fragments are retired — position derives live in the popup and the
|
||||
* future DAG window).
|
||||
*/
|
||||
export function PlanBlock({ data, onOpen }: { data: PlanBlockData; onOpen: () => void }) {
|
||||
const markerId = useId().replace(/[^a-zA-Z0-9-]/g, "");
|
||||
const statusMap = useMemo(() => new Map(data.nodes.map((n) => [n.id, n.status] as const)), [data]);
|
||||
const statusOf = (id: string): PlanNodeStatus => statusMap.get(id) ?? "upcoming";
|
||||
|
||||
if (data.kind === "full") {
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
data-testid="plan-block-full"
|
||||
onClick={onOpen}
|
||||
title="Open the full plan"
|
||||
className="block w-full text-left"
|
||||
>
|
||||
<PlanDiagram nodes={data.nodes} edges={data.edges} statusOf={statusOf} markerId={markerId} />
|
||||
</button>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<div data-testid="plan-block-neighborhood" className="rounded-xl border bg-card/60 p-2.5">
|
||||
<div className="mb-1.5 px-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground">
|
||||
Plan fragment
|
||||
</div>
|
||||
<button type="button" onClick={onOpen} title="Open the full plan" className="block w-full text-left">
|
||||
<PlanDiagram
|
||||
nodes={data.nodes}
|
||||
edges={data.edges}
|
||||
statusOf={statusOf}
|
||||
glowId={data.current}
|
||||
markerId={markerId}
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
data-testid="plan-block-full"
|
||||
onClick={onOpen}
|
||||
title="Open the full plan"
|
||||
className="block w-full text-left"
|
||||
>
|
||||
<PlanDiagram nodes={data.nodes} edges={data.edges} statusOf={statusOf} markerId={markerId} />
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user