Skip to content

feat(telemetry): observe GitHub publication egress - #1140

Merged
brokemac79 merged 5 commits into
mainfrom
codex/csw-123-phase0-egress-telemetry
Aug 12, 2026
Merged

brokemac79 merged 5 commits into
mainfrom
codex/csw-123-phase0-egress-telemetry

Conversation

@brokemac79

@brokemac79 brokemac79 commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • add an observe-only GitHub publication-egress seam around the real gh transport while retaining the existing v1 request metrics
  • attribute bounded v2 member, invocation, wire-attempt, pagination, credential-pool, route, latency, outcome, first/repeat, and reset-header facts
  • retain sanitized aggregates in the existing SQLite Durable Object and expose bounded public 1h/6h/24h observability
  • document exact semantics, privacy/cardinality/retention bounds, known incomplete boundaries, and the Phase 1 exclusion

Related: CSW-123. This is the separate Phase 0 dependency for the future pool-coordinator work. It intentionally does not implement coordinator bindings, epochs, permits, blocked-until decisions, probes, recovery ramps, or any admission/retry enforcement.

Maintainer authorization: Martin explicitly authorized merging and automatically deploying this separate observe-only Phase 0 telemetry PR on 2026-08-12. Phase 1 remains explicitly out of scope.

Problem

Existing v1 metrics count logical request classes but cannot reliably distinguish one command from its paginated HTTP attempts, identify the credential pool actually selected, or preserve sanitized reset-authority evidence. That makes six-hour quota diagnosis underdetermined and leaves no trustworthy denominator for Phase 1.

Implementation

  • A fail-open PATH shim observes GitHub CLI debug frames for safe commands and records one wire attempt per real page. Opaque artifact downloads retain an explicit incomplete invocation without fabricating wire counts.
  • Call sites declare closed descriptors for pool class, stage, source action, claim generation, and durable-revision first/repeat state. Pool identity is privately fingerprinted from the actual credential boundary; public responses expose only pool class.
  • Runtime token selection propagates repository_actions, target_app, and public_read_fallback from the credential actually chosen, never from generic rate-limit prose.
  • Only allowlisted method/operation/route/page/status/latency dimensions survive parsing. Raw repositories, owners, items, branches, SHAs, paths, queries, cursors, URLs, request IDs, ETags, bodies, tokens, and installation IDs are rejected or discarded.
  • Sanitized 403/429 observations retain header presence, bounded numeric values, receive time, and retry_after/rate_limit_reset/absent/invalid candidate provenance. They do not choose a shared reset policy.
  • Signed, receipt-deduplicated submissions aggregate into five-minute and hourly SQLite rollups with fixed row caps and retention. Public queries return truncation/completeness flags plus full-window member/invocation/wire-attempt conservation totals.
  • Observer, parser, and upload failures remain non-fatal. The command's stdout, ordinary stderr, signals, and exit status are preserved; the byte-preserving fallback also protects existing throttle classification if the rich parser is unavailable. If the uploader finds no readable metric records, it emits one incomplete, unattempted invocation marker without inventing a wire attempt or member.
  • Public rollup queries include the complete five-minute or hourly bucket overlapping the lower window boundary; raw rate-limit observations retain the exact cutoff.

first_repeat has one exact meaning: first when publicationFailureAttempts == 0 for the claimed durable item revision, and repeat when that same revision already has at least one charged publication failure. It is not an HTTP retry, pagination page, batch membership, or claim-generation grouping.

Validation

