Skip to content

Promote PR #106: telemetry_policy canary — headers from canon at runtime#107

Merged
klappy merged 1 commit intoprodfrom
main
Apr 18, 2026
Merged

Promote PR #106: telemetry_policy canary — headers from canon at runtime#107
klappy merged 1 commit intoprodfrom
main

Conversation

@klappy
Copy link
Copy Markdown
Owner

@klappy klappy commented Apr 18, 2026

Promotes

Preview smoke — PASSED (canon-change-no-redeploy verified)

Preview worker built at commit af861a7 (canary feature, before Description-column fix); main canon had #102 (Description column) merged after that build; smoke hit preview and got:

  • governance_source: "canon"
  • 8/8 headers
  • Full canon Description text returned (e.g. x-oddkit-client: "Your client name (highest priority identifier). Examples: claude-desktop, truthkit-cli, your-company-agent.")

This is the capability PR #100 lacked. Canon updated → tool updated → no worker redeploy.

What to verify in prod after merge

  1. curl POST https://oddkit.klappy.dev/mcptelemetry_policy returns governance_source: "canon" and 8 headers with full Description text
  2. If governance_source returns "minimal", canon fetch failed — inspect but not a rollback condition (tool remains functional)
  3. If telemetry_policy returns an error envelope, rollback within 15 min

Rollback procedure

git revert this merge commit in a new branch, PR to prod, merge. No forward-fix in prod.

Not in this PR

  • Bundled baseline tier (tier 2 of the three-tier stack) — requires manifest + build-time schema check, deferred to follow-up
  • oddkit_baseline_check probe — deferred to follow-up
  • The canon contract klappy.dev#101 stays status: draft until the follow-ups land

Note

Medium Risk
Moderate risk: changes the telemetry_policy tool response shape and introduces runtime parsing of a canon markdown table, so failures or doc-format drift could degrade the output (though it falls back to a minimal baseline).

Overview
telemetry_policy now attempts to fetch canon/constraints/telemetry-governance.md at runtime and parse the Self-Report Fields table to populate self_report_headers from canon (using the Description column), enabling canon updates to change output without redeploy.

The tool response now includes governance_source (canon vs minimal) and falls back to a hardcoded minimal set of eight headers plus a default policy message when canon fetch/parsing fails.

Markdown table parsing was factored into a new shared parseTableRow helper (workers/src/markdown-utils.ts) and the governance parser test suite was extended to validate the telemetry headers extraction/degradation behavior.

Reviewed by Cursor Bugbot for commit aae64f9. Bugbot is set up for automated code reviews on this repo. Configure here.

…me (#106)

* feat(telemetry_policy): canary refactor — headers from canon at runtime

Replaces the hardcoded self_report_headers dictionary with a runtime
parse of canon/constraints/telemetry-governance.md #### Self-Report
Fields table. Response envelope now declares governance_source:
'canon' when the fetch succeeds and the table parses, 'minimal' when
it falls back to the shipped baseline.

This is the canary refactor for the governance anti-pattern sweep
(docs/oddkit/audit/governance-anti-pattern-sweep-2026-04-17). It
conforms to the three-tier resolution contract drafted in
klappy/klappy.dev#101 (canon/constraints/core-governance-baseline),
exercising tiers 1 (live canon) and 3 (minimal baseline in code).
Tier 2 (bundled baseline directory with manifest) and the build-time
schema check arrive in follow-up work once the contract graduates
from status:draft to status:active.

Implementation:
- New helper parseSelfReportHeadersTable in index.ts parses the
  '### Self-Report Fields' table section from the canon doc.
- Parser is permissive (whitespace + backticks) and fails closed to
  null so the caller falls back to the minimal baseline rather than
  hiding the degradation.
- Minimal baseline remains the 8 stable headers; canon controls the
  descriptions once live.

Verified:
- npm run typecheck: clean
- Parser unit-tested against live canon content: 8/8 headers parsed
- Parser degradation paths (no section, empty table) return null

Refactor discipline this commit follows (from PR #100 post-mortem):
- Single feature PR, single site touched
- Public contract (MCP tool response) changes are additive
  (governance_source field added; self_report_headers keys unchanged)
- Preview smoke against live prod will verify canon-tier response
  before promotion

* refactor(workers): extract parseTableRow to shared markdown-utils

* fix(telemetry_policy canary): read Description column + add parser tests

Addresses execution-mode challenge gaps on PR #106:

1. Information regression fixed: parser now reads canon's column 4
   (Description) instead of column 0 (Field label). Canon was extended
   with richer per-header descriptions in klappy/klappy.dev#102; this
   commit updates the parser to consume that new column.
2. Tests committed: Test 8 added to
   workers/test/governance-parser.test.mjs covering 8/8 header extraction,
   non-trivial description lengths, and degradation paths (no section,
   empty table). All 105 tests pass against the unmerged klappy.dev
   branch via KLAPPYDEV_RAW override.

Still outstanding (follow-up work, not blocking the canary):
- parseTableRow duplicated across workers/src/index.ts and
  workers/src/orchestrate.ts. Accepted duplication for now, flagged in
  both sites; export-and-share refactor lands when the sweep surfaces
  more duplication candidates.
- Preview smoke against Cloudflare preview with the extended canon
  loaded but no worker redeploy — run manually after this PR deploys.

Companion PR: klappy/klappy.dev#102 (canon extension). This worker
change is backward-compatible with the old 3-column table: the parser
requires 4 cols, so against the old canon it falls through to the
minimal baseline tier. Once klappy.dev#102 merges, canon tier takes
over.

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
oddkit aae64f9 Commit Preview URL

Branch Preview URL
Apr 18 2026, 10:28 PM

@klappy klappy merged commit 204ad1e into prod Apr 18, 2026
5 checks passed
klappy added a commit that referenced this pull request Apr 19, 2026
…vise priority

Canary (telemetry_policy self_report_headers reading from canon) shipped
to prod via oddkit#106 + #107 and klappy.dev#102 (canon extension).
Live smoke confirms governance_source: 'canon' with 8/8 canon-sourced
descriptions.

Corrections to the audit:
- telemetry_policy was originally classified CLEAN but carried a
  hardcoded header dictionary next to the canon-fetched policy prose —
  the same anti-pattern class. Reclassified to LOW severity (drift,
  not correctness) and selected as the canary. Now ✅ shipped.
- Refactor priority revised during planning after the canary was
  selected. New order: canary (✅ done) → validate+preflight bundled →
  mode-enum collapse → orient → gate → encode. Lessons-first-smallest
  sequencing rather than raw severity.

Validate+preflight moves up because it's a correctness bug, not drift:
validate gates 'done' but never reads canon/constraints/definition-of-done.md
(which doesn't exist yet). First step is writing that canon doc.
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