Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
db21cbb
feat(maintainer): export PR lifetime traces
cv Aug 29, 2026
e165123
fix(maintainer): address lifetime trace review
cv Aug 29, 2026
80eb9fa
fix(maintainer): harden lifetime trace publication
cv Aug 29, 2026
b2c409e
fix(maintainer): close lifetime publication races
cv Aug 29, 2026
d38ce9c
fix(maintainer): validate head under publication lock
cv Aug 29, 2026
2bb77c2
fix(maintainer): preserve complete lifetime publication
cv Aug 29, 2026
c5e5fc5
fix(maintainer): recover interrupted trace publication
cv Aug 29, 2026
07f8c49
fix(maintainer): fence displaced trace publishers
cv Aug 29, 2026
41a9c43
fix(maintainer): reclaim only stopped trace owners
cv Aug 29, 2026
5eeacf6
fix(maintainer): identify stale trace lock owners
cv Aug 29, 2026
5f48056
fix(maintainer): complete retained workflow attempts
cv Aug 29, 2026
b84fbcd
fix(maintainer): recover portable trace locks
cv Aug 29, 2026
9caaaa9
fix(maintainer): bind trace lock cancellation cleanup
cv Aug 29, 2026
62ca520
fix(maintainer): track trace lock creation
cv Aug 29, 2026
cd70802
fix(maintainer): remove only owned trace locks
cv Aug 29, 2026
61427ac
fix(maintainer): initialize trace locks atomically
cv Aug 29, 2026
7a42c14
fix(maintainer): guide trace backup recovery
cv Aug 29, 2026
383a5e2
refactor(maintainer): narrow trace history reads
cv Aug 29, 2026
af9a07d
fix(maintainer): fence trace lock handoff
cv Aug 29, 2026
5d25c4b
fix(maintainer): fence trace lock heartbeat
cv Aug 29, 2026
57bcfe4
test(maintainer): prove trace lock heartbeat
cv Aug 29, 2026
e53b069
fix(maintainer): share trace pull snapshot
cv Aug 29, 2026
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
44 changes: 24 additions & 20 deletions .agents/skills/nemoclaw-maintainer-analyze-pr-value-stream/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: nemoclaw-maintainer-analyze-pr-value-stream
description: Analyze one NemoClaw pull request from its earliest observable branch push through merge. Separates approval delay from automation time and compares the latest revision with a target. Use for PR latency, value-stream, bottleneck, or ten-minute-target analysis.
description: Analyze one NemoClaw pull request across its complete observable lifetime. Produces a bounded Perfetto trace and summary, separates contributor, review, and automation time, and compares the latest revision with a target. Use for PR latency, value-stream, bottleneck, timeline, or ten-minute-target analysis.
user_invocable: true
---

Expand All @@ -9,39 +9,40 @@ user_invocable: true

# Analyze a Pull Request Value Stream

Run the deterministic read-only analyzer for one pull request. The analyzer uses authenticated GitHub reads and emits bounded JSON.
Run the deterministic read-only analyzer once for one pull request. Every invocation collects the complete observable retained lifetime. It writes a Perfetto-compatible trace, summary, and manifest under `.nemoclaw-maintainer/pr-value-stream/pr-<number>/` and emits the summary as bounded JSON on stdout.

Do not run a reduced or latest-revision-only analysis. The latest-revision waterfall remains one derived part of the complete lifetime result.

## Prerequisites

- Run from a NemoClaw checkout with authenticated `gh` access.
- Use Node.js 22.19 or later with type stripping enabled.
- Retained Vitest artifact timing is conditional: install this checkout’s dependencies so `node_modules/vitest/vitest.mjs` is available, and install `zipinfo` and `unzip`. The analyzer still returns the bounded report when these optional tools or an artifact are unavailable, with the failure recorded in `caveats`.
- Retained Vitest artifact timing is conditional: install this checkout's dependencies so `node_modules/vitest/vitest.mjs` is available, and install `zipinfo` and `unzip`. Optional artifact failures appear in `caveats` and do not become test-timing evidence.

## Run the analysis

Use the default ten-minute target:

```bash
node --experimental-strip-types --no-warnings \
.agents/skills/nemoclaw-maintainer-analyze-pr-value-stream/scripts/analyze-pr-value-stream.mts \
--workdir "$PWD" \
--number <pull-request-number>
```

The default repository is `NVIDIA/NemoClaw`. Use `--repository OWNER/REPO` only when the user requests another repository.
The default repository is `NVIDIA/NemoClaw`. Use `--repository OWNER/REPO` only when the user requests another repository. The ten-minute target defaults to 10; use `--target-minutes` only when the user requests another target.

The analyzer owns completeness and safety bounds. Do not use legacy pagination or truncation options to reduce the standard analysis. If required retained history exceeds a bound, the command fails rather than calling a partial trace complete.

Use these comparison-friendly options. Keep every option equal when comparing pull requests:
## Outputs

| Option | Default | Accepted value |
|---|---:|---:|
| `--target-minutes` | `10` | Greater than 0, at most 1440 |
| `--max-run-pages` | `3` | Integer from 1 through 10 |
| `--max-check-pages` | `3` | Integer from 1 through 10 |
| `--max-automation-runs` | `50` | Integer from 1 through 100 |
| `--max-test-artifacts` | `12` | Integer from 0 through 24 |
| `--top-tests-per-shard` | `10` | Integer from 1 through 25 |
A successful invocation writes:

Use `--max-test-artifacts 0` to skip artifact downloads.
- `summary.json`: the complete bounded value-stream report printed on stdout.
- `trace.json`: Chrome Trace Event JSON for Perfetto or `chrome://tracing`.
- `manifest.json`: exact pull request identity, head commit, output sizes, and completeness declarations. This file is written last.

The trace contains lifecycle events, all retained PR revisions, workflows, job queues, job executions, steps, external checks, reviews, comments, inline feedback, commit publication spans, and temporal feedback-to-next-change spans.

Open `trace.json` in Perfetto to zoom, filter categories, inspect event arguments, and measure arbitrary intervals.

## Interpret the result

Expand All @@ -50,12 +51,15 @@ Report these fields first:
1. `target.status` and `target.theoreticalFastestSeconds`.
2. The largest entries in `bottlenecks`.
3. `elapsed.approvalDelaySeconds` and `elapsed.mergeLagAfterReadySeconds`.
4. `waterfall.runsTruncated` and all applicable `caveats`.
4. The `lifetime` artifact paths and counts.
5. All applicable `caveats`.

Do not describe a fallback branch timestamp as exact. Do not claim causal attribution from the counterfactual approval calculation. A truncated run set is incomplete evidence. Treat null timing fields as queued or otherwise not yet observed. Treat artifact failure caveats as status evidence, not test timing evidence.
Do not describe a fallback branch timestamp as exact. Do not claim causal attribution from temporal feedback-to-change spans or counterfactual approval calculations. Treat null timing fields as queued or otherwise unobserved. Treat artifact failure caveats as status evidence, not test timing evidence.

## Trust boundaries

The script performs no GitHub writes. It invokes executables with argument arrays and rejects unknown or duplicate options. It bounds GitHub output, pagination, job counts, artifact sizes, extracted data, and final JSON.
The script performs no GitHub writes. It invokes executables with argument arrays, bounds GitHub output, pagination, revisions, workflow runs, jobs, trace events, artifact sizes, and file sizes, and rejects malformed or incomplete required history. Lifetime artifact publication uses a per-PR lock. An active publication waits for up to 30 seconds; a lock left untouched for more than five minutes is treated as orphaned and reclaimed automatically. A timeout reports the exact active lock path for diagnosis.

GitHub does not expose canonical branch-creation timestamps or pull request description edit history. The trace uses the first retained exact-commit workflow as an observable push signal and records that limitation. Draft transitions appear only when GitHub's timeline returns them.

When retained CLI shard artifacts are enabled, the script accepts only an exact run and commit match, one regular `blob-*.json` ZIP entry, and bounded compressed and expanded sizes. It uses a private temporary directory and removes that directory after the attempt.
When retained CLI shard artifacts are available, the script accepts only an exact run and commit match, one regular `blob-*.json` ZIP entry, and bounded compressed and expanded sizes. It uses a private temporary directory and removes it after the attempt.
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,27 @@ import path from "node:path";
import { promisify } from "node:util";
import { fileURLToPath, pathToFileURL } from "node:url";