Current base: f0dd69f75573e6ac592d5b8c218bbda245fc2b1a
Current head: 41bdd3bd2ad97475ce36d63f975ee4adc03b8a43

  • pnpm run check:static
  • pnpm run build:all
  • pnpm run lint
  • node --test test/github-egress-telemetry.test.ts — 7/7
  • node --test --test-name-pattern="exact-review lease competition" test/sweep-workflow.test.ts — 1/1
  • node --test --test-name-pattern="github egress|exact-review queue" test/dashboard-worker-queue-runtime.test.ts — 45/45
  • Linux container: telemetry, publication-batch, batch CLI/prepare/workflow, and state-writer suites — 113/113
  • git diff --check origin/main...HEAD
  • actionlint on the two touched workflows: no new diagnostic class versus current origin/main
  • ShellCheck on scripts/github-egress-observer.sh: only SC2317 informational reports for trap-invoked functions
  • dirty Codex review: accepted and fixed missing target-owner member attribution; final pass clean
  • committed Codex review: accepted and fixed parser-failure stderr suppression, unterminated-record handling, partial-window bucket omission, and the empty-sink conservation blind spot; final codex review --base origin/main clean
  • pnpm run review -- --local-range --target-repo openclaw/clawsweeper --base origin/main: decision=keep_open confidence=high action=kept_open; local-only, no GitHub mutation

The full native-Windows aggregate suite also reproduces current-main platform noise: hosted-Linux Bash tests cannot find WSL /bin/bash, and unrelated concurrent temporary-root cleanup tests can fail with EPERM. No platform-policy or unrelated test-harness changes are included; the affected Linux surfaces pass in the container lane above.

Real Behavior Proof

Claim

The production observation seam counts real GitHub CLI HTTP pages and attributes the actual selected credential pool without changing command behavior or exposing raw identifiers. Its signed aggregates survive Worker restart, dedupe replayed receipts, and fail open when parsing is unsafe or unavailable.

Exercised surface

  • exact head 41bdd3bd2ad97475ce36d63f975ee4adc03b8a43
  • Docker-backed Crabbox provider=local-container, lease cbx_a8d87f6084a7, Node 24 Bookworm, exit 0
  • GitHub CLI 2.88.1 over an unmocked loopback TLS HTTP server
  • production shell shim and built parser/CLI
  • real Wrangler 4.107.0 local Worker and SQLite-backed ExactReviewQueue Durable Object
  • signed upload, restart persistence, receipt replay, public query, and privacy sentinel scan

Scenario and observed result

The fixture executed repository-Actions, target-App, and public-read-fallback calls; a three-page REST request; a 403 with Retry-After and X-RateLimit-*; an unknown route; and an opaque artifact download. It then removed the rich parser and repeated a throttled command, including an unterminated ordinary-stderr case, and exercised an absent telemetry sink.

  • 18 invocations conserved to 19 observed wire attempts and 1 durable member
  • pagination accounted for exactly 3 page attempts
  • wire attempts: 17 repository_actions, 1 target_app, 1 public_read_fallback
  • exactly 1 sanitized rate-limit observation with authoritative candidate data
  • exactly 1 unknown-route wire attempt marked incomplete
  • exactly 1 missing-sink incomplete invocation, unattempted and with no invented wire/member count
  • stdout, ordinary stderr, and exit status matched direct CLI behavior
  • missing-parser fallback preserved throttle text and unterminated stderr while stripping debug frames
  • rows and rate-limit observations survived Worker restart
  • duplicate receipt was deduplicated
  • private/raw sentinels were absent from stored submissions and public output
  • median added loopback observer overhead was 38.6 ms across 12 baseline and 12 observed samples (process-launch measurement, not a production latency forecast)
  • production mutations: 0; OpenClaw Bay affected: false

Proof package: docs/proof/github-egress-telemetry/README.md and run-proof.sh. The exact-head run used a fresh clone of the pushed branch because Windows-to-local-container rsync failed before execution with code 12; Crabbox performed no local dirty-tree sync (syncSkipped=true) and verified the remote HEAD before running.

Limits

  • Responses are deterministic loopback fixtures; the proof does not consume or deliberately exhaust live GitHub quota.
  • gh run download remains intentionally opaque because binary redirects cannot be safely parsed from debug output.
  • This proves observation and conservation only, not Phase 1 admission, shared circuits, permits, probes, or ramp behavior.

