Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (codex r3): stale detection, no-op fix, SSE recovery, cross-series race
[._.]/ Adam Eivy80a280b25863
diff --git a/PLAN.md b/PLAN.mdindex bd787d83c2..97c2455b41 100644--- a/PLAN.md+++ b/PLAN.md@@ -70,3 +70,6 @@ by `/do:replan --issues`:- [ ] **Parallelize the foundation judge + canon readiness with the editorial-checks pass in `runSeriesReview`** (`server/services/pipeline/seriesReview.js`). Today foundation (a full LLM round-trip) runs to completion before `runEditorialChecks` even starts, and canon sits idle until checks finish; only the seed→read chain (feedback-seed → checks-seed → health/getReview) is a real ordering constraint. `judgeFoundation` writes only its own snapshot and `checkSeriesCanonReadiness` is store-independent, so both can be kicked off at function entry and awaited just before `computeReviewVerdict`. Deferred from the /simplify pass because it changes the SSE progress-frame ordering (foundation/canon `step:*` frames would interleave with `check:*` frames) — needs the progress emits moved to kickoff/settle and a quick UX check that the interleaved stream still reads cleanly. Largest wall-clock win (~the foundation-judge duration).- [ ] **Hoist the pipeline `port-error/port-warning` severity palette to a shared export** and use it in `SeriesReviewPanel.jsx` (`SEVERITY_STYLES`), `AutopilotPanel.jsx` (`SEVERITY_COLORS`), and `ArcCanvas.jsx` — three byte-for-byte inline copies today. Candidate home: `client/src/components/pipeline/manuscript/constants.js`. Deferred from /simplify because it touches two files outside the #2664 diff.++- [ ] **Broaden series-review snapshot invalidation beyond the findings store.** `getSeriesReview` now stamps `stale` when the live open-finding set diverges from the snapshot's `findingIds` (covers accept/dismiss via a "Fix here" link). It does NOT detect edits to manuscript text, canon, or foundation made through other paths (the verdict's foundation/canon/health dimensions can go stale silently). Follow the `foundationJudge` pattern: stamp a `sourceInputsHash` on the review snapshot and recompute-vs-current on GET so any reviewed-source change flips `stale`. Deferred from #2664 review (codex r3, P1) as a broader pre-existing-pattern change.+- [ ] **Series-review: reject conflicting in-flight review options instead of silently coalescing.** `startSeriesReviewRun` coalesces by seriesId, so a second start with different feedback/provider/force/gate gets the running run's id and its options are dropped. Single-user/single-tab this is rare (the button disables while reviewing) and the client no longer clears the note on an `alreadyRunning` response — but a `createSseRunner` `sig`-based conflict (like storyBuilderRunner) would surface it. Deferred from #2664 review (codex r3, P2) — competing-actor/multi-tab hardening the single-user trust model largely excludes.diff --git a/client/src/components/pipeline/SeriesReviewPanel.jsx b/client/src/components/pipeline/SeriesReviewPanel.jsxindex 07c263472c..e4c7364d25 100644--- a/client/src/components/pipeline/SeriesReviewPanel.jsx+++ b/client/src/components/pipeline/SeriesReviewPanel.jsx@@ -106,22 +106,28 @@ export default function SeriesReviewPanel({ series, onSeriesUpdate, onIssuesUpdaconst reviewRunIdRef = useRef(null);const fixRunIdRef = useRef(null);+ // The series this panel currently represents — used to drop a late-resolving+ // verdict response from a series the user has already switched away from.+ const activeSeriesRef = useRef(seriesId);+ activeSeriesRef.current = seriesId;const onSeriesUpdateRef = useRef(onSeriesUpdate);const onIssuesUpdateRef = useRef(onIssuesUpdate);onSeriesUpdateRef.current = onSeriesUpdate;onIssuesUpdateRef.current = onIssuesUpdate;- const { latest: reviewLatest, frames: reviewFrames } = usePipelineProgress(+ const { latest: reviewLatest, frames: reviewFrames, closed: reviewClosed } = usePipelineProgress(pipelineSeriesReviewSseUrl, [seriesId], { enabled: reviewing },);- const { latest: fixLatest } = usePipelineProgress(+ const { latest: fixLatest, closed: fixClosed } = usePipelineProgress(pipelineSeriesFixSseUrl, [seriesId], { enabled: fixing },);const loadVerdict = useCallback(async () => {if (!seriesId) return;const res = await getPipelineSeriesReview(seriesId, { silent: true }).catch(() => null);- if (!res) return;+ // Drop a response that resolved after the user switched series (P2) — the+ // request was bound to `seriesId`, so compare it against the live series.+ if (!res || activeSeriesRef.current !== seriesId) return;// Always adopt the server's verdict (including null) so switching to a series// with no stored review clears the previous series' findings (P2).setReview(res.review ?? null);@@ -176,12 +182,20 @@ export default function SeriesReviewPanel({ series, onSeriesUpdate, onIssuesUpdaif (fixRunIdRef.current && fixLatest.runId && fixLatest.runId !== fixRunIdRef.current) return;setFixing(false);if (fixLatest.type === 'complete') {- getPipelineSeries(seriesId, { silent: true }).then((s) => { if (s) onSeriesUpdateRef.current?.(s); }).catch(() => null);- listPipelineIssues(seriesId, { silent: true }).then((is) => onIssuesUpdateRef.current?.(Array.isArray(is) ? is : [])).catch(() => null);- setReview(null);- setConfirmDismissed(false);const fixed = fixLatest.fixed ?? 0;- toast.success(`Fixed ${fixed} of ${fixLatest.total ?? 0} — re-review to confirm${fixLatest.budgetStopped ? ' (stopped: daily budget reached)' : ''}`);+ if (fixed > 0) {+ // Fixes landed — the manuscript + findings changed, so the verdict is+ // stale; clear it and prompt a re-review to confirm.+ getPipelineSeries(seriesId, { silent: true }).then((s) => { if (s) onSeriesUpdateRef.current?.(s); }).catch(() => null);+ listPipelineIssues(seriesId, { silent: true }).then((is) => onIssuesUpdateRef.current?.(Array.isArray(is) ? is : [])).catch(() => null);+ setReview(null);+ setConfirmDismissed(false);+ toast.success(`Fixed ${fixed} of ${fixLatest.total ?? 0} — re-review to confirm${fixLatest.budgetStopped ? ' (stopped: daily budget reached)' : ''}`);+ } else {+ // Nothing was applied (all unanchorable / budget stopped first) — KEEP the+ // findings visible instead of clearing them, and warn (not a success).+ toast.warning(`No fixes could be auto-applied (${fixLatest.total ?? 0} finding(s))${fixLatest.budgetStopped ? ' — daily budget reached' : ' — patch them from each finding instead'}.`);+ }} else if (fixLatest.type === 'rejected') {toast.error(fixLatest.mode === 'dry-run'? 'Fixing is preview-only right now (CoS auto-run is in dry-run) — set it to execute to apply fixes.'@@ -193,6 +207,24 @@ export default function SeriesReviewPanel({ series, onSeriesUpdate, onIssuesUpda}}, [fixing, fixLatest, seriesId]);+ // Recover when an SSE stream closes WITHOUT a terminal frame (the runner was+ // pruned / the endpoint 404'd before we attached) — otherwise reviewing/fixing+ // stays true forever and the controls are stuck disabled (P2). The terminal+ // frame, when it does arrive, is handled by the effects above; this only fires+ // for the no-terminal-frame close.+ useEffect(() => {+ if (reviewing && reviewClosed && !(reviewLatest && RUN_ENDED.has(reviewLatest.type))) {+ setReviewing(false);+ loadVerdict();+ }+ }, [reviewing, reviewClosed, reviewLatest, loadVerdict]);+ useEffect(() => {+ if (fixing && fixClosed && !(fixLatest && FIX_RUN_ENDED.has(fixLatest.type))) {+ setFixing(false);+ loadVerdict();+ }+ }, [fixing, fixClosed, fixLatest, loadVerdict]);+const runReview = useCallback(async () => {setStarting(true);// Only submit feedback while the textarea is actually shown (before the first@@ -205,8 +237,9 @@ export default function SeriesReviewPanel({ series, onSeriesUpdate, onIssuesUpdaif (!res) return;// The note has now been consumed by this run — clear it so a later re-review// (after fixes clear `review`, re-showing the textarea) can't silently re-seed- // the same note as a fresh duplicate finding.- if (body.feedback) setFeedback('');+ // the same note as a fresh duplicate finding. Don't clear when the server+ // coalesced onto an already-running review (the note wasn't actually taken).+ if (body.feedback && !res.alreadyRunning) setFeedback('');reviewRunIdRef.current = res.runId || null;setReviewing(true);}, [seriesId, feedback, review]);@@ -245,6 +278,16 @@ export default function SeriesReviewPanel({ series, onSeriesUpdate, onIssuesUpdaconst hasFixableFindings = (review?.findings?.length || 0) > 0;const canFix = fixAvail?.canFix !== false;const showConfirm = hasIssues && !confirmDismissed && !fixing && !reviewing;+ // Name the blockers behind an 'issues' verdict with zero listed findings, so+ // the headline never contradicts itself with "0 issue(s)" (P2).+ const nonFindingBlockers = [];+ if (review) {+ if (review.foundation && Number.isFinite(review.foundation.weightedScore)+ && review.foundation.weightedScore < (review.foundationThreshold ?? 7.5)) nonFindingBlockers.push('foundation');+ if (review.canon && review.canon.ready === false) nonFindingBlockers.push('canon');+ if (review.health && review.health.ready === false) nonFindingBlockers.push('health');+ if (review.incomplete) nonFindingBlockers.push('incomplete review');+ }return (<div className="border border-port-border rounded-lg bg-port-card/40">@@ -318,10 +361,25 @@ export default function SeriesReviewPanel({ series, onSeriesUpdate, onIssuesUpda{review.verdict === 'ready' ? (<><CheckCircle2 size={15} className="text-port-success" /><span className="text-port-success">Looks ready to move forward.</span></>) : (- <><AlertTriangle size={15} className="text-port-warning" /><span className="text-port-warning">{review.findingCount || 0} issue(s) to address before moving forward.</span></>+ <><AlertTriangle size={15} className="text-port-warning" /><span className="text-port-warning">+ {review.findingCount > 0+ ? `${review.findingCount} issue(s) to address before moving forward.`+ : (nonFindingBlockers.length+ ? `Blocked by ${nonFindingBlockers.join(', ')} — address before moving forward.`+ : 'Not ready to move forward yet.')}+ </span></>)}</div>+ {/* Stale banner — the findings changed since this verdict (e.g. a+ finding was fixed/dismissed via "Fix here"), so it's out of date. */}+ {review.stale ? (+ <p className="text-[11px] text-port-warning flex items-center gap-1.5">+ <AlertTriangle size={12} />+ The findings changed since this review ran — re-review for an up-to-date verdict.+ </p>+ ) : null}+{/* Signal chips */}<div className="flex flex-wrap gap-2 text-[11px]">{review.foundation && Number.isFinite(review.foundation.weightedScore) ? (diff --git a/server/services/pipeline/seriesReview.js b/server/services/pipeline/seriesReview.jsindex 883e100549..ff3e0eaaa8 100644--- a/server/services/pipeline/seriesReview.js+++ b/server/services/pipeline/seriesReview.js@@ -338,8 +338,16 @@ export async function runSeriesReview(seriesId, {failedStages,checksErrored,erroredCheckIds,+ // The open-finding comment ids this verdict was computed from — so a later+ // GET can detect that the review is stale (findings were accepted/dismissed,+ // e.g. via a "Fix here" link) without re-running.+ findingIds: findings.map((f) => f.commentId),hadFeedback: !!(feedback && String(feedback).trim()),};+ // Don't persist (or return) a verdict for a run the user canceled mid-flight —+ // the SSE wrapper will broadcast `canceled`, and a reload must not restore a+ // verdict from a run that never finished.+ if (aborted()) return null;await saveSnapshot(result);console.log(`🔎 series review — series=${seriesId.slice(0, 12)} verdict=${verdict} findings=${findings.length} foundation=${foundation?.weightedScore ?? '—'} health=${health?.score ?? '—'}`);return result;@@ -365,6 +373,13 @@ async function clearSnapshot(seriesId) {* Read the last stored review verdict for a series (null when never run). Also* reports whether the FIX path is currently available (cos-domain autonomy):* with the domain `off`, review still works read-only but fixing is disabled.+ *+ * Stamps a `stale` flag when the live open-finding set no longer matches the+ * snapshot's `findingIds` — i.e. findings were accepted/dismissed since (e.g. via+ * a "Fix here" link) or new findings appeared — so a reload can warn the verdict+ * is out of date instead of presenting it as current. (This covers the+ * findings-store drift this feature introduces; foundation/canon/manuscript edits+ * through other paths are a broader pre-existing concern tracked in PLAN.md.)*/export async function getSeriesReview(seriesId) {assertValidSeriesId(seriesId);@@ -372,7 +387,16 @@ export async function getSeriesReview(seriesId) {const verdict = content === null? null: safeJSONParse(content, null, { allowArray: false, logError: true, context: snapshotPath(seriesId) });- const fix = await getFixAvailability();+ const [fix, review] = await Promise.all([+ getFixAvailability(),+ verdict ? getReview(seriesId).catch(() => ({ comments: [] })) : Promise.resolve(null),+ ]);+ if (verdict && review) {+ const liveOpen = new Set(collectReviewFindings(review.comments).map((f) => f.commentId));+ const snapshotIds = Array.isArray(verdict.findingIds) ? verdict.findingIds : (verdict.findings || []).map((f) => f?.commentId).filter(Boolean);+ const stale = snapshotIds.length !== liveOpen.size || snapshotIds.some((id) => !liveOpen.has(id));+ verdict.stale = stale;+ }return { review: verdict, fix };}