Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(scripts): flag a chain allow-list entry whose gate no longer exists

obchaine76e6d6c9a1e
diff --git a/scripts/__tests__/feature-forwarding.test.mjs b/scripts/__tests__/feature-forwarding.test.mjs
index e6726264ca..43eff9cc3e 100644
--- a/scripts/__tests__/feature-forwarding.test.mjs
+++ b/scripts/__tests__/feature-forwarding.test.mjs
@@ -612,6 +612,43 @@ e2e-test-support = ["openhuman-core/e2e-test-support"]
assert.deepEqual(result.staleExclusion, ['e2e-test-support']);
});
+test('an exclusion for a gate no crate below declares any more is flagged as stale', () => {
+ // The other half of the stale check: once the core drops the gate, nothing
+ // declares it, so it stops appearing in the `allowed:` report too — and the
+ // entry would silently exclude a gate by that name if one ever came back.
+ const result = chainLink(
+ `
+[features]
+default = ["openhuman-core/default"]
+media = ["openhuman-core/media"]
+voice = ["openhuman-core/voice"]
+e2e-test-support = ["openhuman-core/e2e-test-support"]
+`,
+ [coreSource()],
+ { notForwarded: { 'peripheral-rpi': 'a gate the core deleted' } }
+ );
+ assert.equal(result.ok, false);
+ assert.deepEqual(result.staleExclusion, ['peripheral-rpi']);
+ assert.match(formatChainReport(result), /no crate below declares it any more/);
+});
+
+test('a crate-local entry for a gate this crate no longer declares is flagged as stale', () => {
+ const result = chainLink(
+ `
+[features]
+default = ["openhuman-core/default"]
+media = ["openhuman-core/media"]
+voice = ["openhuman-core/voice"]
+e2e-test-support = ["openhuman-core/e2e-test-support"]
+`,
+ [coreSource()],
+ { localGates: { jev: 'This crate owns the gate.' } }
+ );
+ assert.equal(result.ok, false);
+ assert.deepEqual(result.staleLocal, ['jev']);
+ assert.match(formatChainReport(result), /no longer does/);
+});
+
test('a documented crate-local gate passes', () => {
const result = chainLink(
`
diff --git a/scripts/lib/feature-forwarding.mjs b/scripts/lib/feature-forwarding.mjs
index ac417bfeb4..cb50eb0935 100644
--- a/scripts/lib/feature-forwarding.mjs
+++ b/scripts/lib/feature-forwarding.mjs
@@ -541,11 +541,23 @@ export function diffChainForwarding({
!upstream.has(gate) && !Object.prototype.hasOwnProperty.call(localGates, gate)
);
// A "local" gate an upstream crate now declares is no longer local, and the
- // entry would hide a genuinely missing forward for it.
- const staleLocal = Object.keys(localGates).filter(gate => upstream.has(gate));
- // Mirrors `diffForwarding`'s stale check: an exclusion for a gate that IS
- // carried here is wrong, and would mask the day it gets dropped.
- const staleExclusion = Object.keys(notForwarded).filter(gate => declared.has(gate));
+ // entry would hide a genuinely missing forward for it. One this crate has
+ // since dropped is stale for the opposite reason: it describes nothing, and
+ // would silently excuse a gate by that name the day one reappears.
+ const staleLocal = Object.keys(localGates).filter(
+ gate => upstream.has(gate) || !declared.has(gate)
+ );
+ // Mirrors `diffForwarding`'s stale check, in both directions: an exclusion
+ // for a gate that IS carried here is wrong and would mask the day it gets
+ // dropped, and an exclusion for a gate no source declares any more excuses a
+ // name that no longer exists — it also stops appearing in the `allowed:`
+ // report, so nothing draws attention to it.
+ const requiredUpstream = new Set(
+ sources.filter(source => source.required).flatMap(source => source.gates)
+ );
+ const staleExclusion = Object.keys(notForwarded).filter(
+ gate => declared.has(gate) || !requiredUpstream.has(gate)
+ );
return {
ok:
missing.length === 0 &&
@@ -606,11 +618,17 @@ export function formatChainReport(result, { notForwarded = {} } = {}) {
);
}
if (result.staleLocal.length > 0) {
- lines.push('', 'Stale CHAIN_LOCAL_GATES entries (a crate below now declares the gate):');
+ lines.push(
+ '',
+ `Stale CHAIN_LOCAL_GATES entries (a crate below now declares the gate, or ${result.crate} no longer does):`
+ );
for (const gate of result.staleLocal) lines.push(` - ${gate}`);
}
if (result.staleExclusion.length > 0) {
- lines.push('', 'Stale CHAIN_GATES_NOT_FORWARDED entries (the gate IS forwarded):');
+ lines.push(
+ '',
+ 'Stale CHAIN_GATES_NOT_FORWARDED entries (the gate IS forwarded, or no crate below declares it any more):'
+ );
for (const gate of result.staleExclusion) lines.push(` - ${gate}`);
}
if (result.ok) lines.push(` OK: forwards every gate of the crates below it.`);