Risks and rollout

  • The observer adds a process/parser boundary around publication gh calls; measured loopback overhead is bounded but production latency must be observed over six complete quota windows.
  • An uploader with no readable metrics emits one bounded incomplete invocation, but an uploader that never starts still cannot report itself. Operators must compare member/invocation/wire conservation against existing durable lifecycle and workflow counters.
  • Public detail is capped and explicitly marked truncated/incomplete; private pool identity remains internal.
  • Existing v1 metrics continue in parallel, so current dashboards and retry behavior remain compatible.
  • This PR touches workflow files and therefore carries GitHub OAuth/workflow-scope risk; a maintainer-owned replacement branch may be required by policy.

Bay impact is observe-only: no queue, gate, schedule, hot cadence, batch size/concurrency, retry budget, credential, or production-state setting changes. After merge/deployment, collect six complete quota windows before authorizing Phase 1.

Rollback is a commit revert: remove the observer setup/upload steps and public route. Existing v1 metrics and publication behavior continue; retained v2 tables become inert and require no queue drain or data migration.

Release note

Internal operations telemetry only; no user-facing behavior change.

@clawsweeper

clawsweeper Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@brokemac79

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 12, 2026
@clawsweeper

clawsweeper Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 12, 2026, 8:39 AM ET / 12:39 UTC.

ClawSweeper review

What this changes

Adds an observe-only wrapper around publication-time GitHub CLI calls, signed bounded telemetry rollups, and a read-only operator endpoint for GitHub egress diagnostics.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open for a release-owner decision: this is a meaningful new observer-only telemetry feature, not work already present on current main, and the supplied boundary proof is strong enough for maintainer review.

Priority: P2
Reviewed head: 41bdd3bd2ad97475ce36d63f975ee4adc03b8a43
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The PR has strong real-boundary proof and no actionable patch defect, while its large credentialed workflow and public-contract surface still needs release-owner approval.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The PR body provides after-fix local-container evidence through real gh, the production observer path, and a real local Worker/Durable Object with observable recovery and privacy results.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The PR body provides after-fix local-container evidence through real gh, the production observer path, and a real local Worker/Durable Object with observable recovery and privacy results.
Evidence reviewed 7 items Current-main boundary: Current main prepares GitHub credentials but has no v2 egress-observer environment or rollup path, so it does not already provide the requested per-wire publication telemetry.
Credentialed transport seam: The branch captures the existing gh binary before prepending its PATH shim and writes only validated observer settings to the workflow environment.
Fail-open behavior: The shim preserves the real command exit status and uses a conservative stderr scrubber if the richer parser fails.
Findings None None.
Security None None.

How this fits together

Exact-review publication workflows call GitHub through the CLI to publish review results. This change observes those calls, sends sanitized aggregates to the queue Durable Object, and exposes rollups to operators without changing admission or retry policy.

flowchart LR
  A[Exact review queue] --> B[Publication workflows]
  B --> C[GitHub CLI observer]
  C --> D[GitHub API]
  C --> E[Signed telemetry upload]
  E --> F[Durable Object rollups]
  F --> G[Read-only operator API]
Loading

Decision needed

Question Recommendation
Should this observe-only credentialed-publication telemetry feature be authorized for merge and deployment as Phase 0 now? Authorize Phase 0 rollout: Merge the observer-only change, retain existing v1 behavior in parallel, and review six complete quota windows before considering Phase 1.

Why: The PR body records separate Phase 0 authorization but expressly leaves merge and deployment unauthorized; that release decision cannot be inferred from code, tests, or proof.

Before merge

  • Resolve merge risk (P1) - Merging installs a PATH-level observer around credentialed publication calls; despite the fail-open design, production should verify unchanged command behavior and egress overhead through the planned six complete quota windows.
  • Resolve merge risk (P1) - The new public observability contract and retained rollups need an explicit release-owner decision before deployment, because Phase 1 enforcement must remain out of scope.
  • Complete next step (P2) - A release owner must decide whether to deploy the credentialed PATH observer and public telemetry contract; no narrow automated repair is identified.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Change size 28 files, +4,413 / -13 lines The feature spans workflow, transport, Durable Object, public API, docs, proof, and tests, so it merits release-owner review as one operational change.
