Skip to content

Commit f2864b8

Browse files
committed
Merge remote-tracking branch 'origin/main' into HEAD
2 parents c9946e8 + 86707db commit f2864b8

79 files changed

Lines changed: 5030 additions & 1844 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.agents/skills/create-pr/SKILL.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ A PR is one reviewable responsibility and may hold several atomic commits. A bra
1515
2. Push and open the PR — `references/open-pr.md`. A squash merge writes the PR title as the commit subject on `main`, so CI holds the title to the same Conventional Commit scope rules the `commit` skill describes.
1616
3. Request and handle AI review — `references/ai-review.md`, with the `gh` reply and thread-state calls in `references/gh-review.md`.
1717
4. Watch CI after opening and after every push with `gh pr checks`. Read the failing step logs and annotations rather than the summary, then use the `fix-ci` skill for the fix, and ask the bots for another pass if they do not rerun on their own.
18-
5. Merge only when the user explicitly asks and the conditions below hold: `gh pr merge <pr> --squash --delete-branch`. Squash is the repository's normal flow.
18+
5. Merge only when the user explicitly asks and the conditions below hold: `gh pr merge <pr> --squash`, without `--delete-branch` or `--body-file`. On a base branch with a merge queue this adds the PR to the queue instead. When the PR fixes an issue someone else reported, credit that reporter with a `Co-authored-by` trailer on one of the PR's commits before merging, using their noreply address `<id>+<login>@users.noreply.github.com` (`gh api users/<login> --jq .id`): the squash body is built from the commit messages.
19+
6. After merging, reply on each linked issue and on any original contributor PR it superseded. For a branch offered without a PR, reply where it was offered. Say what landed and in which PR, and, when it changes the published package, the release that shipped it or that it ships with the next one. Do this in particular when someone pinged or offered a branch and got no answer.
1920

2021
## Ready means
2122

‎.agents/skills/profile/references/rust.md‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,14 @@ affect rendering — before believing a speedup.
4545
- Parallelism only when it improves end-to-end time on real fixture shapes.
4646
- Binary size when adding a dependency or feature (`rust-binary-size` skill).
4747

48-
## Reproducing The CI Performance Comment
48+
## Comparing Refs And Reproducing The CI Comment
4949

50-
`apps/ccusage/scripts/compare-pr-performance.bb --help` lists the options; the
51-
`compare-pr-performance.bb` step in `.github/workflows/ci.yaml` is the reference
52-
for a realistic argument set. Locally, point `--base-dir` at the main worktree
53-
and `--head-dir` at `$PWD`, and cut `--runs`/`--warmup` down to keep iteration
54-
fast.
50+
`just bench-history <ref|binary>...` builds each ref in release mode, runs every
51+
report command over the generated realistic fixture in interleaved rounds, and
52+
judges each ref against the previous one the same way the CI comment judges a
53+
PR against its merge base. Add `--real` to also measure the logs this
54+
environment points at. Judge by the CPU-time and peak-RSS ratios, not wall time.
55+
56+
When a regression slips past the comparison, fix the fixture generator
57+
(`apps/ccusage/scripts/generate-large-fixture.ts`) so its lines carry the shape
58+
that triggered it; do not add a special-case benchmark.

‎.github/actions/detect-code-changes/action.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ runs:
1010
- id: detect
1111
shell: bash
1212
env:
13-
BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before }}
13+
BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha || github.event.before }}
1414
HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
1515
run: |
1616
set -euo pipefail

‎.github/scripts/contribution-gate.test.nu‎

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,11 @@ def test-existing-implementation-pull-request []: nothing -> nothing {
230230
'pullfrog/issue-42-run-999'
231231
) null
232232

