Skip to content

feat(status): Phase 2 — substrate status surface (0.5.0)#33

Merged
broomva merged 1 commit into
mainfrom
feat/phase-2-status-surface
May 18, 2026
Merged

feat(status): Phase 2 — substrate status surface (0.5.0)#33
broomva merged 1 commit into
mainfrom
feat/phase-2-status-surface

Conversation

@broomva
Copy link
Copy Markdown
Owner

@broomva broomva commented May 18, 2026

Summary

Phase 2 of substrate completion (BRO-1154 under epic BRO-1148). Gives the metrics pipeline shipped in v0.4.0 a readable face.

New CLI

bstack status                  # 8-section colored summary
bstack status --json           # machine-readable for CI / tooling
bstack status --setpoint S<n>  # single-setpoint detail (text or --json)
bstack status --aggregate      # Phase 8 placeholder (exits 3)
bstack status --no-color       # strip ANSI even on TTY
bstack status --no-collect     # use stale cache without auto-collect

Auto-runs bstack metrics collect if ~/.bstack/metrics/latest.json is missing or > 5 min old. A fresh install gets a populated panel without calling metrics first.

8 sections rendered

Section Source
Plant derived from S11 + S12
Setpoints all setpoints in latest.json, classified vs alerts
Gates grep policy.yaml for G + bypass audit (Phase 5)
Primitives grep CLAUDE.md primitive table rows; fallback 20
Companion skills S10 value/target
Bridge S13 value/alert
RCS stability parse research/rcs/data/parameters.toml l3 lambda; graceful degrade when absent
Last upgrade ~/.bstack/just-upgraded-from + last-update-check

Live smoke against this workspace

bstack v0.4.0 — broomva [governed]
─────────────────────────────────────────────
Plant            ✓  5/5 governance files, 3/3 hooks wired
Setpoints        ✓  6/6 in target
Gates            ✓  12 reachable, 0 bypass attempts last 24h
Primitives       ✓  20/20 declared
Companion skills ✓  328/27 installed
Bridge           ✓  freshness 183s (alert >3600s)
RCS stability    -  (not configured for this workspace)
Last upgrade        v0.3.0 → v0.3.1 (available)
─────────────────────────────────────────────
All setpoints within target. No alerts.

Bugs caught + fixed pre-commit

  1. grep -c double-emit on BSD/macOS. primitive_count + gate_count + gate_bypass used grep -c ... || echo 0 which produces "0\n0" because grep -c exits 1 on zero matches AND outputs 0. Replaced with || true + tr -d whitespace. Regex also corrected from ^\| \*\*P[0-9]+\*\* (matches no rows) to ^\| P[0-9]+ \| (matches actual table format).
  2. Test framework set -e leak. tests/status-surface.test.sh had set +e; ...; set -e which enabled -e for subsequent tests even though the script header was set -uo pipefail (no -e). When test 7's grep -q returned 1 (no ANSI found, as intended), set -e killed the script. Replaced with explicit || true + run-and-grab pattern.

Files

  • NEW bin/bstack-status (~360 LOC)
  • NEW tests/status-surface.test.sh (8 fixture tests, all pass locally)
  • EDIT bin/bstack — register status subcommand + new help entry under Observability:
  • EDIT .github/workflows/ci.yml — add new test to VETTED allowlist
  • EDIT VERSION0.5.0
  • EDIT CHANGELOG.md — 0.5.0 entry

SLO targets (introduced)

  • bstack status (cached metrics): p50 < 500ms, p99 < 1s
  • bstack status (cold, auto-collects first): p50 < 2.5s, p99 < 6s
  • bstack status --setpoint <S-id>: p50 < 100ms, p99 < 300ms

Test plan

  • All 8 fixture tests pass locally
  • shellcheck clean (bin/bstack-status + test)
  • Smoke-tested against this workspace (text + --json + --setpoint modes)
  • --aggregate exits 3 with Phase 8 message
  • --no-color produces clean ANSI-free output
  • CI green
  • After merge: release.yml auto-publishes v0.5.0

Stack position

PR 6 of N in substrate completion. Depends on v0.4.0 (bin/bstack-metrics). Spec: §6 Phase 2.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added status subcommand providing workspace health summaries with text and JSON output formats.
    • Introduced support for per-setpoint views and a no-color display option.
  • Tests

    • Added comprehensive test suite validating status command behavior across multiple output modes.
  • Documentation

    • Updated release notes documenting version 0.5.0 features.
  • Chores

    • Version updated to 0.5.0.
    • CI workflow extended to include new status tests.

Review Change Stack

Implements §6 Phase 2 of substrate completion spec (BRO-1154 under epic
BRO-1148). Gives the metrics pipeline shipped in v0.4.0 a readable face.

New `bin/bstack-status` dispatcher:
  bstack status                  Colored text summary (8 sections)
  bstack status --json           Machine-readable JSON for CI / tooling
  bstack status --setpoint S<n>  Single-setpoint detail (text or --json)
  bstack status --aggregate      Phase 8 placeholder (exits 3)
  --no-color                     Strip ANSI even on TTY
  --no-collect                   Use stale cache without auto-running collect

The status command auto-runs `bstack metrics collect` if
~/.bstack/metrics/latest.json is missing or > 5 min old, so a fresh
install gets a populated panel without needing to call metrics first.

Sections rendered:
  Plant            derived from S11 + S12
  Setpoints        all setpoints in latest.json, classified vs alerts
  Gates            grep policy.yaml for G<n> + bypass audit (Phase 5)
  Primitives       grep CLAUDE.md table rows; fallback 20
  Companion skills S10 value/target
  Bridge           S13 value/alert
  RCS stability    parse research/rcs/data/parameters.toml l3 lambda;
                   gracefully degrades when not configured
  Last upgrade     ~/.bstack/just-upgraded-from + last-update-check

