Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

fix(exchange): accept exact fresh grant marker [A2,A7,E21]

Corey Olsone0ab953f1208
diff --git a/src/exchange.js b/src/exchange.js
index 99742957..d47b906f 100644
--- a/src/exchange.js
+++ b/src/exchange.js
@@ -1,3 +1,4 @@
+import { AGENT_GRANT_ENGINE } from './agent-grant-engine.js';
import { LANDING_LOCAL_PREFIX } from './landing-local-lease.js';
import { PROOF_COUNTER_PREFIX } from './proof-counters.js';
import { rebuildProofCounters } from './proof-counters.js';
@@ -173,6 +174,8 @@ function hasOnlyInitCoordinator(db, names) {
const detail = JSON.parse(event.event_detail);
if (detail.model !== undefined && detail.model !== 'unknown') return false;
delete detail.model;
+ if (detail.grantEngine !== undefined && detail.grantEngine !== AGENT_GRANT_ENGINE) return false;
+ delete detail.grantEngine;
if (JSON.stringify(detail) !== JSON.stringify({ lane: 'coordinator' })) return false;
} catch {
return false;
diff --git a/test/exchange.test.js b/test/exchange.test.js
index 4f102365..896487d1 100644
--- a/test/exchange.test.js
+++ b/test/exchange.test.js
@@ -1,3 +1,4 @@
+import { AGENT_GRANT_ENGINE } from '../src/agent-grant-engine.js';
/**
* The v1 board exchange keeps each SQLite row, including lifecycle history and sequence counters.
*/
@@ -334,3 +335,41 @@ test('fresh-init approval baselines are disposable only with exact setup history
rmSync(directory, { recursive: true, force: true });
}
});
+
+
+test('fresh-init grant markers permit pairing without admitting other history [A2,A7,E21]', () => {
+ const directory = tempDirectory();
+ const source = populatedBoard(join(directory, 'source.sqlite'));
+ const setup = store.openBoard(join(directory, 'setup.sqlite'));
+ try {
+ store.register(setup, { lane: 'coordinator', path: '/fresh' });
+ const incoming = exportBoard(source);
+ const cases = [
+ { detail: { lane: 'coordinator' }, allowed: true },
+ { detail: { lane: 'coordinator', grantEngine: AGENT_GRANT_ENGINE }, allowed: true },
+ { detail: { lane: 'coordinator', grantEngine: String(AGENT_GRANT_ENGINE) }, allowed: false },
+ { detail: { lane: 'coordinator', grantEngine: AGENT_GRANT_ENGINE + 1 }, allowed: false },
+ { detail: { lane: 'coordinator', grantEngine: AGENT_GRANT_ENGINE, grant: 'stored authority' }, allowed: false },
+ ];
+ for (const [index, entry] of cases.entries()) {
+ const target = store.openBoard(join(directory, `marker-${index}.sqlite`));
+ try {
+ const initial = exportBoard(setup);
+ initial.tables.event[0].event_detail = JSON.stringify(entry.detail);
+ importBoard(target, initial);
+ const before = exportBoard(target);
+ if (entry.allowed) {
+ importBoard(target, incoming);
+ assert.deepEqual(exportBoard(target), incoming);
+ } else {
+ assert.throws(() => importBoard(target, incoming), /IMPORT_NOT_EMPTY/u);
+ assert.deepEqual(exportBoard(target), before, 'invalid setup remains untouched');
+ }
+ } finally { store.closeBoard(target); }
+ }
+ } finally {
+ store.closeBoard(setup);
+ store.closeBoard(source);
+ rmSync(directory, { recursive: true, force: true });
+ }
+});