Skip to content

Commit b4249aa

Browse files
committed
fix(telemetry): add a 15-minute egress window
1 parent ac34090 commit b4249aa

6 files changed

Lines changed: 94 additions & 10 deletions

File tree

‎dashboard/github-egress-telemetry.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,8 @@ export class GithubEgressTelemetryStore {
296296
}
297297

298298
publicObservability(hours: number, now = Date.now()) {
299-
const boundedHours = hours === 1 || hours === 6 || hours === 24 ? hours : null;
299+
const boundedHours =
300+
hours === 0.25 || hours === 1 || hours === 6 || hours === 24 ? hours : null;
300301
if (!boundedHours) return null;
301302
const bucketKind = boundedHours <= 6 ? "five_minute" : "hour";
302303
const windowStart = now - boundedHours * 60 * 60 * 1000;

‎docs/github-egress-telemetry.md‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ curl --fail --silent --show-error \
2525
'https://clawsweeper.openclaw.ai/api/github-egress-observability?hours=6'
2626
```
2727

28-
`hours` accepts only `1`, `6`, or `24`. The response contains closed aggregate
28+
`hours` accepts only `0.25` (15 minutes), `1`, `6`, or `24`. Use the 15-minute
29+
view for periodic collection when a high-cardinality one-hour detail response
30+
would reach the public row cap. The response contains closed aggregate
2931
dimensions and sanitized rate-limit observations. It never contains private
3032
pool identities, repository or item identifiers, branches, raw SHAs, paths,
3133
queries, cursors, URLs, request IDs, ETags, bodies, tokens, or installation IDs.
@@ -140,9 +142,9 @@ class, durable claim generation, first/repeat fact, safe route template, parsed
140142
method/status, and response receive time. Unsafe parsing emits or uploads an
141143
incomplete bounded marker. It never uploads a partially parsed raw frame.
142144

143-
Completeness is computed independently for each requested one-, six-, or
144-
24-hour window. Rollup queries include the complete five-minute or hourly
145-
bucket that overlaps the window's lower boundary, so totals can include at
145+
Completeness is computed independently for each requested 15-minute, one-,
146+
six-, or 24-hour window. Rollup queries include the complete five-minute or
147+
hourly bucket that overlaps the window's lower boundary, so totals can include at
146148
most one bucket of observations immediately before the exact cutoff. Raw
147149
rate-limit observations use the exact cutoff. `rows_truncated` and
148150
`rate_limit_rows_truncated` identify a bounded public response, while
@@ -198,6 +200,10 @@ both five-minute and hourly rollups transactionally and deduplicates upload
198200
retries by producer-run-scoped, content-derived receipt ID. Cap evictions are
199201
cumulative diagnostics and mark affected public windows incomplete.
200202

203+
The 15-minute view does not raise or bypass the public row cap. A collector
204+
must preserve `rows_truncated` and `query_complete` and record a gap if even the
205+
smaller view exceeds the bound.
206+
201207
## Rollback and Phase 1 boundary
202208

203209
Rollback removes the workflow setup and upload steps and the public route. The

‎docs/proof/github-egress-telemetry/README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ rows survive a Worker restart and an identical producer receipt is deduplicated.
2323
- `repository_actions`, `target_app`, and `public_read_fallback` call-site
2424
attribution
2525
- A real signed telemetry upload and public query through `wrangler dev --local`
26+
- The 15-minute public detail query through the same Worker and Durable Object
2627
- The real SQLite Durable Object storage, receipt deduplication, and restart
2728
persistence
2829
- Sentinel scans across workflow JSONL and public output
@@ -58,6 +59,7 @@ schedule, gate, deployment, or credential state.
5859
- A missing observer parser preserves the original throttled command's stderr,
5960
stdout, and exit status while stripping unsafe debug frames.
6061
- Public output withholds pool identity and all raw sentinels.
62+
- The 15-minute view returns `window.hours=0.25` with a complete query.
6163
- Worker restart preserves rows and replaying the same receipt is deduplicated.
6264
- Median loopback observer overhead remains below the proof's one-second safety
6365
ceiling; the measured value is reported, not treated as a production latency

‎docs/proof/github-egress-telemetry/run-proof.mjs‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,12 @@ const candidateHead = process.env.GITHUB_EGRESS_PROOF_SOURCE_SHA || (await gitHe
3131

3232
await mkdir(outputDir, { recursive: true });
3333
await Promise.all(
34-
["proof-summary.json", "public-observability.json", "wrangler.log"].map((name) =>
35-
rm(path.join(outputDir, name), { force: true }),
36-
),
34+
[
35+
"proof-summary.json",
36+
"public-observability.json",
37+
"public-observability-15m.json",
38+
"wrangler.log",
39+
].map((name) => rm(path.join(outputDir, name), { force: true })),
3740
);
3841

3942
const github = createHttpsServer(
@@ -283,8 +286,14 @@ exit 73
283286
assert.deepEqual(duplicateUpload, { accepted: false, deduped: true });
284287
const afterDuplicate = await getJson(`${worker.origin}/api/github-egress-observability?hours=1`);
285288
assert.deepEqual(afterDuplicate.rows, beforeRestart.rows);
289+
const fifteenMinuteView = await getJson(
290+
`${worker.origin}/api/github-egress-observability?hours=0.25`,
291+
);
292+
assert.equal(fifteenMinuteView.window.hours, 0.25);
293+
assertPublicView(fifteenMinuteView);
286294

287295
privacyScan(JSON.stringify(afterDuplicate));
296+
privacyScan(JSON.stringify(fifteenMinuteView));
288297
const baselineMedianMs = median(baselineSamples);
289298
const observedMedianMs = median(observedSamples);
290299
const addedMedianMs = observedMedianMs - baselineMedianMs;
@@ -318,6 +327,7 @@ exit 73
318327
empty_sink_incomplete_invocations: 1,
319328
restart_rows_preserved: true,
320329
duplicate_upload_deduped: true,
330+
fifteen_minute_public_query_complete: fifteenMinuteView.completeness.query_complete,
321331
output_and_exit_preserved: true,
322332
parser_failure_error_preserved: true,
323333
sentinel_privacy_scan_passed: true,
@@ -343,6 +353,10 @@ exit 73
343353
path.join(outputDir, "public-observability.json"),
344354
`${JSON.stringify(afterDuplicate, null, 2)}\n`,
345355
);
356+
await writeFile(
357+
path.join(outputDir, "public-observability-15m.json"),
358+
`${JSON.stringify(fifteenMinuteView, null, 2)}\n`,
359+
);
346360
await writeFile(
347361
path.join(outputDir, "proof-summary.json"),
348362
`${JSON.stringify(summary, null, 2)}\n`,

‎docs/public-api.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ branch, not a promise that every method will remain supported.
2424
| `/api/exact-review-queue/item` | `GET` | One queue item's status; forwards query parameters. |
2525
| `/api/exact-review-queue/reviews` | `GET` | Per-item review lookup used by observer surfaces. |
2626
| `/api/review-observability` | `GET` | Review observability from the queue Durable Object; forwards query parameters. |
27-
| `/api/github-egress-observability` | `GET` | Sanitized publication GitHub egress rollups for `hours=1`, `6`, or `24`. |
27+
| `/api/github-egress-observability` | `GET` | Sanitized publication GitHub egress rollups for `hours=0.25`, `1`, `6`, or `24`. |
2828
| `/api/review-coverage` | `GET` | Review coverage from the queue Durable Object. |
2929
| `/api/apply-observability` | `GET` | Apply-lane observability from `applyObservabilityJson`. |
3030
| `/api/health-history` | `GET` | Historical health from `healthHistoryJson`. |

‎test/github-egress-telemetry.test.ts‎

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ test("signed upload, SQLite restart, retention, cardinality, and public privacy
492492
);
493493
assert.equal(windowStore.publicObservability(1, NOW)?.completeness.observed, false);
494494
assert.equal(windowStore.publicObservability(6, NOW)?.completeness.observed, true);
495+
assert.equal(windowStore.publicObservability(0.5, NOW), null);
495496

496497
const unalignedNow = NOW + 2 * 60 * 1_000;
497498
const firstPartialBucket = unalignedNow - 60 * 60 * 1_000 + 30 * 1_000;
@@ -503,6 +504,18 @@ test("signed upload, SQLite restart, retention, cardinality, and public privacy
503504
assert.equal(oneHourView?.completeness.observed, true);
504505
assert.equal(oneHourView?.units.wire_attempt, 1);
505506

507+
const fifteenMinutesAgo = unalignedNow - 15 * 60 * 1_000 + 30 * 1_000;
508+
assert.equal(
509+
windowStore.ingest(telemetryBody("6".repeat(64), fifteenMinutesAgo), fifteenMinutesAgo).ok,
510+
true,
511+
);
512+
const fifteenMinuteView = windowStore.publicObservability(0.25, unalignedNow);
513+
assert.equal(fifteenMinuteView?.window.hours, 0.25);
514+
assert.equal(fifteenMinuteView?.window.bucket_minutes, 5);
515+
assert.equal(fifteenMinuteView?.completeness.observed, true);
516+
assert.equal(fifteenMinuteView?.completeness.query_complete, true);
517+
assert.equal(fifteenMinuteView?.units.wire_attempt, 1);
518+
506519
const unalignedDayNow = NOW + 30 * 60 * 1_000;
507520
const firstPartialHour = unalignedDayNow - 24 * 60 * 60 * 1_000 + 5 * 60 * 1_000;
508521
assert.equal(
@@ -511,7 +524,55 @@ test("signed upload, SQLite restart, retention, cardinality, and public privacy
511524
);
512525
const oneDayView = windowStore.publicObservability(24, unalignedDayNow);
513526
assert.equal(oneDayView?.completeness.observed, true);
514-
assert.equal(oneDayView?.units.wire_attempt, 3);
527+
assert.equal(oneDayView?.units.wire_attempt, 4);
528+
529+
const highCardinalityStorage = new MemoryDurableStorage();
530+
const highCardinalityStore = new GithubEgressTelemetryStore(highCardinalityStorage);
531+
highCardinalityStore.ensureSchemaSync();
532+
const insertRollup = (bucketStart: number, configRevision: string) =>
533+
highCardinalityStorage.sql.exec(
534+
`INSERT INTO exact_review_github_egress_rollups_v2 (
535+
bucket_kind, bucket_start, deployment_revision, config_revision,
536+
pool_class, pool_identity, stage, source_action, operation, method,
537+
route_template, page_bucket, unit, outcome, status_bucket,
538+
latency_bucket, claim_generation_bucket, first_repeat, attempted,
539+
telemetry_complete, count
540+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
541+
"five_minute",
542+
bucketStart,
543+
"a".repeat(16),
544+
configRevision,
545+
"repository_actions",
546+
"private-pool",
547+
"publication_apply",
548+
"scheduled_normal",
549+
"item_metadata",
550+
"GET",
551+
"issue_metadata",
552+
"none",
553+
"invocation",
554+
"success",
555+
"2xx",
556+
"100_249ms",
557+
"1",
558+
"first",
559+
1,
560+
1,
561+
1,
562+
);
563+
for (let index = 0; index < 2_001; index += 1) {
564+
insertRollup(NOW - 50 * 60 * 1_000, index.toString(16).padStart(16, "0"));
565+
}
566+
insertRollup(NOW - 10 * 60 * 1_000, "f".repeat(16));
567+
const truncatedHour = highCardinalityStore.publicObservability(1, NOW);
568+
assert.equal(truncatedHour?.rows.length, 2_000);
569+
assert.equal(truncatedHour?.completeness.rows_truncated, true);
570+
assert.equal(truncatedHour?.completeness.query_complete, false);
571+
const completeQuarterHour = highCardinalityStore.publicObservability(0.25, NOW);
572+
assert.equal(completeQuarterHour?.rows.length, 1);
573+
assert.equal(completeQuarterHour?.units.invocation, 1);
574+
assert.equal(completeQuarterHour?.completeness.rows_truncated, false);
575+
assert.equal(completeQuarterHour?.completeness.query_complete, true);
515576

516577
const future = NOW + 8 * 24 * 60 * 60 * 1_000;
517578
const futureBody = telemetryBody("f".repeat(64), future);

0 commit comments

Comments
 (0)