Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions .agents/briefs/calibration.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
# Findings rejected in the 4 weeks to 2026-10-12
# Findings rejected in the 4 weeks to 2026-10-13

Each line below was raised as blocking and rejected when it was verified against the code,
with the reason after the dash. A finding like one of these is right only with evidence that
distinguishes it from the rejected one: name the input or state that makes this one differ.

Written by `node .agents/scripts/delivery-stats.mjs --calibration`; 442 rejected findings in all.
Written by `node .agents/scripts/delivery-stats.mjs --calibration`; 470 rejected findings in all.

## spec review

- #456 src/leasing/lease-acquisition-coordinator.ts:720 no test shows `#heldByOlder` holds back a device for every older matching waiter — the maintainer accepted it as reviewed
- #456 src/leasing/lease-acquisition-coordinator.ts:767 a failing lease write repeats the presence read without pause — not reproduced: 20 flushes gave 1 call
- #456 src/leasing/lease-acquisition-coordinator.ts:183 UNKNOWN_MODEL loses osVersion on the wire — a worker puts no details on the wire for any UNKNOWN_MODEL
- #456 src/gateway/fleet-coordinator.test.ts:4554 forwarded input not checked for physical — the title names the virtual request, not what was forwarded
- #455 e2e/helpers/env.ts:248 the new waitFor branch has no test that goes red [testing 3] — not blocking: testing 3 covers production code; this is an e2e helper
- #453 src/daemon/main.test.ts:693 count read with no macrotask settle after the write is reached, so a mutant passes — not true: making startup run `void leasing.settleRequests()` fails the test (expected 2 to be 1)
- #449 `src/core/physical-enrollment.test.ts:305` no test proves INTERNAL for a throwing inspection — titles now match bodies; `dispatcher.test.ts:3392` proves pass-through
- #449 `src/contract/protocol.ts:16` the comment no longer names `device.add` as the reason for the bump — rule 17 forbids it; Done when 7 was changed
- #496 src/core/doctor.test.ts:463 optionalModules order unproven — duplicate of the code finding, fixed there
- #495 supervisor.test.ts:1099 "removes the record" unproven — duplicate of the code finding, fixed there
- #495 supervisor.ts:248 start-failed remedy points to an empty log — duplicate of the code finding at :244, fixed there
- #463 src/gateway/fleet-coordinator.ts:1093 assumption contradicts spec "That code does not change" — not blocking: Done when 8 needs the change; one extra dispatch, never a wrong device
- #463 src/core/physical-presence.ts:15 memory survives device remove — not blocking: recorded Assumption, self-heals within one probe interval
- #461 src/drivers/ios/physical.ts:77 ECID matching needs `context.source`, missing before Node 22 — not blocking: package.json engines require node >=22
- #458 src/core/doctor.ts:240 stalled-transition-detected moved before the fix — detection before its effect; no doc states the old order; a spec test needs it
- #458 src/contract/schemas.test.ts:609 title claims the worker view — it parses devices with the same schema; worker-view.test.ts:64 proves it

## code review

- #456 e2e/physical-devices-core.test.ts:202 title claims the retry waits for retryBackoffMs — the title only says when the record is ready, which the body proves
- #456 src/leasing/lease-acquisition-coordinator.ts:660, :601, :384 test `request.physical` instead of `lineOf` — they pick a flow, not a queue line; no input diverges
- #456 src/gateway/fleet-coordinator.ts:1347 and src/gateway/routing.ts:44 repeat the physical/virtual split — they choose stages or the forwarded model, not a queue line
- #456 src/leasing/lease-acquisition-coordinator.ts:755 isActive check untested — unreachable today; spec line 179 asks for it as a guard
- #455 e2e/helpers/env.ts:248 a startDaemon timeout before activeEnvs.add leaks the daemon — not blocking: only a live daemon that never writes admin.token for 30 s
- #455 e2e/helpers/env.ts:246 the comment's "every later CLI call" is false after SIGKILL (tests lens) — duplicate of the claims finding at env.ts:246, fixed there
- #457 src/daemon/server.test.ts:1043 the comment names a holder that does not exist — duplicate of the comment review finding, fixed there
- #454 src/core/testing.ts:74 doc comment is a what-comment — duplicate of the comment review finding, fixed there
- #495 supervisor.test.ts:1099 deleting removeRecord stays green — duplicate of the spec finding, fixed
- #495 supervisor.ts:745 stop-waiter removal untested — the leak is not observable without asserting private state
- #494 participants called inside decisions.run (lease-release-coordinator.ts:173) — duplicate of the spec finding, fixed there
- #468 src/leasing/create-leasing.test.ts:3959 (also :4009, fleet-coordinator.test.ts:4837) fail only by a 5 s timeout without the waiting-request check — they still fail, because the second request is never refused.
- #463 src/core/physical-presence.ts:23 last finished read wins over a newer one — not blocking: transient, self-heals at next watcher read, no wrong device
- #461 src/drivers/ios/physical.ts:390 timed-out read deletes its file right after SIGTERM — not blocking: a stray temp file, no wrong state or rule breach
- #461 src/drivers/ios/index.ts:1555 simctl on an Android physical lease names `devicectl` — not blocking: Android inspectPhysical refuses every device, so no such lease exists
- #458 src/leasing/physical-device-watcher.ts:202 a grant does not reset the miss count — the spec names the resets; a grant is not one

## claims review

- #468 src/leasing/lease-acquisition-coordinator.ts:299 cites ADR 0023, not in docs/internal/adr/ — ADR 0023 is accepted on draft PR #465, merged by the maintainer.
- #468 docs/EVENTS.md:26 "one-lease-per-requester" wording is stale — the default limit is still 1; the name is dated, not false.
- #468 src/leasing/lease-acquisition-coordinator.ts:322 "one-lease-per-requester check" is stale — it still describes the default limit.
- #462 src/daemon/dispatcher.ts:135 execEnv doc says driver keys are "layered on top"; unsetEnv now removes keys — not blocking: still true of the layering; unsetEnv is documented at the use site
- #458 src/leasing/lease-release-coordinator.ts:86 set doc omits return reclaims — incomplete, not false; deleted under rule 17
- #458 src/contract/schemas.ts:204, src/core/doctor.ts:257, src/core/registry.ts:123 — each gives a why
- #458 src/daemon/server.test.ts:2032, :3087, src/leasing/lease-release-coordinator.ts:165, :274 — each gives a why (round 2)
- #456 src/gateway/queue.ts:15 `FleetLeaseRecord` doc points at another module — the maintainer accepted it as reviewed
- #456 src/gateway/fleet-coordinator.ts:90 and src/gateway/worker-registry.ts:112 cite an ADR — rule 17 allows ADR citations; both give a why
- #456 docs/internal/COMPONENTS.md:69 says missingApps is committed — it rides the committed transition's event; misleads at most
- #456 docs/CLI.md:549 describes a reclaim the real drivers cannot run yet — the doc states the feature's end state
- #456 docs/CLI.md:818 "not judged against a worker's catalog" — matches the spec's interim wording
- #456 docs/CLI.md:1337 self-contradicting sentence — confusing, but true
- #456 src/mcp/server.ts:126 description omits physical — incomplete, not false
- #456 20 comment findings rejected as giving a why or documenting a client-exported shape (e2e/fake-driver/fake-driver.ts:587, src/cli/index.ts:958, src/contract/operations.ts:171, :181, src/contract/schemas.ts:321, :1049, src/core/domain.ts:24, src/core/driver.ts:113, :115, :326, :357, :364, src/core/reclaim-coordinator.test.ts:290, src/drivers/android/index.ts:910, :1000, src/drivers/ios/index.test.ts:1070, src/gateway/routing/pipeline.ts:31, src/leasing/lease-acquisition-coordinator.ts:142, src/leasing/wait-queue.ts:166, :363)
53 changes: 30 additions & 23 deletions .agents/scripts/delivery-stats.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,26 @@ function ghJson(args) {
.map((line) => JSON.parse(line));
}

// why: `gh api --paginate` follows Link headers to numeric-ID repository URLs, which a cloud
// session's GitHub proxy refuses, so pages are requested by number against the repo-scoped path.
function ghPaged(path, fields) {
const items = [];
for (let page = 1; ; page++) {
const batch = ghJson([
path,
...fields.flatMap((f) => ["-f", f]),
"-f",
"per_page=100",
"-f",
`page=${page}`,
"--jq",
".[] | @json",
]);
items.push(...batch);
if (batch.length < 100) return items;
}
}