233-
let closing_pull_request = {number: 1209, state: OPEN, url: 'https://github.com/ccusage/ccusage/pull/1209'}
233+
let closing_pull_request = {
234+
number: 1209
235+
state: OPEN
236+
url: 'https://github.com/ccusage/ccusage/pull/1209'
237+
}
234238
expect 'finds an open pull request that GitHub recognizes as closing the issue' (
235239
open-closing-pull-request [$closing_pull_request]
236240
) {number: 1209, html_url: 'https://github.com/ccusage/ccusage/pull/1209'}
@@ -287,7 +291,11 @@ def test-existing-implementation-pull-request []: nothing -> nothing {
287291
def test-implementation-result []: nothing -> nothing {
288292
expect 'accepts prepared PR metadata' (
289293
implementation-result '{"implementation":"prepared","title":"fix: count cache writes","body":"Fixes the missing cost.\n\nTests: focused adapter test."}'
290-
) {implementation: prepared, title: 'fix: count cache writes', body: "Fixes the missing cost.\n\nTests: focused adapter test."}
294+
) {
295+
implementation: prepared
296+
title: 'fix: count cache writes'
297+
body: "Fixes the missing cost.\n\nTests: focused adapter test."
298+
}
291299
expect 'accepts a declined implementation' (
292300
implementation-result '{"implementation":"none","title":"","body":""}'
293301
) {implementation: none, title: '', body: ''}
@@ -541,7 +549,11 @@ def test-issue-context []: nothing -> nothing {
541549
}
542550

543551
def test-issue-number []: nothing -> nothing {
544-
expect 'parses a positive integer issue number' (parse-issue-number '42') 42
552+
(expect
553+
'parses a positive integer issue number'
554+
(parse-issue-number '42')
555+
42
556+
)
545557

546558
[
547559
'1.5'
@@ -616,7 +628,11 @@ def test-issue-triage-policy []: nothing -> nothing {
616628
)
617629

618630
let core_bug = issue-verdict-record '{"kind":"bug","maintenance_fit":"maintainable","confidence":"high","decision":"keep_open","priority":"priority:high","implementation":"create_pr","reason":"Confirmed cost calculation regression with a focused fix."}' true
619-
expect 'keeps a high-confidence core bug open' $core_bug.decision keep_open
631+
(expect
632+
'keeps a high-confidence core bug open'
633+
$core_bug.decision
634+
keep_open
635+
)
620636
(expect
621637
'allows an important maintainable bug implementation'
622638
$core_bug.implementation
@@ -653,7 +669,11 @@ def test-issue-triage-policy []: nothing -> nothing {
653669
)
654670

655671
let security = issue-verdict-record '{"kind":"security","maintenance_fit":"excluded","confidence":"high","decision":"close","priority":"priority:low","implementation":"none","reason":"The report may affect credential handling."}' true
656-
expect 'never auto-closes a security report' $security.decision needs_human
672+
(expect
673+
'never auto-closes a security report'
674+
$security.decision
675+
needs_human
676+
)
657677
(expect
658678
'marks a security report for review'
659679
$security.maintenance_fit

‎.github/scripts/contribution-gate/coauthor.nu‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ def find-implementation-pull-request [repo: string, branch: string, marker: stri
3333
for attempt in 0..($max_attempts - 1) {
3434
let pull_requests = implementation-pull-requests $repo $branch $marker
3535
if ($pull_requests | length) > 1 {
36-
error make {msg: 'Found multiple implementation pull requests for this issue-gate run'}
36+
error make {
37+
msg: 'Found multiple implementation pull requests for this issue-gate run'
38+
}
3739
}
3840
if ($pull_requests | length) == 1 {
3941
return ($pull_requests | get 0)
@@ -42,7 +44,9 @@ def find-implementation-pull-request [repo: string, branch: string, marker: stri
4244
sleep 5sec
4345
}
4446
}
45-
error make {msg: 'Could not find the implementation pull request for this issue-gate run after retrying the GitHub API'}
47+
error make {
48+
msg: 'Could not find the implementation pull request for this issue-gate run after retrying the GitHub API'
49+
}
4650
}
4751

4852
def commit-attributions [repo: string, sha: string]: nothing -> list<record> {
@@ -116,7 +120,11 @@ def validate-commit [
116120
$expected_email
117121
$issue_author_id
118122
)
119-
{sha: $commit.sha, trailer_ok: $validation.trailer_ok, author_ok: $validation.author_ok}
123+
{
124+
sha: $commit.sha
125+
trailer_ok: $validation.trailer_ok
126+
author_ok: $validation.author_ok
127+
}
120128
}
121129

122130
export def verify-coauthor []: nothing -> nothing {
@@ -129,7 +137,9 @@ export def verify-coauthor []: nothing -> nothing {
129137
let pull_request = find-implementation-pull-request $repo $branch $marker
130138
let commits = pull-request-commits $repo $pull_request.number
131139
if ($commits | is-empty) {
132-
error make {msg: $"Implementation PR #($pull_request.number) has no commits to verify"}
140+
error make {
141+
msg: $"Implementation PR #($pull_request.number) has no commits to verify"
142+
}
133143
}
134144
let validation = $commits | each {|commit|
135145
validate-commit $repo $commit $expected_trailer $expected_email $issue_author_id
@@ -139,7 +149,9 @@ export def verify-coauthor []: nothing -> nothing {
139149
let summary = $invalid
140150
| each {|result| $"($result.sha): trailer_ok=($result.trailer_ok), author_ok=($result.author_ok)"}
141151
| str join "\n"
142-
error make {msg: $"Issue-author co-author verification failed for PR #($pull_request.number):\n($summary)"}
152+
error make {
153+
msg: $"Issue-author co-author verification failed for PR #($pull_request.number):\n($summary)"
154+
}
143155
}
144156
print $"Verified issue-author attribution on PR #($pull_request.number) across ($commits | length) commits."
145157
}

‎.github/scripts/contribution-gate/context.nu‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ export def issue-context-record [requested_number: int, issue: record]: nothing
1010

1111
let actual_number = $issue | get --optional number
1212
if ($actual_number | describe) != 'int' or $actual_number != $requested_number {
13-
error make {msg: $"GitHub returned an unexpected issue number for #($requested_number)"}
13+
error make {
14+
msg: $"GitHub returned an unexpected issue number for #($requested_number)"
15+
}
1416
}
1517
if ($issue | get --optional state) != 'open' {
1618
error make {msg: $"Issue #($requested_number) is not open"}

‎.github/scripts/contribution-gate/mutations.nu‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,13 @@ export def upsert-comment [
188188
create-comment $repo $number $body $require_open_issue
189189
}
190190
$comment_id => {
191-
patch-comment $repo $number $comment_id $body $require_open_issue
191+
(patch-comment
192+
$repo
193+
$number
194+
$comment_id
195+
$body
196+
$require_open_issue
197+
)
192198
}
193199
}
194200
}

‎.github/scripts/contribution-gate/requests.nu‎

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ export def retry-pull-request-lookup [lookup: closure, wait: closure, max_attemp
147147
return $outcome.pull_request
148148
}
149149
if $attempt == $max_attempts and $outcome.transient_error != null {
150-
error make {msg: $"Pull request lookup still failed after retrying: ($outcome.transient_error)"}
150+
error make {
151+
msg: $"Pull request lookup still failed after retrying: ($outcome.transient_error)"
152+
}
151153
}
152154
if $attempt < $max_attempts {
153155
do $wait $attempt | ignore
@@ -188,7 +190,9 @@ export def closing-pull-request-nodes [connection: record]: nothing -> list<reco
188190
error make {msg: 'GitHub returned invalid closing pull request pagination data'}
189191
}
190192
if $has_next_page {
191-
error make {msg: 'Closing pull request lookup exceeded one page; refusing incomplete duplicate detection'}
193+
error make {
194+
msg: 'Closing pull request lookup exceeded one page; refusing incomplete duplicate detection'
195+
}
192196
}
193197
let nodes = $connection | get --optional nodes
194198
if ($nodes | describe) !~ '^(list|table)' {
@@ -274,7 +278,9 @@ export def implementation-title [title: string]: nothing -> string {
274278
(($sanitized | str length) <= 240)
275279
] | all {|condition| $condition }
276280
if not $valid {
277-
error make {msg: 'The sanitized implementation title must be one non-empty line of at most 240 characters'}
281+
error make {
282+
msg: 'The sanitized implementation title must be one non-empty line of at most 240 characters'
283+
}
278284
}
279285
$sanitized
280286
}
@@ -382,14 +388,18 @@ def git-complete [args: list<string>]: nothing -> record {
382388
def git-run [args: list<string>]: nothing -> nothing {
383389
let result = git-complete $args
384390
if $result.exit_code != 0 {
385-
error make {msg: $"git ($args | str join ' ') failed with exit code ($result.exit_code): ($result.stderr | str trim)"}
391+
error make {
392+
msg: $"git ($args | str join ' ') failed with exit code ($result.exit_code): ($result.stderr | str trim)"
393+
}
386394
}
387395
}
388396

389397
def git-output [args: list<string>]: nothing -> string {
390398
let result = git-complete $args
391399
if $result.exit_code != 0 {
392-
error make {msg: $"git ($args | str join ' ') failed with exit code ($result.exit_code): ($result.stderr | str trim)"}
400+
error make {
401+
msg: $"git ($args | str join ' ') failed with exit code ($result.exit_code): ($result.stderr | str trim)"
402+
}
393403
}
394404
$result.stdout | str trim
395405
}
@@ -441,7 +451,9 @@ def discard-created-pull-request [repo: string, number: int, branch: string]: no
441451
{|| git-run [push origin --delete $branch] }
442452
)
443453
if ($errors | is-not-empty) {
444-
error make {msg: $"Could not fully discard implementation PR #($number) on branch ($branch): ($errors | str join '; ')"}
454+
error make {
455+
msg: $"Could not fully discard implementation PR #($number) on branch ($branch): ($errors | str join '; ')"
456+
}
445457
}
446458
}
447459

@@ -457,7 +469,9 @@ def discard-unvalidated-publication [repo: string, branch: string]: nothing -> n
457469
{|| git-run [push origin --delete $branch] }
458470
)
459471
if ($errors | is-not-empty) {
460-
error make {msg: $"Could not fully discard an unvalidated implementation publication on branch ($branch): ($errors | str join '; ')"}
472+
error make {
473+
msg: $"Could not fully discard an unvalidated implementation publication on branch ($branch): ($errors | str join '; ')"
474+
}
461475
}
462476
}
463477

@@ -506,7 +520,9 @@ def resolve-coauthor-attribution [username: string, user_id: int, user: record]:
506520
} else {
507521
let created_at = $user | get --optional created_at
508522
if ($created_at | describe) != 'string' {
509-
error make {msg: $"Could not determine when GitHub account ($username) was created"}
523+
error make {
524+
msg: $"Could not determine when GitHub account ($username) was created"
525+
}
510526
}
511527
let created_at = $created_at | into datetime
512528
let legacy_cutoff = '2017-07-18T00:00:00Z' | into datetime
@@ -526,7 +542,9 @@ def resolve-coauthor-attribution [username: string, user_id: int, user: record]:
526542
export def coauthor-email [username: string, user_id: int, user: record]: nothing -> string {
527543
let attribution = resolve-coauthor-attribution $username $user_id $user
528544
if ($attribution.email | is-empty) {
529-
error make {msg: $"Could not resolve a GitHub email for legacy account ($username) without a public email"}
545+
error make {
546+
msg: $"Could not resolve a GitHub email for legacy account ($username) without a public email"
547+
}
530548
}
531549
$attribution.email
532550
}
@@ -616,7 +634,9 @@ export def publish-implementation []: nothing -> nothing {
616634
error make {msg: 'The implementation patch is empty'}
617635
}
618636
if $staged.exit_code != 1 {
619-
error make {msg: $"Could not inspect the staged implementation: ($staged.stderr | str trim)"}
637+
error make {
638+
msg: $"Could not inspect the staged implementation: ($staged.stderr | str trim)"
639+
}
620640
}
621641

622642
git-run [config user.name 'github-actions[bot]']
@@ -680,7 +700,9 @@ export def publish-implementation []: nothing -> nothing {
680700
}
681701
} catch {
682702
discard-created-pull-request $repo $pull_number $branch
683-
error make {msg: 'Could not reconcile competing pull requests after publication; the workflow-created pull request was closed'}
703+
error make {
704+
msg: 'Could not reconcile competing pull requests after publication; the workflow-created pull request was closed'
705+
}
684706
}
685707
let competing = $reconciliation.competing
686708
if $competing != null {

‎.github/scripts/npm-registry-gate.nu‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ export def wait-for-npm-package-versions [
7272
| each {|package| $"($package.name)@($package.version)"}
7373
| str join ', '
7474
)
75-
error make {msg: $"npm registry did not serve exact package versions within ($effective_timeout): ($versions)"}
75+
error make {
76+
msg: $"npm registry did not serve exact package versions within ($effective_timeout): ($versions)"
77+
}
7678
}
7779

7880
print 'All native package versions are available from npm.'

‎.github/scripts/upsert-pr-comment.nu‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ def main [] {
77
let body = (open --raw (required_env COMMENT_FILE))
88
match (find_existing_comment $repository $pr_number $marker) {
99
null => (create_comment $repository $pr_number $body)
10-
$existing => (update_or_recreate_comment $repository $pr_number $existing.id $body)
10+
$existing => ((update_or_recreate_comment
11+
$repository
12+
$pr_number
13+
$existing.id
14+
$body
15+
))
1116
}
1217
}
1318
def find_existing_comment [repository: string, pr_number: string, marker: string] {

0 commit comments

Comments
 (0)