import { exportLifetimeTrace, type LifetimeArtifacts } from "./export-pr-lifetime-trace.mts";

const execFileAsync = promisify(execFile);
const MAX_GH_OUTPUT = 10_000_000;
const MAX_JSON_OUTPUT = 4_000_000;
const MAX_RUN_PAGES = 3;
const MAX_CHECK_PAGES = 3;
const MAX_AUTOMATION_RUNS = 50;
const MAX_TEST_ARTIFACTS = 12;
const TOP_TESTS_PER_SHARD = 10;

type Input = {
workdir: string;
number: number;
repository?: string;
targetMinutes?: number;
maxRunPages?: number;
maxCheckPages?: number;
maxAutomationRuns?: number;
maxTestArtifacts?: number;
topTestsPerShard?: number;
};

export type ValueStreamReport = {
measuredAt: string;
lifetime?: LifetimeArtifacts;
repository: string;
number: number;
url: string;
Expand Down Expand Up @@ -283,11 +286,11 @@ function normalizeAnalysisInput(input: Input): AnalysisOptions {
number: input.number,
repository,
targetMinutes,
maxRunPages: boundedInteger(input.maxRunPages ?? 3, "maxRunPages", 1, 10),
maxCheckPages: boundedInteger(input.maxCheckPages ?? 3, "maxCheckPages", 1, 10),
maxAutomationRuns: boundedInteger(input.maxAutomationRuns ?? 50, "maxAutomationRuns", 1, 100),
maxTestArtifacts: boundedInteger(input.maxTestArtifacts ?? 12, "maxTestArtifacts", 0, 24),
topTestsPerShard: boundedInteger(input.topTestsPerShard ?? 10, "topTestsPerShard", 1, 25),
maxRunPages: MAX_RUN_PAGES,
maxCheckPages: MAX_CHECK_PAGES,
maxAutomationRuns: MAX_AUTOMATION_RUNS,
maxTestArtifacts: MAX_TEST_ARTIFACTS,
topTestsPerShard: TOP_TESTS_PER_SHARD,
};
}

Expand Down Expand Up @@ -1459,17 +1462,7 @@ export async function analyzePrValueStream(input: Input): Promise<ValueStreamRep
}

function parseArguments(argv: string[]): Input {
const allowed = new Set([
"workdir",
"number",
"repository",
"target-minutes",
"max-run-pages",
"max-check-pages",
"max-automation-runs",
"max-test-artifacts",
"top-tests-per-shard",
]);
const allowed = new Set(["workdir", "number", "repository", "target-minutes"]);
const values = new Map<string, string>();
for (let index = 0; index < argv.length; index += 2) {
const key = argv[index];
Expand All @@ -1489,16 +1482,20 @@ function parseArguments(argv: string[]): Input {
number,
repository: values.get("repository"),
targetMinutes: numeric("target-minutes"),
maxRunPages: numeric("max-run-pages"),
maxCheckPages: numeric("max-check-pages"),
maxAutomationRuns: numeric("max-automation-runs"),
maxTestArtifacts: numeric("max-test-artifacts"),
topTestsPerShard: numeric("top-tests-per-shard"),
};
}

async function main(): Promise<void> {
const report = await analyzePrValueStream(parseArguments(process.argv.slice(2)));
const input = parseArguments(process.argv.slice(2));
const normalized = normalizeAnalysisInput(input);
const report = await collectValueStreamReport(normalized);
report.lifetime = await exportLifetimeTrace({
workdir: normalized.workdir,
repository: normalized.repository,
number: normalized.number,
report,
githubRead: async (args) => runGithubCli({ workdir: normalized.workdir, args }),
});
const output = `${JSON.stringify(report, null, 2)}\n`;
if (Buffer.byteLength(output) > MAX_JSON_OUTPUT)
throw new Error("value-stream JSON exceeded the 4 MB output bound");
Expand Down
Loading
Loading