Production versus tests production +3,765, tests +648 Most growth implements the observer and rollup contract; focused tests cover the new telemetry surface.

Merge-risk options

Maintainer options:

  1. Authorize an observe-only rollout (recommended)
    Accept the bounded workflow and credential-path risk for Phase 0, then use six production quota windows to validate conservation and overhead before any enforcement work.
  2. Hold for release-owner approval
    Keep the branch in draft state if the release owner does not yet want a PATH-level observer around credentialed publication calls.

Technical review

Best possible solution:

Authorize only the Phase 0 observer rollout, monitor six complete production quota windows, and keep admission, circuit, permit, probe, and recovery enforcement out of scope until that evidence is reviewed.

Do we have a high-confidence way to reproduce the issue?

Not applicable as a bug reproduction: this is a new telemetry capability, and the PR supplies a current-head real-boundary proof run for the proposed behavior.

Is this the best way to solve the issue?

Yes, conditionally: an observe-only, bounded, signed sidecar is the narrowest path to gather the denominator needed before any admission or retry policy change.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against f0dd69f75573.

Labels

Label justifications:

  • P2: This is a bounded internal operations feature with meaningful credentialed-publication impact but no demonstrated active user outage.
  • merge-risk: 🚨 automation: The PR changes two publication workflows and adds a composite action that intercepts GitHub CLI execution.
  • merge-risk: 🚨 security-boundary: The PATH observer runs beside credentials and sends signed telemetry through an internal authenticated route.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The PR body provides after-fix local-container evidence through real gh, the production observer path, and a real local Worker/Durable Object with observable recovery and privacy results.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix local-container evidence through real gh, the production observer path, and a real local Worker/Durable Object with observable recovery and privacy results.

Evidence

What I checked:

Likely related people:

  • Martin Cleary: Introduced recent GitHub-quota handling in the runtime path and is named in the PR’s stated Phase 0 authorization. (role: publication-runtime contributor; confidence: high; commits: cd4892391195, 91272a65e6ff; files: src/clawsweeper-github-runtime.ts, .github/workflows/sweep.yml)
  • steipete: Recent commits substantially maintain the queue and dashboard surfaces receiving the signed telemetry and public query. (role: recent queue and dashboard contributor; confidence: high; commits: a1795973a9e6, 6bf7f483fb03, 5a964dadc813; files: dashboard/exact-review-queue.ts, dashboard/worker.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record the release-owner merge/deployment decision and perform the promised six-window production observation before starting Phase 1.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (5 earlier review cycles)
  • reviewed 2026-08-12T11:56:01.685Z sha 90e0d60 :: needs changes before merge. :: [P2] Verify the downloaded GitHub CLI before executing it
  • reviewed 2026-08-12T12:01:11.170Z sha 90e0d60 :: found issues before merge. :: [P2] Verify the downloaded GitHub CLI before executing it
  • reviewed 2026-08-12T12:08:51.387Z sha 7d0762a :: found issues before merge. :: [P2] Verify the fallback GitHub CLI before execution
  • reviewed 2026-08-12T12:15:39.248Z sha 7d0762a :: needs changes before merge. :: [P2] Verify the fallback GitHub CLI before execution
  • reviewed 2026-08-12T12:31:10.286Z sha 41bdd3b :: needs maintainer review before merge. :: none

@brokemac79

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 12, 2026
@brokemac79

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@brokemac79
brokemac79 marked this pull request as ready for review August 12, 2026 12:56
@brokemac79
brokemac79 requested a review from a team as a code owner August 12, 2026 12:56
@brokemac79
brokemac79 merged commit ac34090 into main Aug 12, 2026
25 checks passed
@brokemac79
brokemac79 deleted the codex/csw-123-phase0-egress-telemetry branch August 12, 2026 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant