Skip to content

feat(cog-person-count): wire run subcommand — v0.0.1 fully functional#697

Merged
ruvnet merged 1 commit into
mainfrom
feat/cog-person-count-runtime-wiring
May 21, 2026
Merged

feat(cog-person-count): wire run subcommand — v0.0.1 fully functional#697
ruvnet merged 1 commit into
mainfrom
feat/cog-person-count-runtime-wiring

Conversation

@ruvnet
Copy link
Copy Markdown
Owner

@ruvnet ruvnet commented May 21, 2026

Phase 4 of ADR-103. Wires the long-running polling loop so all four verbs (version/manifest/health/run) do real work end-to-end.

What ships

  • src/runtime.rs (new) — run_loop polls sensing_url every poll_ms, slides a [56,20] CSI window, infers, emits person.count events. Same shape as cog-pose-estimation::runtime. Fails open on connect errors with a WARN log.
  • src/main.rs::cmd_run — loads RunConfig from JSON file, builds InferenceEngine, emits run.started, hands off to Tokio.
  • cog/README.md — new "Relationship to the in-process score_to_person_count heuristic" section documenting the dual-emitter design.

Verified

  • cargo check — clean
  • cargo test15/15 pass (no regressions)
  • Binary size unchanged: 2.36 MB
  • Smoke against a bad URL: emits run.started then WARN per frame, loop alive, no NaN

After this PR merges, ADR-103 v0.0.1 is structurally complete. v0.2.0 is data-bound (#645).

🤖 Generated with claude-flow

Phase 4 of ADR-103. Adds the long-running polling loop so the cog's
fourth verb (`run`) does real work, completing the ADR-100 runtime
contract end-to-end:

  cog-person-count version    → "person-count 0.3.0"
  cog-person-count manifest   → JSON skeleton
  cog-person-count health     → loads weights + 1-shot infer + emit
  cog-person-count run --config  → long-running per-frame emit  ← THIS

What ships:

* src/runtime.rs (new) — `run_loop` polls sensing_url every poll_ms,
  slides a [56, 20] CSI window, runs InferenceEngine::infer, emits
  publisher::person_count events. Same shape as
  cog-pose-estimation::runtime — fetch_frame extracts amplitudes
  from `snapshot.nodes[0].amplitude[]`, fails open on connect errors
  with a WARN log rather than crashing.
* src/lib.rs — registers the runtime module.
* src/main.rs — cmd_run now loads RunConfig from a JSON file, builds
  the InferenceEngine (with weights if cfg.model_path is set,
  otherwise auto-discover), emits a run.started event, and hands off
  to the Tokio multi-thread runtime's block_on(run_loop). Single-node
  fusion is a no-op for N=1 today; v0.2.0 will append predictions
  from sibling nodes and call fusion::fuse_confidence_weighted before
  emit.

Verified locally:

  cargo check  -p cog-person-count --no-default-features   → clean
  cargo test   -p cog-person-count                          → 15/15 pass (no regressions)
  cargo build  -p cog-person-count --release                → 2.36 MB unchanged
  ./cog-person-count run --config bad-config.json:
    line 1: {"event":"run.started","fields":{"cog":"person-count",
             "sensing_url":"http://127.0.0.1:9999/...",poll_ms:100,
             "model_path":"(auto-discover)"}}
    line 2: WARN sensing-server fetch failed
            error=Connection Failed: Connect error: actively refused
    (loop alive — exits cleanly on SIGTERM, no crash, no NaN)

Also adds a "Relationship to the in-process score_to_person_count
heuristic" section to cog/README.md explaining the dual-emitter
design (sensing-server keeps emitting the PR #491 slot heuristic;
the cog runs out-of-process and emits person.count events from the
learned model). Operators choose by installing the cog or not — no
sensing-server rebuild required.

ADR-103 §"Migration" status:
  1. Land ADR + scaffold ........... done (#693, #694)
  2. Train count_v1 ................ done (#695)
  3. Cross-compile + sign + GCS .... done (#696)
  4. Server-side wiring ............ done — out-of-process design
                                      means no rewire needed; this
                                      cog is the wiring.
  5. v0.2.0 multi-room + LoRA ...... data-bound (#645)
@ruvnet ruvnet merged commit 5c914e6 into main May 21, 2026
25 checks passed
@ruvnet ruvnet deleted the feat/cog-person-count-runtime-wiring branch May 21, 2026 23:10
ruvnet added a commit that referenced this pull request May 21, 2026
…ld (#698)

The arm + x86_64 manifests committed in #696 referenced the binaries
built before #697 wired the `run` subcommand. Rebuilt + re-signed +
re-uploaded to GCS, and re-deployed to cognitum-v0:

  arm    sha 15c2fbac…7728ea5  (3,807,456 B, up from 2,168,816 — added Tokio runtime)
  x86_64 sha 051614ce…cc8388b3 (4,502,960 B, up from 2,615,528)

Both re-signed Ed25519 with COGNITUM_OWNER_SIGNING_KEY. Manifests
now match the binaries published at gs://cognitum-apps/cogs/{arm,
x86_64}/cog-person-count-* and the binary installed at
/var/lib/cognitum/apps/person-count/ on cognitum-v0.
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