From fa767b913736aff82e9e5fe53fad8c6611eee783 Mon Sep 17 00:00:00 2001 From: Snarkimedes Date: Sun, 29 Nov 2026 21:01:33 +0000 Subject: [PATCH] fix(diagnostics): keep advisory evidence out of health warnings --- docs/diagnostics.md | 15 +++-- docs/user-guide.md | 12 +++- openspec/specs/workflow-access/spec.md | 17 +++--- src/diagnostics.ts | 53 +++++++--------- tests/host-diagnostic-collection.test.ts | 7 ++- tests/host-diagnostic-native-evidence.test.ts | 7 ++- tests/host-diagnostic-rendering.test.ts | 60 ++++++++++++------- 7 files changed, 98 insertions(+), 73 deletions(-) diff --git a/docs/diagnostics.md b/docs/diagnostics.md index a744665..1ecdf9b 100644 --- a/docs/diagnostics.md +++ b/docs/diagnostics.md @@ -103,10 +103,9 @@ native memory delivery. | --- | --- | --- | | bd CLI | Native `bd version`: version, below-minimum version (`needs ≥1.3.1`), `not found`, or not observed. | Unsupported/unavailable is unhealthy; failed version evidence can be neutral. Install/upgrade in an authorized workflow and start a new session; check `bd version`. The qualified baseline is 1.3.4, not a maximum. | | Workspace | Config-only `bd context --json`: `Located`, `Not initialized`, `Probe failed`, `Withheld` or not observed. | Located identifies native-resolved context, not integrity. Failed/withheld/uninitialized is unhealthy; absent evidence neutral. Inspect context/location evidence; initialization is human-directed, never automatic repair. | -| Recorded bd version | Bounded `.local_version` under the resolved `beads_dir`. | `1.3.4 = CLI` is healthy; `1.3.1 ≠ CLI 1.3.4` is mismatch. `none`, unreadable, truncated, unsupported, unavailable or running-version unavailable stays neutral. Compare the recorded value and `bd version`; review native upgrade guidance if they differ. | +| Recorded bd version | Bounded `.local_version` under the resolved `beads_dir`. | `1.3.4 = CLI` and `1.3.1 ≠ CLI 1.3.4` are informational and do not affect health or counts. `none`, unreadable, truncated, unsupported, unavailable or running-version unavailable stays neutral. Compare the recorded value and `bd version`; review native upgrade guidance if they differ, not sync or migration steps. | | Git hooks | Qualified native `bd hooks list --json`. | Installed/total counts include shims. Optional missing/unreadable/unresolved hooks and empty, failed or withheld evidence are neutral. Outdated or unrecognized installed hooks are mismatch. Review layout and customization before installation, then verify with `bd hooks list`. | | Sync target | Config-only native context and strict-readonly native Dolt remote listing. | `Resolved · origin` means the native default name is listed in a supported direct Dolt context. `Local-only` means an empty listing in a confirmed embedded store. Both are healthy target observations. Missing, failed or ambiguous evidence leaves the target `Unknown` and neutral. | -| Remote history | Availability of a fresh Beads comparison. | `Not applicable` for established local-only operation and `Not checked` otherwise. Both are neutral. Exact remote selectors explain the unavailable probe. | ### Version witnesses @@ -145,10 +144,14 @@ are discarded before capture. A registered `origin` establishes the target name only. Reachability and synchronization remain unmeasured. Local-only describes the current embedded store. Native push may offer Git-origin -adoption with consent. The history comparison is unperformed on Beads 1.3.1 and -1.3.4. No qualified native probe establishes that a comparison uses the remote -branch fetched during that invocation. Diagnostics leaves cached counts out of -the report. Source-Git freshness remains unchecked in all views. +adoption with consent. Ordinary diagnostics omits the Remote history row and +caveat. `details` explains once that the local target observation is not a +fresh history comparison: history is `Not applicable` for established +local-only operation and `Not checked` otherwise. Exact `remote` and +`details remote` still request a fresh comparison and report why it is +unavailable on Beads 1.3.1 and 1.3.4: no qualified native probe binds a +comparison to the remote branch fetched in that invocation. No history is +fetched, cached counts are omitted, and source-Git freshness is not checked. ## Collection and native responsibility diff --git a/docs/user-guide.md b/docs/user-guide.md index 0354666..30ba448 100644 --- a/docs/user-guide.md +++ b/docs/user-guide.md @@ -99,7 +99,7 @@ If `bd` is unavailable or the project is uninitialized, nothing is added. If `bd Before prime and typed operations, the plugin checks `bd version` against minimum 1.3.1 and uses the configuration-only `bd context --json` workspace probe. These checks do not open the store. A missing workspace differs from a failed or unsupported probe; the latter is reported without substituting a store-opening command. -Diagnostics may read a bounded `.local_version` witness as an advisory recorded CLI value; neither a match nor a difference establishes schema state, completed maintenance or pending migrations. Admission and ordinary context loading do not read the witness. Native Beads owns schema bounds, store opening, migrations and upgrade/adoption semantics. Ordinary `bd prime --full` includes native persistent memories and may open or migrate a local store according to native behavior. The plugin does not guarantee migration-free context. An OpenCode session can be the first native store open after a `bd` upgrade; follow the native backup-before-upgrade procedure linked below. A successful prime can include a native partial-availability notice; its output is preserved and success does not certify complete memory delivery or store health. +Diagnostics may read a bounded `.local_version` witness as an informational recorded CLI value. Neither equality nor difference affects health or admission or establishes schema state, completed maintenance or pending migrations. A difference points to native upgrade guidance, not sync or migration; a genuinely unavailable or incompatible running CLI is still unhealthy. Admission and ordinary context loading do not read the witness. Native Beads owns schema bounds, store opening, migrations and upgrade/adoption semantics. Ordinary `bd prime --full` includes native persistent memories and may open or migrate a local store according to native behavior. The plugin does not guarantee migration-free context. An OpenCode session can be the first native store open after a `bd` upgrade; follow the native backup-before-upgrade procedure linked below. A successful prime can include a native partial-availability notice; its output is preserved and success does not certify complete memory delivery or store health. Follow the [Beads 1.3.4 upgrade procedure](https://github.com/gastownhall/beads/blob/7ef2fd05eb0cd3bdbde051f93cfc14ccf270cdde/docs/getting-started/upgrading.md), including backup with the old binary before upgrading and coordination for shared stores. The plugin does not run automatic migration, repair, bootstrap, update or synchronization commands. Agent-initiated administration still requires an explicit applicable request and normal permissions. Native open semantics do not grant extra administrative authority. @@ -117,7 +117,7 @@ Diagnostics shows compact Plugin / Beads tables with short rows including AGENTS Use `/oc-beads:diagnostics details` for bounded evidence, including raw marker/request counts and times, command clipping and per-hook entries. Use `/oc-beads:diagnostics help` for a self-contained static reference that skips diagnostic collection. Selectors are exact after trimming and case folding; other prose remains literal input and selects normal output. Every view is captured once and reused on primary/compaction replay. New captures supply finished code-populated Markdown inside explicit report boundaries, with real newline separation before the unchanged invocation; the relay instruction requests only that report. Older snapshots retain their original instructions. This framing preserves deterministic input values without guaranteeing the model's visible output. Normal captures omit full evidence and routine provisos; real unresolved writes still appear. The subsequent ordinary prompt can still load full native prime and memories. See the [diagnostics reference](diagnostics.md) for every row, state, source, remedy and check. -Git hooks, Sync target and Remote history are independent observations. The target listing opens supported native stores in strict-readonly mode. Server mode may connect to the configured database. On Beads 1.3.1 and 1.3.4, exact `remote` and `details remote` explain that a qualified fresh history comparison is unavailable. No selector fetches history or contacts the sync remote. History is `Not applicable` for a confirmed local-only store and `Not checked` otherwise. +Git hooks and Sync target are independent local observations. Ordinary diagnostics omits the Remote history row and caveat. `details` explains once that target evidence is not a fresh history comparison: history is `Not applicable` for an established local-only store and `Not checked` otherwise. Exact `remote` and `details remote` still request a comparison and explain why it is unavailable on Beads 1.3.1 and 1.3.4. On those versions no selector fetches history or contacts the sync remote. The target listing opens supported native stores in strict-readonly mode; server mode may connect to the configured database. Starting with beta.2, the package-owned `oc-beads:status` is removed without an alias. Use `oc-beads:diagnostics` for integration health and `oc-beads:stats` for the issue-database overview via `bd status` (alias `bd stats`). User-defined old status overrides are untouched and are not migrated. @@ -129,6 +129,14 @@ The normal public entrypoint enables the eleven qualified operations in the nati Each operation asks for its exact `bd` command with `save: []`, so "always" adds no new saved grant and you may be asked again. Existing shell `bd *` grants can authorize equivalent operations; configured denies still win. Results preserve partial, failed and uncertain outcomes rather than retrying. A rejected nested operation does not run, but later operations keep their own checks. Use explicit Stop/Cancel to end the composition. Read [CODE_MODE.md](../assets/oc-beads/resources/CODE_MODE.md) for composition and recovery. +### Read-only smoke prompt + +> Use the typed `beads.find` operation with `{"view":"ready","limit":5}`. +> Report the ready IDs actually returned and the exact `find.complete` +> value (`true`, `false`, or `null`). If the call fails or is unavailable, +> say so and report only values actually returned. Do not claim, modify, +> or sync anything. + ## Task agent The current task agent (`beads-task-agent`) uses scope-bounded task execution: diff --git a/openspec/specs/workflow-access/spec.md b/openspec/specs/workflow-access/spec.md index 8fa24dd..7e995fc 100644 --- a/openspec/specs/workflow-access/spec.md +++ b/openspec/specs/workflow-access/spec.md @@ -477,7 +477,7 @@ Diagnostics SHALL render fixed compact Markdown Plugin / Beads tables and labele - **THEN** normal output distinguishes known integration failures as unhealthy, observed setup differences as mismatch and incomplete observations as neutral fields; explicit details retains producer, scope, observation time, meaning and limits - **AND** normal output has no default provisos or limits line; conditional short actions state useful effects and a check, while detailed explanations are available on request - **AND** section and overall severity use unhealthy > mismatch > healthy, neutral fields are visible but excluded from severity and heading counts, and no assessed checks remains neutral -- **AND** header metadata places DATE, VERSION and PATH in separate rendered paragraphs immediately after the title and before the summary, without repeating them at the bottom; DATE uses exact capture time, VERSION the executing manifest name/version, and PATH observed native cwd_repo_root or explicit not observed, without inference, path stripping, slash appending or implicit cwd fallback; native beads_dir remains in details and observed host/CLI versions stay in their rows; unmeasured schema/maintenance rows and default persistence uncertainty are omitted while actual unresolved writes remain concise; Git hooks, Sync target and Remote history are the three remote-related rows, including neutral target/history observations +- **AND** header metadata places DATE, VERSION and PATH in separate rendered paragraphs immediately after the title and before the summary, without repeating them at the bottom; DATE uses exact capture time, VERSION the executing manifest name/version, and PATH observed native cwd_repo_root or explicit not observed, without inference, path stripping, slash appending or implicit cwd fallback; native beads_dir remains in details and observed host/CLI versions stay in their rows; unmeasured schema/maintenance rows and default persistence uncertainty are omitted while actual unresolved writes remain concise; ordinary tables retain Git hooks and Sync target, but omit the Remote history row and routine remote-history caveat - **AND** success is limited to the observed check; neither a loaded version label nor an admitted version is evidence of unique build identity or fresh live qualification #### Scenario: Native hook report is available @@ -498,13 +498,14 @@ Diagnostics SHALL render fixed compact Markdown Plugin / Beads tables and labele #### Scenario: CLI witness is inspected - **WHEN** a local CLI version witness is readable alongside an observed CLI version -- **THEN** the Recorded bd version row shows the bounded recorded value; the value states equality or difference from the CLI without history inference; equality is healthy, difference is mismatch rather than unhealthy, and missing/unreadable/unsupported values remain neutral literal fields -- **AND** neither equality nor difference establishes SQL schema, reconciliation, hook freshness or maintenance completion, produces migration advice, or affects context or typed-operation admission +- **THEN** the Recorded bd version row shows the bounded recorded value; the value states equality or difference from the CLI without history inference; equality and difference are informational, and missing/unreadable/unsupported values remain neutral literal fields; none affects severity or heading counts +- **AND** a difference points to native upgrade guidance, not sync or migration advice; neither result establishes SQL schema, reconciliation, hook freshness or maintenance completion or affects context or typed-operation admission +- **AND** a genuinely unavailable or incompatible running CLI remains an unhealthy CLI finding under the unchanged admission rules #### Scenario: Remote or historical maintenance freshness is requested - **WHEN** diagnostics has only local evidence -- **THEN** normal output shows Sync target from the available native evidence and Remote history as Not checked, or Not applicable only for established local-only operation; details identifies missing evidence and states source-Git freshness is not checked +- **THEN** normal output shows Sync target from the available native evidence without a Remote history row or caveat; exact `details` explains once that local target evidence is not a fresh history comparison, distinguishing established Local-only (comparison not applicable) from other targets (comparison not checked), and does not imply source-Git freshness was checked - **AND** configured remote presence is a bounded hint without URL or credentials, never proof of effective resolution, connectivity or freshness; absent config fields and absent hooks establish neither local-only operation nor failure - **AND** ordinary collection uses strict-readonly native remote listing without sync-remote contact, fetch, pull, synchronization or a custom resolver - **AND** release-note maintenance applicability and completion remain unmeasured; details points to reviewable native release guidance rather than prescribing a sequential SQL migration chain @@ -512,7 +513,7 @@ Diagnostics SHALL render fixed compact Markdown Plugin / Beads tables and labele #### Scenario: Normal and requested details are captured once - **WHEN** diagnostics is invoked normally or with an exact trimmed case-insensitive `details`, `help`, `remote` or `details remote` selector -- **THEN** exact `details` captures bounded evidence with the compact tables; exact `help` selects a static self-contained reference before collection, file reads or registry probes; exact `remote` and `details remote` request a comparison with normal tables or bounded evidence respectively, but report Not checked when no qualified producer is available and Not applicable for established local-only; bare or other text selects local normal tables without full evidence JSON +- **THEN** exact `details` captures bounded evidence with the compact tables; exact `help` selects a static self-contained reference before collection, file reads or registry probes; exact `remote` and `details remote` request a comparison with normal tables or bounded evidence respectively, but report Not checked when no qualified producer is available and Not applicable for established local-only; bare or other text selects local normal tables without full evidence JSON or a remote-history caveat - **AND** `details remote` evidence distinguishes a successful fresh Beads history comparison, an attempted failure and an unperformed comparison; it does not claim a completed comparison was not checked or imply that source-Git freshness was checked - **AND** exact free text, attachments/delivery, user overrides and the one-time v1 snapshot/replay path are preserved without recollection - **AND** static help explains markers, each row/source/state, useful remedies/checks and limits, links the repository diagnostics reference and preserves the ordinary subsequent prompt/prime lifecycle @@ -530,7 +531,7 @@ Diagnostics SHALL render fixed compact Markdown Plugin / Beads tables and labele - **WHEN** the report contains target/history observations alongside plugin and local Beads observations - **THEN** Local-only and Resolved assess only the target check; In sync assesses only a fresh successful history comparison; Unknown, Not checked and Not applicable are neutral and excluded from severity - **AND** Unresolved, Local ahead, Remote ahead, Diverged and an actually attempted Check failed contribute mismatch, not an automatic unhealthy local-store or Plugin verdict -- **AND** the existing worst-assessed-check roll-up is retained, with a concise summary saying Remote history not checked whenever applicable so a healthy heading cannot imply synchronization; no assessed checks remains neutral +- **AND** the existing worst-assessed-check roll-up is retained, without an ordinary remote-history caveat; the health heading assesses only observed checks, not synchronization, and no assessed checks remains neutral - **AND** Local ahead is described as unpublished work, with short review/sync-under-separate-authority actions and no corruption claim, automatic sync, retry, repair or migration advice ### Requirement: Managed guidance and skill visibility @@ -581,7 +582,7 @@ Diagnostics SHALL derive Local-only, Resolved or Unknown from native context and #### Scenario: Native listing establishes local-only operation - **WHEN** a complete successful native listing is empty in a confirmed embedded Dolt context -- **THEN** Sync target is Local-only and Remote history is Not applicable +- **THEN** Sync target is Local-only; `details` and explicit remote selectors distinguish history as Not applicable, not Not checked - **AND** details explains that native push may offer Git-origin adoption with consent; diagnostics never adopts a remote or promises permanent local-only operation #### Scenario: Target evidence is ambiguous or fails @@ -599,7 +600,7 @@ Only exact explicit remote selectors SHALL trigger a qualified native exact-bran #### Scenario: No fresh comparison is performed - **WHEN** the target is Local-only, no remote selector was requested, the target/context is unknown, unresolved or unsupported, or no qualified native exact-branch operation is available before spawn -- **THEN** Remote history is Not applicable for Local-only and otherwise Not checked with an unperformed/unsupported/withheld reason in details +- **THEN** explicit remote selectors report Remote history as Not applicable for Local-only and otherwise Not checked, with the unperformed/unsupported/withheld reason in bounded evidence when requested; ordinary output omits the row and caveat, and exact `details` conveys the distinction and any local evidence limits in one explanation - **AND** without a qualified native operation there is no fetch; Beads 1.3.1 and 1.3.4 have no qualified history probe, and exact remote selectors explain this limitation - **AND** ordinary/details remains local without fetch; known proxied-server mode is unsupported rather than an attempted history failure - **AND** `remote please`, reversed tokens or other non-exact selector text does not trigger a remote operation diff --git a/src/diagnostics.ts b/src/diagnostics.ts index 44b6ff0..8f96580 100644 --- a/src/diagnostics.ts +++ b/src/diagnostics.ts @@ -295,7 +295,7 @@ function assessRemote( locationWithheld: boolean, historyRequested: boolean, observedAt: string, -): { rows: Row[]; findings: Finding[]; summary?: string } { +): { row: Row; findings: Finding[]; requestedSummary?: string } { const localOnly = target?.state === "local-only"; const targetAssessed = target?.state === "resolved" || localOnly; const missingTarget = locationWithheld ? "session location unconfirmed" : "native listing not performed"; @@ -320,19 +320,12 @@ function assessRemote( const historyValue = localOnly ? "Not applicable" : "Not checked"; const historyUnavailable = "No qualified Beads history probe is available"; - let historyReason = "The invocation did not request a remote history comparison."; - if (localOnly) historyReason = "This embedded store has no registered native remotes."; + let historyReason = "The local sync target check does not compare history."; + if (localOnly) historyReason = "There is no registered native remote to compare."; else if (historyRequested) historyReason = `${historyUnavailable}.`; return { - rows: [ - ["Sync target", targetAssessed ? 0 : null, targetValue], - [ - "Remote history", - null, - historyRequested && !localOnly ? `${historyValue} · ${historyUnavailable}` : historyValue, - ], - ], + row: ["Sync target", targetAssessed ? 0 : null, targetValue], findings: [ { id: "sync-target", @@ -355,7 +348,7 @@ function assessRemote( meaning: `Comparison was not attempted. ${historyReason} Source-Git freshness was not checked.`, }, ], - summary: localOnly ? undefined : "Remote history not checked.", + requestedSummary: historyRequested ? `Remote history: ${historyValue}. ${historyReason}` : undefined, }; } @@ -426,17 +419,11 @@ function assessContext( function assessWitness( witness: BeadsHealthObservation["witness"] | undefined, observedAt: string, -): { row: Row; finding?: Finding } { +): { row: Row; finding?: Finding; action?: string } { const check = "Recorded bd version"; if (!witness) return { row: [check, null, "not observed"] }; - const describe = ( - id: string, - classification: FindingClass, - observation: string, - meaning: string, - action?: string, - ): Finding => ({ + const describe = (id: string, classification: FindingClass, observation: string, meaning: string): Finding => ({ id, module: "beads", class: classification, @@ -445,26 +432,26 @@ function assessWitness( observedAt, observation, meaning, - ...(action ? { action } : {}), }); switch (witness.state) { case "differ": return { - row: [check, 1, `${witness.recorded} ≠ CLI ${witness.running}`], + row: [check, null, `${witness.recorded} ≠ CLI ${witness.running}`], + action: + "Review the [Beads upgrade guide](https://github.com/gastownhall/beads/blob/7ef2fd05eb0cd3bdbde051f93cfc14ccf270cdde/docs/getting-started/upgrading.md) for the recorded version difference.", finding: describe( "witness-differs", - "review-needed", + "note", `Recorded ${witness.recorded} differs from running ${witness.running}`, "This is not evidence of schema, reconciliation, hook freshness or maintenance completion.", - "Read-only review: consult https://github.com/gastownhall/beads/blob/7ef2fd05eb0cd3bdbde051f93cfc14ccf270cdde/docs/getting-started/upgrading.md and compare the recorded and running values again; no migration is inferred.", ), }; case "match": return { - row: [check, 0, `${witness.recorded} = CLI`], + row: [check, null, `${witness.recorded} = CLI`], finding: describe( "witness-matches", - "ok", + "note", `Recorded ${witness.recorded} matches running ${witness.running}`, "A match does not establish schema or maintenance completion.", ), @@ -770,19 +757,20 @@ function interpretHealthReport(snapshot: DiagnosticsSnapshot, time: string) { if (guardAssessment.summary) comments.push(guardAssessment.summary); if (guardAssessment.action) actions.push(guardAssessment.action); beadsRows.push(witness.row); + if (witness.action) actions.push(witness.action); beadsRows.push(hooks.row); if (hooks.action) { comments.push("Git hooks need attention."); actions.push(hooks.action); } - beadsRows.push(...remote.rows); - const summary = [comments[0], remote.summary].filter(Boolean).join(" "); + beadsRows.push(remote.row); return { findings, pluginRows, beadsRows, actions, - summary, + summary: comments[0], + requestedHistorySummary: remote.requestedSummary, identity, repoRoot: guard?.workspace?.repoRoot, overallStatus: worstStatus([...pluginRows, ...beadsRows]), @@ -836,6 +824,7 @@ export function renderHealthReport(snapshot: DiagnosticsSnapshot, capturedAt: nu beadsRows, actions, summary, + requestedHistorySummary, identity, repoRoot, overallStatus, @@ -851,6 +840,7 @@ export function renderHealthReport(snapshot: DiagnosticsSnapshot, capturedAt: nu "", `PATH: ${formatInlineCode(repoRoot ?? "not observed")}`, ...(summary ? ["", summary] : []), + ...(!details && requestedHistorySummary ? ["", requestedHistorySummary] : []), "", `**Plugin** ${formatHeadingStatus(pluginStatus)}`, "", @@ -890,10 +880,11 @@ Use /oc-beads:diagnostics remote or /oc-beads:diagnostics details remote to requ | Write outcomes | Existing unresolved write evidence only (mismatch). Inspect actual operation/readback before any retry; this row is absent without a recorded gap. | | bd CLI | Native version observation: supported version, below minimum 1.3.1 or not found. Install/upgrade only in an authorized workflow; check bd version and a new session. | | Workspace | Config-only native context: Located, Not initialized, Probe failed, Withheld or not observed. Located identifies a directory, not database integrity. Review location/context evidence; onboarding is human-directed, never automatic repair. | -| Recorded bd version | Bounded .local_version under resolved beads_dir: equals CLI, differs from CLI (mismatch), none, unreadable, unsupported, truncated or unavailable (neutral). Compare bd version and the recorded value; review native upgrade guidance for a difference. This is no schema or maintenance diagnosis. | +| Recorded bd version | Neutral observation of bounded .local_version under resolved beads_dir: equals CLI, differs from CLI, none, unreadable, unsupported, truncated or unavailable. Review native upgrade guidance only for a difference. This is no schema or maintenance diagnosis. | | Git hooks | Native bd hooks list reports installation counts including shims. Missing/unreadable/unresolved optional hooks and empty/failed/withheld observations are neutral. Outdated and unrecognized installations are mismatches. Review hook identity, layout and customization before bd hooks install, which writes hooks and may change core.hooksPath. Verify with bd hooks list. This row covers installation only. | | Sync target | Native bd context --json and strict-readonly bd remote listing. Resolved means native origin is registered. Local-only means the native list is empty in a confirmed embedded store. Missing, failed or ambiguous evidence leaves the target Unknown. Review the evidence in details. Reachability remains unmeasured. | -| Remote history | Not applicable for Local-only, otherwise Not checked. Both states are neutral. Exact remote selectors explain the unavailable history probe. Source-Git freshness remains unmeasured. | + +Remote history is omitted from the normal report. Details record it as Not applicable for Local-only, otherwise Not checked. Exact remote selectors explain why no comparison is made. Source-Git freshness remains unmeasured. Below the title and before the summary, DATE is the exact capture timestamp, VERSION the executing package name/version, and PATH the observed native repository root (cwd_repo_root), each in a separate paragraph. Missing root is explicitly not observed; no root is inferred from beads_dir or session cwd. The Beads directory remains in details. Details retains raw command inventory/clipping, hook entries, root marker counts, last-request counts/times, context provenance and finding explanations. diff --git a/tests/host-diagnostic-collection.test.ts b/tests/host-diagnostic-collection.test.ts index b539eeb..3bba4ff 100644 --- a/tests/host-diagnostic-collection.test.ts +++ b/tests/host-diagnostic-collection.test.ts @@ -322,7 +322,12 @@ test("registered diagnostics handles exact selectors locally and replays capture [f.ctx.location.directory, ["--readonly", "dolt", "remote", "list", "--json", "--sandbox"]], ]); expect(framedReport).toContain("| Sync target | ✅ | Resolved · origin |"); - expect(framedReport).toContain("| Remote history | — | Not checked"); + expect(framedReport).not.toContain("| Remote history |"); + if (selector === "details" || selector === "details remote") { + expect(framedReport!.match(/Source-Git freshness was not checked/g)).toHaveLength(1); + } else if (selector !== "remote") { + expect(framedReport).not.toMatch(/Remote history|Source-Git freshness/); + } expect(framedReport!.includes("No qualified Beads history probe is available")).toBe( selector === "remote" || selector === "details remote", ); diff --git a/tests/host-diagnostic-native-evidence.test.ts b/tests/host-diagnostic-native-evidence.test.ts index e0f6654..0d2fdbe 100644 --- a/tests/host-diagnostic-native-evidence.test.ts +++ b/tests/host-diagnostic-native-evidence.test.ts @@ -31,7 +31,9 @@ test("registered diagnostics reports an embedded store with no native remotes or const report = metadata.ocBeadsWorkflow.instructions; expect(report).toContain("| Git hooks | — | 0/1 installed · 1 missing/unreadable/unresolved |"); expect(report).toContain("| Sync target | ✅ | Local-only |"); - expect(report).toContain("| Remote history | — | Not applicable |"); + expect(report).not.toContain("| Remote history |"); + expect(report).toContain('"observation":"Not applicable"'); + expect(report.match(/Source-Git freshness was not checked/g)).toHaveLength(1); expect(report).not.toContain("No qualified Beads history probe is available"); expect(report).toContain("Git-origin adoption with consent"); expect(report).toContain("Source-Git freshness was not checked"); @@ -144,7 +146,8 @@ test("registered diagnostics keeps incomplete or ambiguous native target evidenc }; const report = ocBeadsWorkflow.instructions; expect(report).toContain(`| Sync target | — | Unknown · ${example.reason} |`); - expect(report).toContain("| Remote history | — | Not checked · No qualified Beads history probe is available |"); + expect(report).not.toContain("| Remote history |"); + expect(report.match(/No qualified Beads history probe is available/g)).toHaveLength(1); expect(report).toContain("Comparison was not attempted"); expect(report).not.toMatch(/secret|Check failed|Unresolved|❌ Unhealthy/); expect(bd.mock.calls.slice(start).map(([, args]) => args)).toEqual([ diff --git a/tests/host-diagnostic-rendering.test.ts b/tests/host-diagnostic-rendering.test.ts index cb9268a..a814377 100644 --- a/tests/host-diagnostic-rendering.test.ts +++ b/tests/host-diagnostic-rendering.test.ts @@ -114,8 +114,6 @@ VERSION: @snarkipus/opencode-beads \`2.2.1\` PATH: \`/fixture\` -Remote history not checked. - **Plugin** ✅ Healthy | Check | Status | Value | @@ -133,15 +131,14 @@ Remote history not checked. |---|---|---| | bd CLI | ✅ | 1.3.4 | | Workspace | ✅ | Located | -| Recorded bd version | ✅ | 1.3.4 = CLI | +| Recorded bd version | — | 1.3.4 = CLI | | Git hooks | ✅ | 5/5 installed (shims) | -| Sync target | ✅ | Resolved · origin | -| Remote history | — | Not checked |`); +| Sync target | ✅ | Resolved · origin |`); expect(report).toContain("## Beads diagnostics — ✅ Healthy"); expect(report).toContain("**Plugin**"); expect(report).toContain("**Beads**"); expect(report).toContain("| Check | Status | Value |"); - expect(report).toContain("| Recorded bd version | ✅ | 1.3.4 = CLI |"); + expect(report).toContain("| Recorded bd version | — | 1.3.4 = CLI |"); expect(report).not.toMatch(/partial|Request instructions|Codex|descriptions/i); expect(report).not.toMatch( /Details:|Limits:|does not establish|model-mediated|unique build|liveQualification|no final-write guarantee|remote freshness/i, @@ -164,8 +161,6 @@ VERSION: @snarkipus/opencode-beads \`2.2.1\` PATH: \`/fixture\` -Remote history not checked. - **Plugin** ✅ Healthy | Check | Status | Value | @@ -183,10 +178,9 @@ Remote history not checked. |---|---|---| | bd CLI | ✅ | 1.3.4 | | Workspace | ✅ | Located | -| Recorded bd version | ✅ | 1.3.4 = CLI | +| Recorded bd version | — | 1.3.4 = CLI | | Git hooks | ✅ | 5/5 installed (shims) | -| Sync target | ✅ | Resolved · origin | -| Remote history | — | Not checked |`); +| Sync target | ✅ | Resolved · origin |`); expect(first).toContain("| Context | — | Not yet loaded |"); expect(first).toContain("✅ Healthy"); const unreadableSkill = renderHealthReport({ ...ready, local: { ...ready.local, sharedSkill: "unreadable" } }, 2000); @@ -206,8 +200,6 @@ VERSION: @snarkipus/opencode-beads \`2.2.1\` PATH: \`/fixture\` -Remote history not checked. - **Plugin** ✅ Healthy | Check | Status | Value | @@ -225,10 +217,9 @@ Remote history not checked. |---|---|---| | bd CLI | ✅ | 1.3.4 | | Workspace | ✅ | Located | -| Recorded bd version | ✅ | 1.3.4 = CLI | +| Recorded bd version | — | 1.3.4 = CLI | | Git hooks | — | 0/5 installed · 5 missing/unreadable/unresolved | -| Sync target | ✅ | Resolved · origin | -| Remote history | — | Not checked |`); +| Sync target | ✅ | Resolved · origin |`); const incompatible = renderHealthReport( { ...ready, @@ -247,7 +238,7 @@ VERSION: @snarkipus/opencode-beads \`2.2.1\` PATH: \`not observed\` -bd CLI unavailable or below the supported minimum. Remote history not checked. +bd CLI unavailable or below the supported minimum. **Plugin** ❌ Unhealthy @@ -266,10 +257,9 @@ bd CLI unavailable or below the supported minimum. Remote history not checked. |---|---|---| | bd CLI | ❌ | 1.3.0 (needs ≥1.3.1) | | Workspace | — | not observed | -| Recorded bd version | ✅ | 1.3.4 = CLI | +| Recorded bd version | — | 1.3.4 = CLI | | Git hooks | — | observation failed | | Sync target | — | Unknown · native listing not performed | -| Remote history | — | Not checked | **Actions** @@ -279,10 +269,27 @@ bd CLI unavailable or below the supported minimum. Remote history not checked. const noEvidence = renderHealthReport({}, 2000); expect(noEvidence).not.toContain("✅ Healthy"); expect(noEvidence).toContain("| Sync target | — | Unknown · native listing not performed |"); - expect(noEvidence).toContain("| Remote history | — | Not checked |"); + expect(noEvidence).not.toMatch(/Remote history|Source-Git freshness/); expect(noEvidence).toContain("No checks assessed"); }); +test("remote history is omitted in normal mode and explained once when requested for a local-only store", () => { + const snapshot = { ...presentationFixture(), syncTarget: { state: "local-only" } } satisfies DiagnosticsSnapshot; + for (const [details, historyRequested] of [ + [false, false], + [true, false], + [false, true], + [true, true], + ]) { + const report = renderHealthReport({ ...snapshot, historyRequested }, 2000, details); + expect(report).toContain("| Sync target | ✅ | Local-only |"); + expect(report).not.toContain("| Remote history |"); + expect(report.match(/Not applicable/g) ?? []).toHaveLength(details || historyRequested ? 1 : 0); + expect(report).not.toContain("No qualified Beads history probe is available"); + expect(report.match(/Source-Git freshness was not checked/g) ?? []).toHaveLength(details ? 1 : 0); + } +}); + test("normal command membership, witness and write uncertainty keep distinct severity", () => { const ready = presentationFixture(); const partial = renderHealthReport( @@ -307,8 +314,15 @@ test("normal command membership, witness and write uncertainty keep distinct sev { ...ready, local: { ...ready.local, witness: { state: "differ", recorded: "1.3.1", running: "1.3.4" } } }, 2000, ); - expect(differs).toContain("| Recorded bd version | ⚠️ | 1.3.1 ≠ CLI 1.3.4 |"); - expect(differs).not.toContain("❌ Unhealthy"); + expect(differs).toContain("| Recorded bd version | — | 1.3.1 ≠ CLI 1.3.4 |"); + const matching = renderHealthReport(ready, 2000); + expect(differs).toContain("## Beads diagnostics — ✅ Healthy"); + expect(differs).toContain("**Beads** ✅ Healthy"); + expect(differs.split("\n").find((line) => line.startsWith("| bd CLI |"))).toBe( + matching.split("\n").find((line) => line.startsWith("| bd CLI |")), + ); + expect(differs).toContain("Review the [Beads upgrade guide]"); + expect(matching).not.toContain("Beads upgrade guide"); const gap = renderHealthReport({ ...ready, persistence: "update task-1: uncertain; readback required" }, 2000); expect(gap).toContain("update task-1"); expect(gap).toContain("⚠️ Mismatch"); @@ -380,7 +394,7 @@ test("diagnostic header metadata uses observed root and exact code-populated val const fixture = presentationFixture(); const report = renderHealthReport(fixture, 2000); expect(report).toStartWith( - "## Beads diagnostics — ✅ Healthy\n\nDATE: `1970-01-01T00:00:02.000Z`\n\nVERSION: @snarkipus/opencode-beads `2.2.1`\n\nPATH: `/fixture`\n\nRemote history not checked.\n\n**Plugin**", + "## Beads diagnostics — ✅ Healthy\n\nDATE: `1970-01-01T00:00:02.000Z`\n\nVERSION: @snarkipus/opencode-beads `2.2.1`\n\nPATH: `/fixture`\n\n**Plugin**", ); expect(report.match(/DATE:/g)).toHaveLength(1); expect(report.match(/VERSION:/g)).toHaveLength(1);