function fetchFromGitHub(now, weekCount) {
const repo = repository();
const since = new Date(now.getTime() - weekCount * WEEK_MS);
Expand All @@ -80,29 +100,16 @@ function fetchFromGitHub(now, weekCount) {
]);
Object.assign(pr, d);
}
const handoffs = ghJson([
`repos/${repo}/issues/comments`,
"-f",
`since=${since.toISOString()}`,
"-f",
"per_page=100",
"--paginate",
"--jq",
'.[] | select((.body // "") | startswith("## Handoff"))' +
' | {issue: (.issue_url | split("/") | last | tonumber), createdAt: .created_at, body} | @json',
]);
const needsHardware = ghJson([
`repos/${repo}/issues`,
"-f",
"state=open",
"-f",
"labels=needs-hardware",
"-f",
"per_page=100",
"--paginate",
"--jq",
".[] | select(.pull_request) | {number, title} | @json",
]);
const handoffs = ghPaged(`repos/${repo}/issues/comments`, [`since=${since.toISOString()}`])
.filter((c) => (c.body ?? "").startsWith("## Handoff"))
.map((c) => ({
issue: Number(c.issue_url.split("/").at(-1)),
createdAt: c.created_at,
body: c.body,
}));
const needsHardware = ghPaged(`repos/${repo}/issues`, ["state=open", "labels=needs-hardware"])
.filter((i) => i.pull_request)
.map((i) => ({ number: i.number, title: i.title }));
return { now: now.toISOString(), prs, handoffs, needsHardware };
}

Expand Down
48 changes: 47 additions & 1 deletion src/delivery-stats.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { execFileSync } from "node:child_process";
import { mkdtempSync, writeFileSync } from "node:fs";
import { chmodSync, mkdtempSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
Expand Down Expand Up @@ -268,4 +268,50 @@ describe("delivery-stats.mjs", () => {
"- #30 feat(ios): boot a watch",
]);
});

it("reads GitHub by numbered pages, so a second page of comments is read and no --paginate is passed", () => {
const dir = mkdtempSync(join(tmpdir(), "delivery-stats-gh-"));
const handoff = (issue: number): object => ({
issue_url: `https://api.github.com/repos/o/r/issues/${issue}`,
created_at: new Date().toISOString(),
body: `## Handoff\n\n### Blocked on\n\nmaintainer ${issue}`,
});
const chatter = { issue_url: "https://api.github.com/repos/o/r/issues/1", body: "hello" };
const pages = {
"repos/o/r/issues/comments": [
[handoff(7), ...Array.from({ length: 99 }, () => chatter)],
[handoff(8)],
],
"repos/o/r/issues": [
[
{ number: 30, title: "waits", pull_request: {} },
{ number: 31, title: "plain issue" },
],
],
} as Record<string, object[][]>;
writeFileSync(join(dir, "pages.json"), JSON.stringify(pages));
writeFileSync(
join(dir, "gh"),
`#!${process.execPath}
const { readFileSync } = require("node:fs");
const args = process.argv.slice(2);
if (args.includes("--paginate")) { console.error("HTTP 403: numeric-ID path"); process.exit(1); }
const pages = JSON.parse(readFileSync(${JSON.stringify(join(dir, "pages.json"))}, "utf8"));
const page = Number((args.find((a) => a.startsWith("page=")) ?? "page=1").slice(5));
for (const item of (pages[args[3]] ?? [])[page - 1] ?? []) console.log(JSON.stringify(item));
`,
);
chmodSync(join(dir, "gh"), 0o755);

const output = execFileSync(process.execPath, [SCRIPT, "--repo", "o/r", "--weeks", "1"], {
encoding: "utf8",
env: { ...process.env, PATH: `${dir}:${process.env.PATH}` },
});

expect(section(output, "## Handoffs this week")).toEqual([
"- #7 blocked on: maintainer 7",
"- #8 blocked on: maintainer 8",
]);
expect(section(output, "## Open PRs waiting on hardware")).toEqual(["- #30 waits"]);
});
});
Loading