Skip to content

feat(examples): counter-cli — the define-once proof (O2)#5

Merged
joelteply merged 3 commits into
mainfrom
examples/counter-cli
Jul 3, 2026
Merged

feat(examples): counter-cli — the define-once proof (O2)#5
joelteply merged 3 commits into
mainfrom
examples/counter-cli

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

O2 — makes the separation contract non-vapor

Second unit of the positron build-out (roadmap in docs/ARCHITECTURE.md, O1 landed in #4). Proves the whole "define once, project many" thesis in one process, zero transport, zero substrate — before any wire or ContinuumHost is involved.

What it demonstrates

  • ONE app definition — the Counter ViewState (semantic content only: value + revision; no colors/widths/layout, exactly as ARCHITECTURE.md Q#4 pins).
  • Two renderers, maximally differentLineRenderer (Output = String) and GaugeRenderer (Output = Vec<String>). Different associated Output types is the outlier-validation discipline: fit both extremes without forcing → the middle (DOM tree, ratatui frame) is guaranteed.
  • One observer = the fourth projection — an AI persona perceives the same Counter a human sees (Session-tier budget_hz) and, on threshold, acts through the identical command vocabulary by emitting a CommandEnvelope tagged CommandSource::Observer. Perception identity is carried onto action provenance (observer_id() == source.observer_id). No separate "AI view."

Shape

  • Standalone workspace member (examples/counter-cli) consuming positron-core as an external crate — the honest "consumable by anyone" proof, not an in-crate test.
  • Transport-free perceive→act sink is Arc<Mutex<Vec<CommandEnvelope>>> (not mpsc::Sender, which is !Sync and would break the Observer: Sync bound).

Verification

  • cargo test -p counter-cli → 2 pass. Two tests, each with // what this catches: — renderer purity (same &state, no mutation, byte-identical re-render) and perceive→act identity carry.
  • cargo run -p counter-cli → renders the counter through both surfaces per revision and prints the 3 commands the observer emitted through the shared vocabulary.
  • cargo check -p counter-cli clean (pre-existing ts-rs serde-attr warning in positron-core is unrelated).

Docs

  • README status refreshed v0.0.0 → v0.1.x + roadmap pointer; positron-tspositron-lit for single-name consistency with the O1 nit fix.

🤖 Generated with Claude Code

joelteply and others added 3 commits July 2, 2026 21:43
Makes docs/ARCHITECTURE.md non-vapor. One Counter ViewState, projected three
ways in a single process with zero transport and zero substrate:

- two renderers, deliberately maximally different — LineRenderer (Output=String)
  and GaugeRenderer (Output=Vec<String>). Different associated Output types is
  the outlier-validation: if the Renderer trait fits both extremes without
  forcing, it fits a DOM tree / ratatui frame in the middle.
- one Observer (an AI persona) that perceives the SAME Counter a human sees and,
  on threshold, acts through the identical command vocabulary by emitting a
  CommandEnvelope tagged CommandSource::Observer — the fourth projection of the
  identical state, not a bespoke integration.

Standalone workspace member consuming positron-core as an external crate (the
"consumable by anyone" proof). Two tests with `// what this catches:`:
renderer purity (same &state, no mutation, byte-identical re-render) and
perceive→act identity carry (observer_id() == CommandSource provenance).

README status refreshed to v0.1.x + roadmap pointer; positron-ts → positron-lit
for single-name consistency with the O1 nit fix.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…ent unwrap, clamp idiom

Review (APPROVE WITH NITS) touch-ups:
- ThresholdObserver doc now says "while at/over its threshold" and states it's
  level-triggered (emits on every at/over-threshold perception, not only the
  crossing) — matches the code, which fires 3× for 8/10/12.
- print state.revision directly instead of state.revision().unwrap() (the field
  is owned; no reason to round-trip through the Option-returning trait method).
- GaugeRenderer caption uses .clamp(0, width) to match the idiom one line up.

No behavior change. cargo test -p counter-cli → 2 pass; clippy clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply joelteply merged commit d326212 into main Jul 3, 2026
2 checks passed
@joelteply joelteply deleted the examples/counter-cli branch July 3, 2026 02:48
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