Skip to content

Cockpit — wire live runtime to Autoflow state - #81

Merged
LogicDuke merged 2 commits into
mainfrom
feature/live-runtime-wiring
Sep 5, 2026
Merged

Cockpit — wire live runtime to Autoflow state#81
LogicDuke merged 2 commits into
mainfrom
feature/live-runtime-wiring

Conversation

@LogicDuke

@LogicDuke LogicDuke commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Live Runtime Wiring implements adopted Decision 059.

Architecture

AutoflowRuntime
→ read-only AutoflowStateReader
→ RepositoryObserver
→ CockpitObservation
→ produceCockpitSnapshot
→ JSON serialization firewall
→ CockpitSource(mode='live')
→ readCockpitSnapshot(unknown)
→ existing D2/D4 projections
→ renderer
→ loopback Cockpit host

Scope

  • add a minimal production AutoflowRuntime as the sole owner of current immutable WorkflowState
  • expose a structurally narrowed read-only AutoflowStateReader to the Cockpit path
  • add a synchronous RepositoryObserver using runtime-supplied immutable repository observation inputs
  • add live runtime composition
  • render live Cockpit state per GET /
  • preserve fixture render-once behavior
  • add cockpit:live entrypoint
  • keep 127.0.0.1:4317 cutover separate from this PR

Authority remains unchanged

  • Autoflow remains the workflow source of truth
  • Cockpit receives no open/apply capability
  • no Policy authority
  • no provider execution authority
  • no repository/Git/GitHub mutation authority
  • no Ready/review/thread/merge authority
  • D1 remains the hostile serialized-input boundary
  • schema v2 unchanged
  • no silent live→fixture fallback
  • no background polling

Strong unchanged boundaries

  • src/cockpit-snapshot/producer.ts
  • src/cockpit/read-model.ts
  • src/cockpit/evidence-freshness-projection.ts
  • src/cockpit/autoflow-projection.ts
  • src/domain/workflow.ts
  • src/domain/workflow-transitions.ts

Validation

  • fresh independent implementation validation: PASS
  • 1831 / 1831 tests PASS
  • typecheck PASS
  • lint PASS
  • build PASS
  • git diff --check PASS
  • capability/authority sweep CLEAN
  • current P0/P1/P2: NONE

Exact candidate

Known non-blocking P3 observations

  1. startup readiness probe performs one discarded full render; a narrower probe could theoretically suffice
  2. a few extra negative test assertions could be added

These are intentionally deferred and are not part of this PR repair scope.

Runtime cutover

The real 127.0.0.1:4317 runtime remains STOPPED.
Starting/cutting over the live runtime is a separate downstream authority gate after the code lands.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AAgxiS7ZxExQN1to1RuA2R

Summary by CodeRabbit

  • New Features

    • Added a live Cockpit runtime that serves up-to-date workflow and repository observations.
    • Added state management for opening workflows and applying transitions, including safe handling when no workflow is active.
    • Added configurable repository observation with validation and immutable results.
    • Added a cockpit:live command for launching the live Cockpit server.
    • Live server binds to loopback and fails safely on startup or observation errors.
  • Tests

    • Added coverage for live observations, workflow transitions, server behavior, validation, and failure handling.

Implements the frozen Live Runtime Wiring DDR (Decision 059): a minimal
AutoflowRuntime owns the single authoritative WorkflowState; a narrowed
read-only AutoflowStateReader and a synchronous RepositoryObserver feed a
whole-observation builder through produceCockpitSnapshot (JSON firewall),
a live CockpitSource, D1, and D2/D4 into a per-GET render. Autoflow remains
the sole workflow source of truth; the Cockpit gains no transition, Policy,
provider, or Git/GitHub authority. Fixture mode and all six strong-boundary
files are unchanged. observedAt is the whole-observation collection time.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AAgxiS7ZxExQN1to1RuA2R
@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 3813be68-e9db-4e70-bf6e-247982cc291c

