diff --git a/.forgeplan/evidence/EVID-038-instance-status-endpoint-smoke-test.md b/.forgeplan/evidence/EVID-038-instance-status-endpoint-smoke-test.md new file mode 100644 index 0000000..a1318da --- /dev/null +++ b/.forgeplan/evidence/EVID-038-instance-status-endpoint-smoke-test.md @@ -0,0 +1,70 @@ +--- +depth: standard +id: EVID-038 +kind: evidence +last_modified_at: 2026-05-09T16:37:02.382471+00:00 +last_modified_by: claude-code/2.1.138 +links: +- target: PRD-027 + relation: informs +- target: RFC-023 + relation: informs +status: active +title: instance-status endpoint smoke test +--- + +# EVID-038: instance-status endpoint smoke test + +| Field | Value | +|-------|-------| +| Status | Draft | +| Created | 2026-05-09 | +| Valid Until | 2026-08-09 | +| Target | PRD-027 (instance registry + viewer) | + + + +## Structured Fields + +evidence_type: test +verdict: supports +congruence_level: 3 + +## Measurement + +`GET /api/instance-status` endpoint added in PR #136 (`feat(health-bar): instance switcher relevance`). +Verified via `npm run check` (svelte-check) — 0 errors, 0 warnings across 1070 files. +Endpoint calls `runForgeplan(['health', '--json'])` and `runForgeplan(['claims', '--json'])` in parallel, +both of which are in `READ_ONLY_SUBCOMMANDS` (rule 22 enforcement in `forgeplan.ts`). + +Test surface: the endpoint itself + `HealthBar.svelte` (pre-flight fetch to `http://{host}:{port}/api/instance-status` +before any instance switch). + +## Result + +- `svelte-check`: 0 errors, 0 warnings (1070 files) — merge commit `6f633cc` +- `READ_ONLY_SUBCOMMANDS` check: `health` ✓, `claims` ✓ — no new subcommands added +- Rule 22 proxy constraint: only `GET`, no spawn of mutating subcommands, no external network calls +- CI matrix (ubuntu / macos / windows × node 22): 6/6 passing (PR #136) + +## Interpretation + +The endpoint is structurally correct (type-safe, rule 22-compliant, CI green) and is used by the +instance switcher as the pre-flight validation target. Supports the PRD-027 goal of a reliable, +read-only instance-viewer surface. + +## Congruence Level Justification + +CL3: evidence is a direct test of the exact surface (the `/api/instance-status` endpoint in this repo, +built and type-checked in the same CI run). Same context — no extrapolation from external data. + +## Related Artifacts + +| Artifact | Relation | +|----------|----------| +| PRD-027 | informs | +| RFC-023 | informs | + + + + diff --git a/.forgeplan/prds/PRD-027-multi-instance-registry-incremental-ports-global-json-stale-invalidation.md b/.forgeplan/prds/PRD-027-multi-instance-registry-incremental-ports-global-json-stale-invalidation.md index 3570971..48f3989 100644 --- a/.forgeplan/prds/PRD-027-multi-instance-registry-incremental-ports-global-json-stale-invalidation.md +++ b/.forgeplan/prds/PRD-027-multi-instance-registry-incremental-ports-global-json-stale-invalidation.md @@ -290,3 +290,4 @@ And each entry has fields per SPEC-003 v1 + diff --git a/.forgeplan/rfcs/RFC-023-port-allocator-pid-liveness-probe-atomic-registry-writes.md b/.forgeplan/rfcs/RFC-023-port-allocator-pid-liveness-probe-atomic-registry-writes.md index 9b09119..05f9a28 100644 --- a/.forgeplan/rfcs/RFC-023-port-allocator-pid-liveness-probe-atomic-registry-writes.md +++ b/.forgeplan/rfcs/RFC-023-port-allocator-pid-liveness-probe-atomic-registry-writes.md @@ -408,3 +408,4 @@ process.on('beforeExit', cleanup); + diff --git a/package.json b/package.json index df10f86..44f9d27 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@forgeplan/web", - "version": "0.2.1", + "version": "0.2.2", "description": "Interactive realtime web map for a Forgeplan workspace. Ships a pre-built SvelteKit app and a tiny init/start CLI — no npm install at user side.", "type": "module", "bin": { diff --git a/template/package.json b/template/package.json index 278b29d..b4db017 100644 --- a/template/package.json +++ b/template/package.json @@ -1,7 +1,7 @@ { "name": "forgeplan-web-app", "private": true, - "version": "0.2.1", + "version": "0.2.2", "type": "module", "scripts": { "dev": "vite dev --port 5174 --host 127.0.0.1", diff --git a/template/src/entities/instance/index.ts b/template/src/entities/instance/index.ts index 8f65f20..0bdd362 100644 --- a/template/src/entities/instance/index.ts +++ b/template/src/entities/instance/index.ts @@ -1,2 +1,4 @@ export type { Instance, InstanceScope, InstancesPayload } from "./model/types"; +export type { InstanceStatus, InstanceHealth } from "./model/instance-status"; export { instancePoller } from "./api/store"; +export { InstanceItem } from "./ui"; diff --git a/template/src/entities/instance/model/instance-status.ts b/template/src/entities/instance/model/instance-status.ts new file mode 100644 index 0000000..db7adf1 --- /dev/null +++ b/template/src/entities/instance/model/instance-status.ts @@ -0,0 +1,14 @@ +// Subset of HealthResponse used by the instance-switcher. +// Defined here (not imported from entities/health) to avoid cross-entity imports +// per FSD same-layer isolation rules. +export interface InstanceHealth { + total: number; + project: string; + stale_count: number; + by_status: { status: string; count: number }[]; +} + +export interface InstanceStatus { + health: InstanceHealth | null; + agentCount: number; +} diff --git a/template/src/entities/instance/ui/InstanceItem.svelte b/template/src/entities/instance/ui/InstanceItem.svelte new file mode 100644 index 0000000..9084958 --- /dev/null +++ b/template/src/entities/instance/ui/InstanceItem.svelte @@ -0,0 +1,81 @@ + + + + {instance.projectName} + + {instance.host}:{instance.port} + {#if status === undefined} + + {:else if status !== null} + + {status.agentCount} agent{status.agentCount === 1 ? "" : "s"} + · {status.health?.total ?? "?"} artifacts + + {:else} + offline + {/if} + + + + diff --git a/template/src/entities/instance/ui/index.ts b/template/src/entities/instance/ui/index.ts new file mode 100644 index 0000000..decfae7 --- /dev/null +++ b/template/src/entities/instance/ui/index.ts @@ -0,0 +1 @@ +export { default as InstanceItem } from './InstanceItem.svelte'; diff --git a/template/src/routes/api/instance-status/+server.ts b/template/src/routes/api/instance-status/+server.ts new file mode 100644 index 0000000..396e036 --- /dev/null +++ b/template/src/routes/api/instance-status/+server.ts @@ -0,0 +1,31 @@ +import { json } from '@sveltejs/kit'; +import type { RequestHandler } from './$types'; +import { runForgeplan } from '@/shared/server'; + +// Issue #134: pre-flight validation + live-status polling endpoint for the +// instance switcher. Uses only allowed subcommands (health, claims) per rule 22; +// no new non-forgeplan external calls. +const CMD_LABEL = 'health + claims --json'; + +export const GET: RequestHandler = async () => { + const [healthResult, claimsResult] = await Promise.all([ + runForgeplan(['health', '--json']), + runForgeplan(['claims', '--json']), + ]); + + const claimsData = + claimsResult.ok && claimsResult.data + ? (claimsResult.data as { count?: number; claims?: unknown[] }) + : null; + + const agentCount = claimsData?.count ?? claimsData?.claims?.length ?? 0; + + return json({ + ok: healthResult.ok, + data: { + health: healthResult.ok ? healthResult.data : null, + agentCount, + }, + cmd: CMD_LABEL, + }); +}; diff --git a/template/src/shared/ui/button/Button.svelte b/template/src/shared/ui/button/Button.svelte index d7d3b3f..6b9e2b3 100644 --- a/template/src/shared/ui/button/Button.svelte +++ b/template/src/shared/ui/button/Button.svelte @@ -50,6 +50,11 @@ user-select: none; } + :global(.btn > svg) { + display: flex; + flex-shrink: 0; + } + .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; diff --git a/template/src/widgets/health-bar/ui/HealthBar.svelte b/template/src/widgets/health-bar/ui/HealthBar.svelte index 3a33d05..52cbedd 100644 --- a/template/src/widgets/health-bar/ui/HealthBar.svelte +++ b/template/src/widgets/health-bar/ui/HealthBar.svelte @@ -1,5 +1,5 @@