Skip to content

feat(telemetry): opt-in local telemetry + fix swarm fork description scope#15

Merged
qxbyte merged 1 commit into
mainfrom
telemetry-and-swarm-description-scope
May 18, 2026
Merged

feat(telemetry): opt-in local telemetry + fix swarm fork description scope#15
qxbyte merged 1 commit into
mainfrom
telemetry-and-swarm-description-scope

Conversation

@qxbyte
Copy link
Copy Markdown
Owner

@qxbyte qxbyte commented May 18, 2026

Summary

  • Opt-in local telemetry (~/.specode/telemetry.jsonl) for spec/swarm flow analysis. Enabled by SPECODE_TELEMETRY=on; absolutely no remote upload. Records spec lifecycle, INV violations (with spec_slug/phase), and task-swarm run/stage/round events. Add spec_state.py telemetry-summary for local aggregation.
  • Fix task-swarm fork description scope drift: r2 coder dispatched by validator-fail-fix was rendering as "修复 N 个 P0" in the UI, misleading observers into thinking reviewer triggered a fix loop (reviewer is advisory and never does). Description now carries [scope] and commands/task-swarm.md tells the orchestrator to copy <json.description> verbatim. agents/task-swarm-validator.md also forbids P0/P1/P2 severity labels in fix guidance — those tags are reviewer terminology.

Why bundled

Both stem from the same problem domain — making flow execution observable without misleading the observer. The description-scope fix surfaced while writing telemetry instrumentation, when state.json inspection of a real run (design-login-page, stage 5 checkpoint) confirmed the state machine was healthy but the human-facing description was lying.

Telemetry details

Event Trigger
spec.init spec_init.py after spec dir created
spec.phase_transition / spec.end spec_session.update_config_session
inv.violation spec_guard.py on each INV-1..9 deny branch
swarm.run_start / swarm.stage_round / swarm.stage_done / swarm.writeback / swarm.run_end task_swarm.py
  • File rotates to .jsonl.0 once it passes SPECODE_TELEMETRY_MAX_BYTES (default 50 MB).
  • All IO errors swallowed — telemetry must never break a hook.
  • audit/<date>.log (always-on hook-decision audit) untouched and complementary.

Test plan

  • python3 -m pytest plugins/specode/tests/ -q154 passed (138 prior + 13 telemetry + 3 _fork_description).
  • Manual CLI smoke: SPECODE_TELEMETRY=on python3 scripts/spec_state.py telemetry-summary shows by-event counts, INV top-list, per-spec aggregates, swarm avg rounds per stage.
  • Opt-out smoke: emit with SPECODE_TELEMETRY unset does not create the file.
  • _fork_description(5, "coder", 2, "validator-fail-fix", "...")阶段 5 coder-r2 [validator-fail-fix]: .... No "P0" in output.

🤖 Generated with Claude Code

…scope

Two changes bundled — both stem from making spec/swarm flow execution
observable without misleading the observer:

1. Local telemetry (opt-in, no remote upload)
   - scripts/spec_telemetry.py: emit(event, **fields) gated by
     SPECODE_TELEMETRY=on. Single ~/.specode/telemetry.jsonl,
     append-only, grep/jq-friendly. Rotates to .0 past
     SPECODE_TELEMETRY_MAX_BYTES (default 50 MB). All IO errors
     swallowed so telemetry never breaks a hook.
   - Instrumented: spec.init / spec.phase_transition / spec.end /
     inv.violation (INV-1..9 with spec_slug + phase) /
     swarm.run_start / swarm.stage_round / swarm.stage_done /
     swarm.writeback / swarm.run_end.
   - spec_state.py telemetry-summary aggregates the file locally
     (event counts, INV top-list, per-spec phase/violation totals,
     swarm avg rounds per converged/failed stage).

2. task-swarm fork description now carries scope
   - Previously a checkpoint stage's r2 coder shipped as
     "阶段 N coder-r2: <title>" with no scope, and the orchestrator
     commonly improvised "修复 N 个 P0" off the validator outbox,
     reading as if reviewer triggered a fix loop (reviewer is
     advisory and never does).
   - task_swarm.py: _fork_description now adds [scope] (e.g.
     [validator-fail-fix] / [advisory] / [re-run]).
   - commands/task-swarm.md: tells the orchestrator to copy
     <json.description> verbatim.
   - agents/task-swarm-validator.md: forbids P0/P1/P2 severity
     labels in fix guidance (reviewer terminology; validator fail
     is itself blocking).

Tests: +16 cases (13 telemetry, 3 _fork_description). Full suite
154 passed.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@pronto-qxbyte
Copy link
Copy Markdown

pronto-qxbyte Bot commented May 18, 2026

PRonto 评审

PR: #15 feat(telemetry): opt-in local telemetry + fix swarm fork description scope
作者: @qxbyte
分支: telemetry-and-swarm-description-scope -> main

概览

新增本地遥测功能,代码质量良好,测试覆盖全面。

问题清单

  • ✅ 未发现明显问题

建议改进

  • 考虑为遥测文件路径添加目录创建逻辑,避免路径不存在时静默失败

PRonto via deepseek-chat

@qxbyte qxbyte merged commit 25042c6 into main May 18, 2026
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