📥 Commits

Reviewing files that changed from the base of the PR and between 7af9030 and 537953f.

📒 Files selected for processing (8)
  • package.json
  • src/autoflow/runtime.ts
  • src/cockpit-host/server.ts
  • src/runtime/live-cockpit.ts
  • src/runtime/repository-observer.ts
  • tests/autoflow/runtime.test.ts
  • tests/runtime/live-cockpit.test.ts
  • tests/runtime/repository-observer.test.ts

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The change adds an Autoflow runtime owner, a validated repository observer, and a live Cockpit server. The server captures fresh state per GET /, serializes live observations, binds to loopback, and fails closed on invalid or unavailable data.

Changes

Live Cockpit Runtime

Layer / File(s) Summary
Autoflow state ownership
src/autoflow/runtime.ts, tests/autoflow/runtime.test.ts
AutoflowRuntime owns workflow state, applies domain transitions, returns NO_WORKFLOW when needed, and exposes a read-only reader.
Repository observation seam
src/runtime/repository-observer.ts, tests/runtime/repository-observer.test.ts
The configured observer validates repository values and returns one frozen observation through observe().
Live Cockpit host and composition
src/cockpit-host/server.ts, src/runtime/live-cockpit.ts, package.json, tests/runtime/live-cockpit.test.ts
The provider-based host renders fresh live snapshots for GET /, handles provider failures with 500, starts on loopback, and wires runtime state, repository observation, startup checks, and shutdown handling.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: ⚪ Minimal · up to 53795

Live Cockpit now renders current Autoflow state on each root request while remaining loopback-only and read-only. Invalid or unavailable live data fails closed rather than serving fixture or stale content, leaving no identified merge-blocking risk.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant CockpitServer
  participant LiveObservation
  participant RepositoryObserver
  participant AutoflowRuntime
  Client->>CockpitServer: GET /
  CockpitServer->>LiveObservation: Create snapshot
  LiveObservation->>RepositoryObserver: observe()
  LiveObservation->>AutoflowRuntime: current()
  LiveObservation-->>CockpitServer: Serialized Cockpit snapshot
  CockpitServer-->>Client: Rendered page
Loading

Poem

A rabbit checks the workflow state,
Then watches fresh snapshots at the gate.
The cockpit serves what readers see,
While loopback keeps the burrow free.
Frozen facts hop safely through the stream.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 68.75% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 7 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: wiring the live Cockpit runtime to authoritative Autoflow state.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 68.75% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 7 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/live-runtime-wiring

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.

@LogicDuke
LogicDuke marked this pull request as ready for review September 5, 2026 16:01
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-05T16:41:22.273480Z 537953f Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@LogicDuke

Copy link
Copy Markdown
Owner Author

@codex review

Please perform one substantive review of this PR at exact head c3a15fd8894e498d8716f63ac4a08bdea36cbfd4 (base main@7af903053bfba65edf42abf11cb52e0a75b8db7c, CI #261 green).

Review scope:

  • AutoflowRuntime ownership correctness (single immutable WorkflowState reference; replace-not-mutate; APPLIED-only advance)
  • reader-only capability boundary (AutoflowStateReader exposes current() only; open/apply unreachable from the Cockpit path)
  • RepositoryObserver truthfulness and capability confinement (runtime-supplied immutable inputs; no Git/GitHub/subprocess/network/fs)
  • observedAt whole-observation collection-time semantics
  • live per-GET capture semantics (one capture per GET /; zero on styles/404/non-GET)
  • fail-closed behavior (startup-fatal vs per-request 500)
  • no silent live→fixture fallback
  • production-entrypoint / DONE-predicate honesty (no autonomous event source; no test-only WorkflowState injection)
  • six strong unchanged boundaries remain byte-identical
  • no authority expansion; no hidden Git/GitHub/network/process capability

Two known non-blocking P3 observations are intentionally deferred and are NOT repair requests unless independently shown to violate a real current invariant:

  1. full-render startup readiness probe
  2. additional optional negative test assertions

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c3a15fd889

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/runtime/live-cockpit.ts Outdated
Addresses Codex P2 on PR #81. startLiveCockpit accepted a caller-supplied
host and bound `options.host ?? HOST`, letting a public caller bind the live
dashboard to 0.0.0.0/::/a routable interface and expose observations to
remote clients. Remove the `host` option from StartLiveCockpitOptions and
always bind the pinned HOST (127.0.0.1); only `port` remains configurable
(ephemeral 0 for tests) and never affects the interface. The removal is
type-level, so a host override is now a compile error. Both production
listen paths remain loopback-only. No strong-boundary or other candidate
file changed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AAgxiS7ZxExQN1to1RuA2R
@LogicDuke

Copy link
Copy Markdown
Owner Author

@codex review

Re-review at exact current head 537953f21ebe79700dd35710645c5a727b89b265 (base main@7af903053bfba65edf42abf11cb52e0a75b8db7c, exact-head CI #262 green).

This head adds commit 537953f which addresses the prior P2 (loopback pin):

  • the public host option was removed from StartLiveCockpitOptions (type-level removal — a host override is now a compile error)
  • startLiveCockpit now always binds the pinned HOST (127.0.0.1); only port remains configurable (ephemeral 0 for tests) and never affects the bind interface
  • both production server.listen paths are loopback-only; no env/internal host override path exists

Please confirm the loopback-pin P2 is resolved and check for any new current finding in the two changed files (src/runtime/live-cockpit.ts, tests/runtime/live-cockpit.test.ts), plus the standing scope: no authority expansion, no hidden Git/GitHub/network/process capability, fail-closed behavior, no live→fixture fallback, strong boundaries unchanged.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 537953f21e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@LogicDuke

Copy link
Copy Markdown
Owner Author

@coderabbitai review

Final substantive review at exact current head 537953f21ebe79700dd35710645c5a727b89b265 (base main@7af903053bfba65edf42abf11cb52e0a75b8db7c, exact-head CI #262 green, exact-head Codex re-review clean).

Scope: the Live Runtime Wiring feature (AutoflowRuntime as sole owner of the current immutable WorkflowState; reader-only AutoflowStateReader into the Cockpit path; synchronous RepositoryObserver over runtime-supplied immutable inputs; whole-observation per-GET capture; loopback-pinned host; fail-closed; no live→fixture fallback; six strong boundaries unchanged; schema v2 unchanged).

Already adjudicated (please provide materially new evidence to reopen):

  • loopback host P2: fixed on 537953f (public host option removed; always binds 127.0.0.1)
  • startup full-render readiness probe: deferred P3
  • optional extra negative tests: deferred P3

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

head_commit="537953f21ebe79700dd35710645c5a727b89b265"
base_commit="7af903053bfba65edf42abf11cb52e0a75b8db7c"

echo "== Commit identity =="
git rev-parse HEAD
git rev-parse "${head_commit}^{parent}"
git merge-base --is-ancestor "$base_commit" "$head_commit" && echo "base-is-ancestor=true"
git diff --check "$base_commit" "$head_commit"
git diff --stat "$base_commit" "$head_commit"
git diff --name-status "$base_commit" "$head_commit"

echo "== Protected boundary identity =="
for path in \
  src/cockpit-snapshot/producer.ts \
  src/cockpit/read-model.ts \
  src/cockpit/evidence-freshness-projection.ts \
  src/cockpit/autoflow-projection.ts \
  src/domain/workflow.ts \
  src/domain/workflow-transitions.ts
do
  printf '%s ' "$path"
  git rev-parse "$base_commit:$path"
  git rev-parse "$head_commit:$path"
done

echo "== Changed source/test structure =="
git diff --name-only "$base_commit" "$head_commit" | while IFS= read -r path; do
  case "$path" in
    *.ts|*.tsx|*.mts|*.cts)
      echo "-- $path"
      ast-grep outline "$path" --items all || true
      ;;
  esac
done

echo "== Complete patch =="
git diff --find-renames --find-copies --no-ext-diff "$base_commit" "$head_commit"

echo "== Runtime and Cockpit candidate files =="
fd -t f . src tests | rg '/(runtime|cockpit)(/|.*\.(ts|tsx)$)|AutoflowRuntime|RepositoryObserver|live-cockpit' || true

echo "== Prohibited-capability indicators in changed source =="
git diff --name-only "$base_commit" "$head_commit" -- 'src/**' | while IFS= read -r path; do
  [ -n "$path" ] || continue
  echo "-- $path"
  rg -n -i -C 2 '(child_process|node:child_process|execFile|spawn|fork|node:net|node:tls|node:http|node:https|fetch\s*\(|axios|octokit|simple-git|isomorphic-git|node:fs|readFile|writeFile|WorkflowState|\.open\s*\(|\.apply\s*\(|\.advance\s*\(|server\.listen|createServer)' "$path" || true
done

echo "== Live route and runtime references =="
rg -n -C 3 '(startLiveCockpit|AutoflowRuntime|AutoflowStateReader|RepositoryObserver|readCockpitSnapshot|produceCockpitSnapshot|server\.listen|req\.method|request\.method|GET)' src tests || true

Length of output: 2785


🏁 Script executed:

#!/bin/bash
set -u -o pipefail

head_commit="HEAD"
base_commit="HEAD^"
stated_base="7af903053bfba65edf42abf11cb52e0a75b8db7c"

echo "== Available commit topology =="
git rev-parse HEAD
git rev-parse HEAD^ || true
git cat-file -e "${stated_base}^{commit}" 2>/dev/null && echo "stated-base-available=true" || echo "stated-base-available=false"

echo "== Patch integrity and file list =="
git diff --check "$base_commit" "$head_commit" || true
git diff --stat "$base_commit" "$head_commit" || true
git diff --name-status "$base_commit" "$head_commit" || true

echo "== Protected boundary identity against local parent =="
for path in \
  src/cockpit-snapshot/producer.ts \
  src/cockpit/read-model.ts \
  src/cockpit/evidence-freshness-projection.ts \
  src/cockpit/autoflow-projection.ts \
  src/domain/workflow.ts \
  src/domain/workflow-transitions.ts
do
  printf '%s\n  parent=' "$path"
  git rev-parse "$base_commit:$path" 2>&1 || true
  printf '  head='
  git rev-parse "$head_commit:$path" 2>&1 || true
done

echo "== Patch from local parent =="
git diff --find-renames --find-copies --no-ext-diff "$base_commit" "$head_commit" || true

echo "== Candidate file names =="
fd -t f . src tests 2>/dev/null | rg '(runtime|cockpit|autoflow|repository-observer|live-cockpit)' || true

echo "== Candidate TypeScript outlines =="
fd -t f -e ts . src tests 2>/dev/null | rg '(runtime|cockpit|autoflow|repository-observer|live-cockpit)' | while IFS= read -r path; do
  echo "-- $path"
  ast-grep outline "$path" --items all 2>&1 || true
done

echo "== Capability and route evidence =="
rg -n -i -C 3 '(AutoflowRuntime|AutoflowStateReader|RepositoryObserver|startLiveCockpit|produceCockpitSnapshot|readCockpitSnapshot|server\.listen|createServer|req\.method|request\.method|child_process|node:child_process|execFile|spawn|fork|node:net|node:tls|node:http|node:https|fetch\s*\(|axios|octokit|simple-git|isomorphic-git|node:fs|readFile|writeFile|\.open\s*\(|\.apply\s*\(|\.advance\s*\()' src tests 2>/dev/null || true

Length of output: 176469


🏁 Script executed:

#!/bin/bash
set -euo pipefail

base="7af903053bfba65edf42abf11cb52e0a75b8db7c"
head="HEAD"

echo "== Full PR file range and integrity =="
git diff --check "$base" "$head"
git diff --name-status "$base" "$head"
git diff --stat "$base" "$head"

echo "== Specified protected boundaries against stated base =="
for path in \
  src/cockpit-snapshot/producer.ts \
  src/cockpit/read-model.ts \
  src/cockpit/evidence-freshness-projection.ts \
  src/cockpit/autoflow-projection.ts \
  src/domain/workflow.ts \
  src/domain/workflow-transitions.ts
do
  parent_blob="$(git rev-parse "$base:$path")"
  head_blob="$(git rev-parse "$head:$path")"
  printf '%s base=%s head=%s equal=%s\n' "$path" "$parent_blob" "$head_blob" \
    "$([ "$parent_blob" = "$head_blob" ] && echo true || echo false)"
done

echo "== Autoflow runtime =="
sed -n '1,220p' src/autoflow/runtime.ts

echo "== Repository observer =="
sed -n '1,180p' src/runtime/repository-observer.ts

echo "== Live Cockpit composition and entrypoint =="
sed -n '1,260p' src/runtime/live-cockpit.ts

echo "== Cockpit route provider behavior =="
sed -n '90,225p' src/cockpit-host/server.ts

echo "== Relevant live runtime tests =="
sed -n '110,455p' tests/runtime/live-cockpit.test.ts

echo "== Runtime module static imports and forbidden API indicators =="
for path in src/autoflow/runtime.ts src/runtime/repository-observer.ts src/runtime/live-cockpit.ts; do
  echo "-- $path imports"
  rg -n '^\s*import\b|^\s*export\b' "$path"
  echo "-- $path prohibited indicators"
  rg -n -i '(node:fs|child_process|node:child_process|exec(File|Sync)?|spawn|fork|simple-git|isomorphic-git|octokit|github|fetch\s*\(|axios|node:https|node:tls|node:net|readFile|writeFile|readdir|\.open\s*\(|\.apply\s*\()' "$path" || true
done

echo "== Public scripts and live entrypoint references =="
fd -t f 'package*.json' . -d 3 -0 | xargs -0 -r -n1 sh -c 'echo "-- $0"; sed -n "1,220p" "$0"' || true
rg -n -C 2 '(cockpit:live|live-cockpit|AGENTBRIDGE_REPOSITORY_ID|AGENTBRIDGE_OBSERVED_HEAD_SHA)' README.md package.json src tests 2>/dev/null || true

Length of output: 43374


@LogicDuke Final substantive review complete for 537953f21ebe79700dd35710645c5a727b89b265.

I found no new findings.

The loopback-pin repair is resolved. StartLiveCockpitOptions has no host option. startLiveCockpit always binds HOST (127.0.0.1).

The reviewed implementation maintains the requested boundaries:

  • AutoflowRuntime has one private current-state reference. It replaces that reference only for APPLIED results.
  • AutoflowStateReader exposes current() only. The Cockpit path receives the narrowed frozen reader.
  • RepositoryObserver uses configured immutable inputs. It has no Git, GitHub, filesystem, subprocess, or network implementation capability.
  • Each live capture reads the observer, reader, and clock once. observedAt is the collection time.
  • GET / captures and renders live state once. Styles, unknown routes, and non-GET requests do not capture state.
  • Startup failures stop startup. Per-request failures return 500. The host does not fall back to fixture data.
  • The production entrypoint has no autonomous event source and starts with an honest no-workflow state.
  • The six specified protected boundaries are byte-identical to 7af903053bfba65edf42abf11cb52e0a75b8db7c.
  • Schema version 2 remains unchanged.
  • git diff --check passes for the reviewed range.
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@LogicDuke
LogicDuke merged commit 843d517 into main Sep 5, 2026
2 checks passed
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