Tests: 8 fixture-based covering text mode sections, --json shape,
--setpoint text+json modes, unknown-setpoint exit, --aggregate
placeholder, --no-color stripping, auto-collect behavior. Added to
vetted CI suite.

Bug fixed during smoke (caught + fixed pre-commit):
  primitive_count + gate_count + gate_bypass used `grep -c ... || echo 0`
  which double-emits "0\n0" on BSD/macOS grep (where `grep -c` exits 1
  on zero matches AND outputs 0). Replaced with `|| true` + `tr -d`
  whitespace. Regex also corrected from ^\| \*\*P[0-9]+\*\* (matches
  no rows) to ^\| P[0-9]+ \| (matches actual table format).

Test bug fixed: tests/status-surface.test.sh had `set +e; ...; set -e`
which enabled -e for subsequent tests even though the script header
was `set -uo pipefail` (no -e). When test 7's grep -q returned 1 (no
ANSI found, as intended), set -e killed the script. Replaced with
explicit `|| true` + run-and-grab pattern.

Dispatcher updated: bstack status subcommand registered + new help
entry under Observability:.

SLO targets (introduced):
  bstack status (cached):       p50 < 500ms, p99 < 1s
  bstack status (cold collect): p50 < 2.5s, p99 < 6s
  bstack status --setpoint:     p50 < 100ms, p99 < 300ms

Files:
  - NEW bin/bstack-status
  - NEW tests/status-surface.test.sh
  - EDIT bin/bstack — register status subcommand + help section
  - EDIT .github/workflows/ci.yml — add new test to VETTED allowlist
  - EDIT VERSION → 0.5.0
  - EDIT CHANGELOG.md — 0.5.0 entry

Linear: BRO-1154 (Phase 2, parent epic BRO-1148).
Spec: §6 Phase 2 of specs/2026-05-18-substrate-completion.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 18, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 41f4fb14-f326-4be9-9994-3a178118b9a3

📥 Commits

Reviewing files that changed from the base of the PR and between 2e1e7db and a54fdb8.

📒 Files selected for processing (6)
  • .github/workflows/ci.yml
  • CHANGELOG.md
  • VERSION
  • bin/bstack
  • bin/bstack-status
  • tests/status-surface.test.sh

📝 Walkthrough

Walkthrough

This PR introduces the Phase 2 substrate status surface feature: a new bstack status CLI subcommand that renders workspace health summaries in multiple modes (colored text, JSON, per-setpoint details), backed by metrics collection and comprehensive test coverage, with version bump to v0.5.0 and CI integration.

Changes

Substrate Status Surface Feature

Layer / File(s) Summary
Release versioning and documentation
VERSION, CHANGELOG.md
VERSION bumped to 0.5.0. CHANGELOG documents Phase 2 status surface with new bin/bstack-status modes, per-setpoint views, --aggregate placeholder, data sources for health metrics, bug fixes, SLO targets, and spec reference.
Status command implementation
bin/bstack-status
New script reads workspace metrics (latest.json, policy.yaml, state markers, gate logs, RCS config), parses flags (--json, --setpoint, --aggregate, --no-color, --no-collect), refreshes stale metrics automatically, and outputs: (1) colored text summary with setpoint details, blocking/informational alert counts, and feature status (plant, governance, S10 companion skills, S13 bridge freshness, RCS stability); (2) JSON object with computed summary fields and raw setpoints; (3) per-setpoint detail view in text or JSON; (4) early exit for --aggregate as Phase 8 placeholder.
CLI dispatcher integration
bin/bstack
Help text and case statement routing add support for new status subcommand, passing arguments through to bin/bstack-status.
Test coverage
tests/status-surface.test.sh
Bash smoke test suite validates 8 scenarios: text output section headings, JSON schema and top-level fields (summary, setpoints), per-setpoint text and JSON output with field validation, error handling for unknown setpoints, --aggregate Phase 8 placeholder behavior with exit code 3, --no-color strips ANSI sequences, and auto-collect triggers metrics refresh when latest.json is missing and validates resulting file contains .setpoints. Includes test helpers for pass/fail accounting and fixture setup.
CI integration
.github/workflows/ci.yml
Adds tests/status-surface.test.sh to the VETTED test list for gated CI execution.

Sequence Diagram(s)

sequenceDiagram
  participant CLI as CLI Args
  participant Parser as Flag Parser
  participant Metrics as Metrics Refresh
  participant Helpers as Helper Functions
  participant Setpoint as Setpoint Mode
  participant JSON as JSON Mode
  participant Text as Text Summary
  participant Exit as Exit Handler

  CLI->>Parser: --json/--setpoint/text
  Parser->>Metrics: Check latest.json
  Metrics->>Helpers: Provide metrics data
  alt --setpoint mode
    Helpers->>Setpoint: Render per-setpoint details
    Setpoint->>Exit: Return setpoint object or error
  else --json mode
    Helpers->>JSON: Compute summary fields
    JSON->>JSON: Embed raw setpoints
    JSON->>Exit: Output JSON object
  else default text
    Helpers->>Text: Analyze health metrics
    Text->>Text: Render colored sections
    Text->>Exit: Print summary report
  end
  Exit->>Exit: Exit based on blocking/informational count
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Poem

🐰 A status command hops into view,
Metrics dance in summaries—bright and true,
JSON and text both show the way,
Phase 2 is built for health display! 🌱

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/phase-2-status-surface

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@broomva broomva merged commit e6ad423 into main May 18, 2026
4 of 5 checks passed
@linear
Copy link
Copy Markdown

linear Bot commented May 18, 2026

BRO-1154

@broomva broomva deleted the feat/phase-2-status-surface branch May 18, 2026 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant