CLI Telemetry Third Review Fixes Implementation Plan
For Claude: REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
Goal: Close the three reproduced privacy, terminal-transition, and provider-classification findings without coupling durable run specs to a changing model catalog.
Architecture: The typed telemetry boundary validates the harness/model pair against the central controlled catalog and drops unknown values. Operation failure recording treats the failed transition as authoritative and the readable error event as independent best effort. Harness readiness and provider invocation become separate service calls, with event-sink failures typed so internal persistence errors cannot be mistaken for provider failures.
Tech Stack: Python 3.12+, Pydantic models, SQLite run ledger, pytest, Ruff, uv.
Review verdicts#
- Accept the privacy bug; reject catalog validation in durable
RunSpec. Historical queued specs must remain readable when the controlled catalog changes.LifecycleRunCompletedPropertieswill validate the harness/model pair againstHARNESS_MODELS, causingcapture_lifecycleto fail closed before event construction. - Accept the authoritative-transition bug. A readable error event and the terminal run write are separate effects. A safe shared error summary will be computed once; error-event persistence and
runs.finish(...)will each receive their own best-effort boundary. - Accept the provider-classification bug and split the contract.
HarnessesService.ensure_ready(...)owns readiness;run_ready(...)invokes the already-approved adapter. A typed sink wrapper distinguishes caller event-persistence failures from adapter failures occurring during the same call.
Task 1: Reject unknown lifecycle models at the telemetry boundary#
Files:
- Modify:
src/codealmanac/services/telemetry/models.py - Test:
tests/test_run_telemetry.py - Test:
tests/test_telemetry_service.py
- Add a failing lifecycle test whose valid queued
RunSpeccontains path/secret-like model text. - Complete the run and assert the recording sender receives no lifecycle event.
- Add a model-level mismatch test using a controlled model with the wrong harness.
- Validate
LifecycleRunCompletedProperties.modelagainstHARNESS_MODELS[HarnessKind(harness)]in the existing model validator. - Run the focused telemetry tests and confirm both pass.
Task 2: Preserve the authoritative failed transition when event logging fails#
Files:
- Modify:
src/codealmanac/core/errors.py - Modify:
src/codealmanac/workflows/operations/service.py - Test:
tests/test_ingest_workflow.py
- Add a failing test that begins an operation, makes
OperationRunner.record(...)raise, callsfail(..., SOURCE_PREPARATION), and expects a durable failed record with the original category. - Add a failing test whose exception
__str__raises and expect the same durable failed transition with the exception type as its safe message. - Make
error_summary(...)return the exception type when stringification fails. - Replace the shared suppression block in
OperationRunner.fail(...)with one block for the readable error event and a separate block forruns.finish(...). - Run the focused workflow tests.
Task 3: Separate readiness, provider invocation, and event-sink failure#
Files:
- Modify:
src/codealmanac/services/harnesses/service.py - Modify:
src/codealmanac/workflows/operations/service.py - Test:
tests/test_harnesses_service.py - Test:
tests/test_build_workflow.py
- Add a failing build workflow test whose adapter is ready but raises during
run; expectprovider_execution. - Add a failing test whose live event sink raises; expect
internal_error, not provider execution. - Add
HarnessEventSinkFailedcarrying the original sink exception. - Keep
ensure_ready(...)as the readiness verb and replace combinedrun(...)withrun_ready(...), which calls only the selected adapter and wraps sink failures. - In
OperationRunner.execute(...), run readiness and provider invocation in separate try/except blocks. Map readiness exceptions toharness_readiness, sink exceptions tointernal_error, and adapter exceptions toprovider_execution. - Preserve normalized failed-result validation as
provider_execution. - Run focused harness, build, ingest, and garden tests.
Task 4: Update living architecture and verify PR #36#
Files:
- Modify:
almanac/architecture/telemetry.md - Modify:
almanac/architecture/agent-runs/harness-contract.md - Modify:
almanac/architecture/lifecycle/operation-runner.md - Modify:
docs/python-port-live-agreement.md - Modify:
docs/plans/2026-07-15-cli-telemetry-live-agreement.md
- Document controlled model fail-closed behavior, independent failure writes, and the split harness contract.
- Run
uv run pytest,uv run ruff check .,uv run codealmanac validate, andgit diff --check. - Run the full suite on Python 3.13.
- Build/install the wheel and smoke version/config/model validation with telemetry disabled.
- Update the PR validation count, commit only planned files, push, and wait for all GitHub checks.