From 7e610c91c86e13f83776db8dab477baec7a8f389 Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Sun, 1 Nov 2026 05:34:52 -0500 Subject: [PATCH 1/2] fix(ci): name the TRUSTED_SCRIPTS_TREE pin and the re-pin remedy in the governance assertion Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- .github/scripts/integration-governance.cjs | 7 +++++-- .github/scripts/integration-governance.test.cjs | 7 +++++++ AGENTS.md | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/scripts/integration-governance.cjs b/.github/scripts/integration-governance.cjs index fcc9b4c0e4..dd5a3f1647 100644 --- a/.github/scripts/integration-governance.cjs +++ b/.github/scripts/integration-governance.cjs @@ -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; diff --git a/.github/scripts/integration-governance.test.cjs b/.github/scripts/integration-governance.test.cjs index cff97879e8..6c3d44d6b1 100644 --- a/.github/scripts/integration-governance.test.cjs +++ b/.github/scripts/integration-governance.test.cjs @@ -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'); diff --git a/AGENTS.md b/AGENTS.md index 362230c572..04b51dc66b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -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/-.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. From 6379d24fa0e8a35264829e2effbf52e4c861bbc7 Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Sun, 1 Nov 2026 05:37:40 -0500 Subject: [PATCH 2/2] test(ci): assert the drifted src/scripts tree refusal names the pin and the re-pin remedy Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- .github/scripts/integration-governance.test.cjs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/scripts/integration-governance.test.cjs b/.github/scripts/integration-governance.test.cjs index 6c3d44d6b1..1ff95c6708 100644 --- a/.github/scripts/integration-governance.test.cjs +++ b/.github/scripts/integration-governance.test.cjs @@ -136,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}); } });