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
7 changes: 5 additions & 2 deletions .github/scripts/integration-governance.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,13 @@ async function verify(kind, subject, members, github) {
const root = process.cwd(), source = subject.preparedBy?.sourceSHA;
if (!/^[a-f0-9]{40}$/.test(source || '') ||
git(['rev-parse', `${source}:.github`]) !== subject.workflowTree ||
git(['rev-parse', `${source}:src/scripts`]) !== TRUSTED_SCRIPTS_TREE ||
git(['rev-parse', 'HEAD:src/scripts']) !== TRUSTED_SCRIPTS_TREE) {
git(['rev-parse', `${source}:src/scripts`]) !== TRUSTED_SCRIPTS_TREE) {
throw new Error('Trusted control/helper closure unavailable; no candidate script execution');
}
const scriptsTree = git(['rev-parse', 'HEAD:src/scripts']);
if (scriptsTree !== TRUSTED_SCRIPTS_TREE) {
throw new Error(`src/scripts tree ${scriptsTree} is not the pinned TRUSTED_SCRIPTS_TREE ${TRUSTED_SCRIPTS_TREE}; a PR that edits src/scripts must re-pin the literal in .github/scripts/integration-governance.cjs to git rev-parse HEAD:src/scripts`);
}
if (kind === 'contents') {
for (const pr of members) verifyContents(pr.title);
return;
Expand Down
12 changes: 10 additions & 2 deletions .github/scripts/integration-governance.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ test('unsupported or untrusted helper scope refuses instead of returning green',
await assert.rejects(policy.verify('contents', subject(), [member()]), /closure unavailable/);
});

test('src/scripts tree matches the pinned TRUSTED_SCRIPTS_TREE', () => {
const pinned = /const TRUSTED_SCRIPTS_TREE = '([a-f0-9]{40})'/.exec(
fs.readFileSync(path.join(__dirname, 'integration-governance.cjs'), 'utf8'))[1];
const actual = cp.execFileSync('git', ['rev-parse', 'HEAD:src/scripts'], {encoding: 'utf8'}).trim();
assert.equal(actual, pinned, `src/scripts tree ${actual} != pinned TRUSTED_SCRIPTS_TREE ${pinned}; re-pin the literal in .github/scripts/integration-governance.cjs to git rev-parse HEAD:src/scripts`);
});

test('real pinned helpers enforce each original member and reject missing signoff or fragment', () => {
const root = process.cwd(), workspace = path.join(root, '.integration-governance-fixture');
const helper = path.join(root, '.github/scripts/integration-governance.cjs');
Expand Down Expand Up @@ -129,9 +136,10 @@ test('real pinned helpers enforce each original member and reject missing signof
// Changing the helper closure is not permission to execute a new checker.
fs.appendFileSync(path.join(workspace, 'src/scripts/check-dco-trailers.sh'), '\n# different helper\n');
git('add', '.'); git('commit', '-s', '-m', 'Different helper closure');
assert.throws(() => check('dco', bad, [pr]));
// HEAD:src/scripts drifted from the pin: the refusal names both trees and the re-pin.
assert.throws(() => check('dco', bad, [pr]), /is not the pinned TRUSTED_SCRIPTS_TREE .*re-pin the literal/);
const forgedSource = structuredClone(bad);
forgedSource.preparedBy.sourceSHA = git('rev-parse', 'HEAD');
assert.throws(() => check('dco', forgedSource, [pr]));
assert.throws(() => check('dco', forgedSource, [pr]), /closure unavailable/);
} finally { fs.rmSync(workspace, {recursive: true, force: true}); }
});
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ These rules apply to every AI agent (hive agents, Copilot CLI, Claude Code, Code
- Every PR with a user-visible `src/` code change needs a `changelog.d/<category>-<slug>.md` fragment (`added|changed|deprecated|fixed|security`) whose body is a single `- ` bullet. Changes outside `src/` (root-level docs, `changelog.d/`, `.github/`), plus `src/docs/`, `*_test.go` files, and `src/{deploy,scripts}/test[-_]*.sh` scripts, are exempt automatically (`src/scripts/check-changelog-fragment.sh` is the source of truth for the exact set); other test-adjacent changes (e.g., `testdata/` fixtures, non-`_test.go` test helpers) and non-user-visible `src/` code changes (refactors, dependency bumps) need the `no-changelog` label instead. `changelog.d/` is at the repository root, not under `src/` β€” `src/changelog.d/` is never compiled and the guard rejects it.
- Sign commits (`git commit -s`); PR titles start with an emoji (`✨` feature, `πŸ›` fix, `πŸ“–` docs, `πŸ“` proposal, `🌱` chore, `⚠️` breaking) β€” `πŸ“` is for proposals only; a docs PR is `πŸ“– docs: …`.
- Do not hand-edit `src/docs` file:line citations (including `src/docs/api-reference.md` and `src/docs/api-reference/*.md`); when CI's citation guard reports drift, run `python3 src/scripts/check-docs-citations.py --fix` first β€” it runs `check-api-reference-citations.sh --fix` for `api-reference.md` and re-anchors other `.go` citations by their backticked Go declaration anchor. Only fall back to a manual edit for citations it still reports as `DRIFT`/`UNRESOLVED`, and run it only when CI tells you citations drifted. The required `changelog-fragment-guard` check runs it (non-fix) when a PR edits a hub or dashboard `server.go` or their `static/` pages, so the PR that causes drift goes red.
- A PR that edits anything under `src/scripts/` must re-pin `TRUSTED_SCRIPTS_TREE` in `.github/scripts/integration-governance.cjs` to `git rev-parse HEAD:src/scripts` (of the post-merge tree); otherwise `build-and-test` fails.
Loading