Skip to content

Commit 41bdd3b

Browse files
committed
fix: surface missing egress telemetry sinks
1 parent d69df1a commit 41bdd3b

5 files changed

Lines changed: 55 additions & 7 deletions

File tree

‎docs/github-egress-telemetry.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,10 @@ per-route breakdown.
159159

160160
The `gh` wrapper preserves the command's stdout, cleaned non-debug stderr, and
161161
exit status. Observation and upload failures do not fail publication. This
162-
fail-open rule means a completely missing upload cannot report its own absence;
163-
use stage conservation against durable publication starts and workflow results
162+
fail-open rule means an uploader that finds no readable metric records sends
163+
one bounded, incomplete, unattempted invocation marker; it never invents a wire
164+
attempt or member count. A completely missing uploader still cannot report its
165+
own absence, so use stage conservation against durable publication starts and workflow results
164166
to detect that case.
165167

166168
Known incomplete boundaries are explicit:

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ schedule, gate, deployment, or credential state.
4747

4848
## Required result
4949

50-
- 18 invocations conserve to 19 observed wire attempts and one durable member;
51-
one artifact invocation is explicitly opaque and invents no wire count.
50+
- 18 transport invocations conserve to 19 observed wire attempts and one
51+
durable member; one artifact invocation is explicitly opaque and invents no
52+
wire count. A separate missing-sink fixture contributes exactly one
53+
incomplete, unattempted invocation marker and no invented wire/member count.
5254
- The paginated invocation accounts for exactly three page attempts.
5355
- The authoritative 403 produces exactly one sanitized reset observation.
5456
- Public-read fallback and target-App each retain their actual selected pool.

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,16 @@ exit 73
234234
receiptScope: "github-egress-proof:1:loopback",
235235
});
236236
assert.equal(submissions.length, 1);
237+
const emptySinkSubmissions = githubEgressTelemetrySubmissions({
238+
metricsPath: path.join(scratch, "missing-egress.jsonl"),
239+
rateLimitPath: path.join(scratch, "missing-rate-limits.jsonl"),
240+
receiptScope: "github-egress-proof:1:missing-sink",
241+
});
242+
assert.equal(emptySinkSubmissions.length, 1);
243+
assert.equal(emptySinkSubmissions[0].metrics.length, 1);
244+
assert.equal(emptySinkSubmissions[0].metrics[0].unit, "invocation");
245+
assert.equal(emptySinkSubmissions[0].metrics[0].attempted, false);
246+
assert.equal(emptySinkSubmissions[0].metrics[0].telemetryComplete, false);
237247

238248
const workerPort = await availablePort();
239249
let worker = await startWorker(workerPort, persistPath, workerLogPath);
@@ -246,6 +256,13 @@ exit 73
246256
fetch: rewriteFetch(worker.origin),
247257
});
248258
assert.deepEqual(firstUpload, { accepted: true, deduped: false });
259+
const emptySinkUpload = await submitGitHubEgressTelemetry({
260+
baseUrl: "https://proof.invalid",
261+
webhookSecret: proofSecret,
262+
submission: emptySinkSubmissions[0],
263+
fetch: rewriteFetch(worker.origin),
264+
});
265+
assert.deepEqual(emptySinkUpload, { accepted: true, deduped: false });
249266
const beforeRestart = await getJson(`${worker.origin}/api/github-egress-observability?hours=1`);
250267
assertPublicView(beforeRestart);
251268

@@ -298,6 +315,7 @@ exit 73
298315
public_read_fallback_wire_attempts: 1,
299316
target_app_wire_attempts: 1,
300317
incomplete_unknown_route_wire_attempts: 1,
318+
empty_sink_incomplete_invocations: 1,
301319
restart_rows_preserved: true,
302320
duplicate_upload_deduped: true,
303321
output_and_exit_preserved: true,
@@ -559,7 +577,7 @@ function assertPublicView(view) {
559577
assert.equal(view.rate_limit_observations.length, 1);
560578
assert.equal(view.privacy.pool_identity, "withheld");
561579
const totals = countBy(view.rows, "unit");
562-
assert.deepEqual(totals, { invocation: 18, member: 1, wire_attempt: 19 });
580+
assert.deepEqual(totals, { invocation: 19, member: 1, wire_attempt: 19 });
563581
}
564582

565583
function privacyScan(serialized) {

‎src/repair/github-egress-telemetry-client.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export function githubEgressTelemetrySubmissions(options: {
6666
count: Math.min(MAX_COUNT, invalid),
6767
});
6868
}
69+
if (metrics.length === 0) metrics.push(incompleteMetric("missing-input"));
6970
const submissions: GitHubEgressTelemetrySubmission[] = [];
7071
const receiptScope =
7172
options.receiptScope ||
@@ -187,7 +188,7 @@ function aggregateMetrics(values: readonly unknown[]): {
187188
return { metrics: [...metrics.values()], invalid };
188189
}
189190

190-
function incompleteMetric(nowMs = Date.now()): GitHubEgressMetricV2 {
191+
function incompleteMetric(reason = "invalid-input", nowMs = Date.now()): GitHubEgressMetricV2 {
191192
const digest = (value: string, length: number) =>
192193
createHash("sha256").update(value).digest("hex").slice(0, length);
193194
return {
@@ -197,7 +198,7 @@ function incompleteMetric(nowMs = Date.now()): GitHubEgressMetricV2 {
197198
`deployment:v1:${process.env.CLAWSWEEPER_DEPLOYMENT_REVISION || process.env.GITHUB_SHA || "unknown"}`,
198199
16,
199200
),
200-
configRevision: digest("config:v1:invalid-input", 16),
201+
configRevision: digest(`config:v1:${reason}`, 16),
201202
poolClass: "other",
202203
poolIdentity: digest("pool:v1:other", 24),
203204
stage: "unknown",

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,31 @@ test("signed upload, SQLite restart, retention, cardinality, and public privacy
396396
});
397397
assert.notEqual(otherRun[0]?.receiptId, submissions[0]?.receiptId);
398398

399+
const emptySink = githubEgressTelemetrySubmissions({
400+
metricsPath: join(root, "missing-metrics.jsonl"),
401+
rateLimitPath: join(root, "missing-rate-limits.jsonl"),
402+
receiptScope: "test-run:3:missing-sink",
403+
});
404+
assert.equal(emptySink.length, 1);
405+
assert.deepEqual(
406+
emptySink[0]?.metrics.map((metric) => ({
407+
unit: metric.unit,
408+
attempted: metric.attempted,
409+
outcome: metric.outcome,
410+
telemetryComplete: metric.telemetryComplete,
411+
count: metric.count,
412+
})),
413+
[
414+
{
415+
unit: "invocation",
416+
attempted: false,
417+
outcome: "ambiguous",
418+
telemetryComplete: false,
419+
count: 1,
420+
},
421+
],
422+
);
423+
399424
const storage = new MemoryDurableStorage();
400425
const store = new GithubEgressTelemetryStore(storage);
401426
store.ensureSchemaSync();

0 commit comments

Comments
 (0)