feat(#2096): migrate Antigravity onto EoS declarative adapter + permission-writer + MCP companion (ADR-1239)
Fold all antigravity literal branches into descriptor-driven reads: getConfigDirFromHome (→ configHome.kind 'dot-home-nested'), projectLocalHookPrefix (→ hostBehaviors.hookPathStyle 'raw'), applyAgentPathRewrites (→ noPathRewrite), getProjectInstructionFile (→ projectInstructionFile 'GEMINI.md'); removed the dead inline convertClaudeAgentToAntigravityAgent branch + dead isAntigravity destructures (antigravity is already on the descriptor-agents path). subagentToolkit flipped undocumented→full (Context7: antigravity.google/docs/cli/features); namedDispatch/nested/maxDepth/backgroundDispatch stay undocumented. Byte-identical golden parity for all 16 runtimes. UPGRADE 1 (permission-writer): permissionWriter 'antigravity' + configureAntigravityPermissions merges a scoped permissions.allow block (GSD's own tree + hooks) into Antigravity's settings.json — non-destructive, idempotent, symmetric uninstall. Added to VALID_PERMISSION_WRITERS + the FinishPermissionWriter union. UPGRADE 2 (MCP companion): configureAntigravityMcpConfig writes mcp_config.json registering the gsd-core companion MCP server (Gemini-successor mcpServers schema, best-effort — raw schema unpublished). Both writers dispatch from finishInstall. settings.json is golden-excluded (HOOK_CONFIG_FILES); mcp_config.json (portable, no absolute paths) is golden-tracked → only antigravity.json changes. Tests: declarative-reference-antigravity extended (source-grep guard across 4 modules, fail-closed for the 4 undocumented sub-axes, validator acceptance) + antigravity-upgrades (permission-writer + mcp_config live-install, idempotency, user-preservation). Matrix + ADR-1016 + capability-manifest + CONTEXT.md + connect-gsd-mcp-server docs updated; changeset (Changed). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
283
tests/antigravity-upgrades.test.cjs
Normal file
283
tests/antigravity-upgrades.test.cjs
Normal file
@@ -0,0 +1,283 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* antigravity capability UPGRADES — ADR-1239 Phase B / #2096 (EoS/antigravity).
|
||||
*
|
||||
* Drives the user-reachable surface (spawned `bin/install.js` via
|
||||
* `runMinimalInstall`) plus targeted unit coverage to prove the two real
|
||||
* upgrades Antigravity contributes as part of the imperative-adapter
|
||||
* migration:
|
||||
*
|
||||
* UPGRADE 1 — permission-writer: `configureAntigravityPermissions` writes
|
||||
* Antigravity's native `{"permissions":{"allow":[...]}}` schema
|
||||
* (antigravity.google/docs/cli/permissions) into the SAME settings.json
|
||||
* GSD's own hook registration writes, non-destructively appending GSD's own
|
||||
* read_file/command allow rules while preserving any existing user
|
||||
* permissions (allow/deny/ask). Uninstall removes only the GSD-owned rules.
|
||||
*
|
||||
* UPGRADE 2 — MCP companion config: `configureAntigravityMcpConfig` writes
|
||||
* a standalone `mcp_config.json` (antigravity.google/docs/cli/gcli-migration)
|
||||
* registering the `gsd` MCP server (`bin/gsd-mcp-server.js`, the SAME
|
||||
* companion OpenCode/Kilo document/wire), non-destructively preserving any
|
||||
* other user-configured `mcpServers` entries. Uninstall removes only the
|
||||
* `gsd` entry.
|
||||
*
|
||||
* Both writers are NOT GSD_TEST_MODE-gated (mirrors Kilo's dispatch, not
|
||||
* OpenCode's) — runMinimalInstall strips GSD_TEST_MODE from the spawned
|
||||
* installer's env, so both fire during a "minimal" install too.
|
||||
*/
|
||||
|
||||
const { test } = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const { spawnSync } = require('node:child_process');
|
||||
|
||||
const { runMinimalInstall, installerEnv, INSTALL_SCRIPT } = require('./helpers/install-shared.cjs');
|
||||
const { cleanup } = require('./helpers.cjs');
|
||||
const {
|
||||
toTildePosixPath,
|
||||
buildAntigravityAllowRules,
|
||||
configureAntigravityPermissions,
|
||||
configureAntigravityMcpConfig,
|
||||
} = require('../bin/install.js');
|
||||
const { PROTOCOL_VERSION } = require('../gsd-core/bin/lib/mcp-server.cjs');
|
||||
const { PACKAGE_NAME } = require('../gsd-core/bin/lib/package-identity.cjs');
|
||||
|
||||
const MCP_SERVER_BIN = path.join(__dirname, '..', 'bin', 'gsd-mcp-server.js');
|
||||
|
||||
const ANTIGRAVITY_CAP = JSON.parse(
|
||||
fs.readFileSync(path.join(__dirname, '..', 'capabilities', 'antigravity', 'capability.json'), 'utf8'),
|
||||
);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Descriptor boundary — permissionWriter wiring
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
test('capabilities/antigravity/capability.json declares runtime.permissionWriter: "antigravity"', () => {
|
||||
assert.equal(ANTIGRAVITY_CAP.runtime.permissionWriter, 'antigravity');
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// UPGRADE 1: permission-writer unit coverage (toTildePosixPath / rule builder)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
test('toTildePosixPath collapses a homedir-rooted path to "~/..." form', () => {
|
||||
const home = require('node:os').homedir();
|
||||
assert.equal(toTildePosixPath(path.join(home, '.gemini', 'antigravity')), '~/.gemini/antigravity');
|
||||
});
|
||||
|
||||
test('toTildePosixPath leaves a non-homedir path as an absolute posix path', () => {
|
||||
assert.equal(toTildePosixPath('/var/tmp/some-config-dir'), '/var/tmp/some-config-dir');
|
||||
});
|
||||
|
||||
test('buildAntigravityAllowRules emits the 4 documented "action(target)" rule strings', () => {
|
||||
const rules = buildAntigravityAllowRules('/tmp/ag-config');
|
||||
assert.deepEqual(rules, [
|
||||
'read_file(/tmp/ag-config/gsd-core/*)',
|
||||
'read_file(/tmp/ag-config/agents/gsd-*)',
|
||||
'read_file(/tmp/ag-config/skills/gsd-*)',
|
||||
'command(node /tmp/ag-config/hooks/*)',
|
||||
]);
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// UPGRADE 1: live install — settings.json permissions.allow (both scopes)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
for (const scope of ['global', 'local']) {
|
||||
test(`antigravity --${scope}: settings.json permissions.allow contains GSD's rules (UPGRADE 1)`, (t) => {
|
||||
const { configDir, root } = runMinimalInstall({ runtime: 'antigravity', scope });
|
||||
t.after(() => cleanup(root));
|
||||
|
||||
const settingsPath = path.join(configDir, 'settings.json');
|
||||
assert.ok(fs.existsSync(settingsPath), `${settingsPath} must exist`);
|
||||
|
||||
const settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
|
||||
assert.ok(settings.permissions && Array.isArray(settings.permissions.allow), 'permissions.allow must be an array');
|
||||
|
||||
// Asserting on the exact rule strings here would require reproducing
|
||||
// toTildePosixPath's os.homedir()-relative substitution from OUTSIDE the
|
||||
// spawned installer subprocess: runMinimalInstall overrides that
|
||||
// subprocess's HOME to `root`, so for --global (configDir === root ===
|
||||
// that subprocess's HOME) every rule collapses to the bare `~/...` form,
|
||||
// while THIS test process's own (unrelated, real) os.homedir() would
|
||||
// reconstruct full absolute paths instead — a guaranteed mismatch that
|
||||
// has nothing to do with correctness. Assert on the documented rule
|
||||
// SHAPE (action + path suffix) instead, which holds regardless of
|
||||
// whether the prefix collapsed to `~` or stayed a full absolute path.
|
||||
const expectedShapes = [
|
||||
{ action: 'read_file(', suffix: '/gsd-core/*)' },
|
||||
{ action: 'read_file(', suffix: '/agents/gsd-*)' },
|
||||
{ action: 'read_file(', suffix: '/skills/gsd-*)' },
|
||||
{ action: 'command(node ', suffix: '/hooks/*)' },
|
||||
];
|
||||
for (const { action, suffix } of expectedShapes) {
|
||||
const found = settings.permissions.allow.some((rule) => rule.startsWith(action) && rule.endsWith(suffix));
|
||||
assert.ok(found, `permissions.allow must include a rule shaped like "${action}...${suffix}" — got ${JSON.stringify(settings.permissions.allow)}`);
|
||||
}
|
||||
// Priority-scoping (deny/ask) is a user-owned decision — GSD never writes it.
|
||||
assert.equal(settings.permissions.deny, undefined, 'GSD must never write permissions.deny');
|
||||
assert.equal(settings.permissions.ask, undefined, 'GSD must never write permissions.ask');
|
||||
});
|
||||
}
|
||||
|
||||
test('configureAntigravityPermissions is idempotent — a second call adds no duplicate rules', (t) => {
|
||||
const root = fs.mkdtempSync(path.join(require('node:os').tmpdir(), 'gsd-ag-perm-idem-'));
|
||||
t.after(() => cleanup(root));
|
||||
|
||||
configureAntigravityPermissions(true, root);
|
||||
configureAntigravityPermissions(true, root);
|
||||
const settings = JSON.parse(fs.readFileSync(path.join(root, 'settings.json'), 'utf8'));
|
||||
assert.equal(settings.permissions.allow.length, new Set(settings.permissions.allow).size, 'no duplicate allow entries');
|
||||
assert.equal(settings.permissions.allow.length, buildAntigravityAllowRules(root).length);
|
||||
});
|
||||
|
||||
test('configureAntigravityPermissions preserves a pre-existing user permissions block (allow/deny/ask)', (t) => {
|
||||
const root = fs.mkdtempSync(path.join(require('node:os').tmpdir(), 'gsd-ag-perm-preserve-'));
|
||||
t.after(() => cleanup(root));
|
||||
|
||||
fs.writeFileSync(path.join(root, 'settings.json'), JSON.stringify({
|
||||
permissions: {
|
||||
allow: ['command(git)'],
|
||||
deny: ['command(rm -rf)'],
|
||||
ask: ['command(*)'],
|
||||
},
|
||||
userCustomField: 'preserve-me',
|
||||
}, null, 2));
|
||||
|
||||
configureAntigravityPermissions(true, root);
|
||||
|
||||
const settings = JSON.parse(fs.readFileSync(path.join(root, 'settings.json'), 'utf8'));
|
||||
assert.ok(settings.permissions.allow.includes('command(git)'), 'pre-existing allow entry preserved');
|
||||
assert.deepEqual(settings.permissions.deny, ['command(rm -rf)'], 'deny block untouched');
|
||||
assert.deepEqual(settings.permissions.ask, ['command(*)'], 'ask block untouched');
|
||||
assert.equal(settings.userCustomField, 'preserve-me', 'unrelated top-level user fields preserved');
|
||||
for (const rule of buildAntigravityAllowRules(root)) {
|
||||
assert.ok(settings.permissions.allow.includes(rule));
|
||||
}
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// UPGRADE 2: MCP companion config — live install (both scopes)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
for (const scope of ['global', 'local']) {
|
||||
test(`antigravity --${scope}: mcp_config.json registers the gsd MCP companion (UPGRADE 2)`, (t) => {
|
||||
const { configDir, root } = runMinimalInstall({ runtime: 'antigravity', scope });
|
||||
t.after(() => cleanup(root));
|
||||
|
||||
const mcpConfigPath = path.join(configDir, 'mcp_config.json');
|
||||
assert.ok(fs.existsSync(mcpConfigPath), `${mcpConfigPath} must exist`);
|
||||
|
||||
const mcpConfig = JSON.parse(fs.readFileSync(mcpConfigPath, 'utf8'));
|
||||
assert.ok(mcpConfig.mcpServers && mcpConfig.mcpServers.gsd, 'mcpServers.gsd must be present');
|
||||
assert.equal(mcpConfig.mcpServers.gsd.command, 'npx');
|
||||
assert.deepEqual(mcpConfig.mcpServers.gsd.args, ['-y', '-p', PACKAGE_NAME, 'gsd-mcp-server']);
|
||||
});
|
||||
}
|
||||
|
||||
test('configureAntigravityMcpConfig is idempotent — a second call does not clobber an existing gsd entry', (t) => {
|
||||
const root = fs.mkdtempSync(path.join(require('node:os').tmpdir(), 'gsd-ag-mcp-idem-'));
|
||||
t.after(() => cleanup(root));
|
||||
|
||||
configureAntigravityMcpConfig(true, root);
|
||||
// Simulate a user hand-edit of the gsd entry after install.
|
||||
const configPath = path.join(root, 'mcp_config.json');
|
||||
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
||||
config.mcpServers.gsd.args.push('--custom-flag');
|
||||
fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n');
|
||||
|
||||
configureAntigravityMcpConfig(true, root);
|
||||
|
||||
const after = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
||||
assert.ok(after.mcpServers.gsd.args.includes('--custom-flag'), 'a user-owned gsd override is never clobbered (Hyrum\'s Law)');
|
||||
});
|
||||
|
||||
test('configureAntigravityMcpConfig preserves a pre-existing unrelated mcpServers entry', (t) => {
|
||||
const root = fs.mkdtempSync(path.join(require('node:os').tmpdir(), 'gsd-ag-mcp-preserve-'));
|
||||
t.after(() => cleanup(root));
|
||||
|
||||
fs.writeFileSync(path.join(root, 'mcp_config.json'), JSON.stringify({
|
||||
mcpServers: {
|
||||
'my-own-server': { command: 'my-tool', args: ['--flag'] },
|
||||
},
|
||||
}, null, 2));
|
||||
|
||||
configureAntigravityMcpConfig(true, root);
|
||||
|
||||
const config = JSON.parse(fs.readFileSync(path.join(root, 'mcp_config.json'), 'utf8'));
|
||||
assert.deepEqual(config.mcpServers['my-own-server'], { command: 'my-tool', args: ['--flag'] });
|
||||
assert.ok(config.mcpServers.gsd);
|
||||
});
|
||||
|
||||
// AC-style proof: the companion mcp_config.json points at (bin/gsd-mcp-server.js)
|
||||
// is actually reachable, not just documented. Mirrors tests/gsd-mcp-server-bin.test.cjs
|
||||
// exactly (same shim, same line-delimited JSON-RPC over stdio).
|
||||
test('UPGRADE 2: gsd-mcp-server companion is reachable — spawn, initialize, tools/list over stdio', () => {
|
||||
const stdin = [
|
||||
JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'initialize' }),
|
||||
JSON.stringify({ jsonrpc: '2.0', id: 2, method: 'tools/list' }),
|
||||
].join('\n') + '\n';
|
||||
|
||||
const res = spawnSync(process.execPath, [MCP_SERVER_BIN], {
|
||||
input: stdin,
|
||||
encoding: 'utf-8',
|
||||
timeout: 15000,
|
||||
env: { ...process.env, GSD_TEST_MODE: '1' },
|
||||
});
|
||||
|
||||
assert.strictEqual(res.status, 0, `gsd-mcp-server must exit cleanly on stdin EOF; stderr: ${res.stderr}`);
|
||||
const lines = res.stdout.trim().split('\n').map((l) => JSON.parse(l));
|
||||
assert.strictEqual(lines.length, 2, 'one response per request');
|
||||
assert.strictEqual(lines[0].result.protocolVersion, PROTOCOL_VERSION, 'initialize handshake succeeds');
|
||||
const toolNames = lines[1].result.tools.map((t) => t.name).sort();
|
||||
assert.deepStrictEqual(
|
||||
toolNames,
|
||||
['gsd_invoke_command', 'gsd_read_state', 'gsd_write_state'],
|
||||
'the companion the mcp_config.json entry connects to advertises the real GSD tool surface',
|
||||
);
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Uninstall — symmetric cleanup for both upgrades
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
test('antigravity --global uninstall removes only GSD-owned permissions.allow rules + mcpServers.gsd, preserving user data', (t) => {
|
||||
const root = fs.mkdtempSync(path.join(require('node:os').tmpdir(), 'gsd-ag-uninstall-'));
|
||||
t.after(() => cleanup(root));
|
||||
|
||||
const args = [INSTALL_SCRIPT, '--antigravity', '--global', '--config-dir', root];
|
||||
const installResult = spawnSync(process.execPath, args, {
|
||||
encoding: 'utf8',
|
||||
env: installerEnv({ HOME: root, USERPROFILE: root }),
|
||||
});
|
||||
assert.strictEqual(installResult.status, 0, `install failed: ${installResult.stderr}`);
|
||||
|
||||
// Seed user-owned data alongside GSD's contributions, post-install.
|
||||
const settingsPath = path.join(root, 'settings.json');
|
||||
const settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
|
||||
settings.permissions.allow.push('command(git)');
|
||||
settings.permissions.deny = ['command(rm -rf)'];
|
||||
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + '\n');
|
||||
|
||||
const mcpConfigPath = path.join(root, 'mcp_config.json');
|
||||
const mcpConfig = JSON.parse(fs.readFileSync(mcpConfigPath, 'utf8'));
|
||||
mcpConfig.mcpServers['my-own-server'] = { command: 'my-tool', args: [] };
|
||||
fs.writeFileSync(mcpConfigPath, JSON.stringify(mcpConfig, null, 2) + '\n');
|
||||
|
||||
const uninstallArgs = [INSTALL_SCRIPT, '--antigravity', '--global', '--config-dir', root, '--uninstall'];
|
||||
const uninstallResult = spawnSync(process.execPath, uninstallArgs, {
|
||||
encoding: 'utf8',
|
||||
env: installerEnv({ HOME: root, USERPROFILE: root }),
|
||||
});
|
||||
assert.strictEqual(uninstallResult.status, 0, `uninstall failed: ${uninstallResult.stderr}`);
|
||||
|
||||
const settingsAfter = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
|
||||
assert.deepEqual(settingsAfter.permissions.allow, ['command(git)'], 'GSD allow rules removed, user rule preserved');
|
||||
assert.deepEqual(settingsAfter.permissions.deny, ['command(rm -rf)'], 'user deny rule preserved');
|
||||
|
||||
const mcpConfigAfter = JSON.parse(fs.readFileSync(mcpConfigPath, 'utf8'));
|
||||
assert.equal(mcpConfigAfter.mcpServers.gsd, undefined, 'gsd MCP entry removed');
|
||||
assert.deepEqual(mcpConfigAfter.mcpServers['my-own-server'], { command: 'my-tool', args: [] }, 'user MCP server preserved');
|
||||
});
|
||||
@@ -4453,11 +4453,12 @@ describe('ADR-857 phase 5f: cross-field consistency gate rejection tests (DEFECT
|
||||
}
|
||||
});
|
||||
|
||||
test('VALID_PERMISSION_WRITERS covers exactly {opencode, kilo}', () => {
|
||||
test('VALID_PERMISSION_WRITERS covers exactly {opencode, kilo, antigravity}', () => {
|
||||
assert.ok(VALID_PERMISSION_WRITERS instanceof Set, 'Must be a Set');
|
||||
assert.strictEqual(VALID_PERMISSION_WRITERS.size, 2, 'Must cover 2 permission writers');
|
||||
assert.strictEqual(VALID_PERMISSION_WRITERS.size, 3, 'Must cover 3 permission writers');
|
||||
assert.ok(VALID_PERMISSION_WRITERS.has('opencode'), 'Must include opencode');
|
||||
assert.ok(VALID_PERMISSION_WRITERS.has('kilo'), 'Must include kilo');
|
||||
assert.ok(VALID_PERMISSION_WRITERS.has('antigravity'), 'Must include antigravity (#2096)');
|
||||
});
|
||||
|
||||
// Confirm the valid base fixture does NOT produce errors (sanity)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// allow-test-rule: structural-regression-guard — AC2 requires asserting no `runtime === 'antigravity'` string-equality branch (nor an `isAntigravity` helper, nor a `canonical === 'antigravity'` branch) remains in bin/install.js, src/runtime-artifact-conversion.cts, src/shell-command-projection.cts, and src/runtime-name-policy.cts — the descriptor-migration contract is a property of the source text, so a source-grep is the only faithful check (#2096)
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
@@ -15,6 +16,17 @@
|
||||
* profile via profileOf, (2) confirms the public adapter classifies it as
|
||||
* declarative, and (3) round-trips a real install proving a gsd command surface
|
||||
* is emitted through the same engine the adapter delegates to.
|
||||
*
|
||||
* #2096 (EoS/antigravity) additions: negotiation fails CLOSED on a corrupted
|
||||
* descriptor, the 4 still-`undocumented` dispatch sub-axes (namedDispatch/
|
||||
* nested/maxDepth/backgroundDispatch) degrade to the most-restrictive known
|
||||
* value (never their optimistic value), the validator accepts the negotiated
|
||||
* subagentToolkit:'full' + permissionWriter:'antigravity' upgrade, and the
|
||||
* hardcoded `runtime === 'antigravity'` / `isAntigravity` / `canonical ===
|
||||
* 'antigravity'` branches are retired from the folded modules (folded into
|
||||
* descriptor-driven `runtime.hostBehaviors` + `runtime.hostIntegration`).
|
||||
* UPGRADE 1 (permission-writer) + UPGRADE 2 (MCP companion) live-install
|
||||
* coverage is in tests/antigravity-upgrades.test.cjs — not duplicated here.
|
||||
*/
|
||||
|
||||
const { test, before } = require('node:test');
|
||||
@@ -23,12 +35,20 @@ const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const { execFileSync } = require('node:child_process');
|
||||
|
||||
const { profileOf } = require('../gsd-core/bin/lib/host-integration.cjs');
|
||||
const {
|
||||
profileOf,
|
||||
negotiateHostCapabilities,
|
||||
PROFILE_BASELINES,
|
||||
UNDOCUMENTED,
|
||||
} = require('../gsd-core/bin/lib/host-integration.cjs');
|
||||
const { validateCapability } = require('../gsd-core/bin/lib/capability-validator.cjs');
|
||||
const { createDeclarativeAdapter } = require('../gsd-core/bin/lib/adapter-declarative.cjs');
|
||||
const { cleanup } = require('./helpers.cjs');
|
||||
const { walk, runMinimalInstall, BUILD_SCRIPT } = require('./helpers/install-shared.cjs');
|
||||
|
||||
const DESC = path.join(__dirname, '..', 'capabilities', 'antigravity', 'capability.json');
|
||||
const ANTIGRAVITY_CAP = JSON.parse(fs.readFileSync(DESC, 'utf8'));
|
||||
const ANTIGRAVITY_AXES = ANTIGRAVITY_CAP.runtime.hostIntegration;
|
||||
|
||||
// hooks/dist is gitignored and built (mirrors golden-install-parity harness).
|
||||
before(() => {
|
||||
@@ -66,6 +86,130 @@ test('a real Antigravity install emits a gsd command/skill surface (invocable)',
|
||||
}
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// #2096 EoS/antigravity — AC3/AC5: fail-closed negotiation + validator
|
||||
// acceptance + the folded descriptor (mirrors kimi/codex reference tests).
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// -- AC5: negotiation fails CLOSED on a corrupted descriptor ------------------
|
||||
|
||||
test('negotiateHostCapabilities never throws for antigravity, even fully corrupted', () => {
|
||||
assert.doesNotThrow(() => negotiateHostCapabilities({}));
|
||||
assert.doesNotThrow(() => negotiateHostCapabilities({ ...ANTIGRAVITY_AXES, embeddingMode: UNDOCUMENTED }));
|
||||
assert.doesNotThrow(() => negotiateHostCapabilities({ ...ANTIGRAVITY_AXES, embeddingMode: 'future-unknown' }));
|
||||
assert.doesNotThrow(() => negotiateHostCapabilities({ ...ANTIGRAVITY_AXES, dispatch: 'corrupted-not-an-object' }));
|
||||
assert.doesNotThrow(() => negotiateHostCapabilities({ ...ANTIGRAVITY_AXES, dispatch: { ...ANTIGRAVITY_AXES.dispatch, maxDepth: 'not-a-number' } }));
|
||||
});
|
||||
|
||||
test('a partial/empty antigravity descriptor degrades to the safe floor, not the declarative-cli baseline', () => {
|
||||
const result = negotiateHostCapabilities({});
|
||||
assert.equal(result.effective.embeddingMode, 'declarative', 'omitted embeddingMode degrades closed');
|
||||
assert.equal(result.effective.hookBus, 'none');
|
||||
assert.notDeepEqual(result.effective, PROFILE_BASELINES['declarative-cli']);
|
||||
assert.ok(result.warnings.length > 0);
|
||||
});
|
||||
|
||||
// AC-specific: the 4 still-undocumented dispatch sub-axes must degrade to the
|
||||
// most-restrictive KNOWN value, not their optimistic value. Real values below
|
||||
// were confirmed via:
|
||||
// node -e "const {negotiateHostCapabilities}=require('./gsd-core/bin/lib/host-integration.cjs');
|
||||
// const cap=require('./capabilities/antigravity/capability.json');
|
||||
// console.log(negotiateHostCapabilities(cap.runtime.hostIntegration).effective.dispatch)"
|
||||
// -> { namedDispatch:false, nested:false, maxDepth:0, background:false, subagentToolkit:'full', backgroundDispatch:false }
|
||||
test("antigravity's 4 still-undocumented dispatch sub-axes (namedDispatch/nested/maxDepth/backgroundDispatch) degrade to the most-restrictive known value, not their optimistic value", () => {
|
||||
// Sanity: the descriptor itself still declares these 4 as the undocumented
|
||||
// sentinel. subagentToolkit is the ONE dispatch axis Context7 confirmed as
|
||||
// 'full' (antigravity.google/docs/cli/features) — it is deliberately NOT
|
||||
// part of this still-undocumented set.
|
||||
assert.equal(ANTIGRAVITY_AXES.dispatch.namedDispatch, 'undocumented');
|
||||
assert.equal(ANTIGRAVITY_AXES.dispatch.nested, 'undocumented');
|
||||
assert.equal(ANTIGRAVITY_AXES.dispatch.maxDepth, 'undocumented');
|
||||
assert.equal(ANTIGRAVITY_AXES.dispatch.backgroundDispatch, 'undocumented');
|
||||
assert.equal(ANTIGRAVITY_AXES.dispatch.subagentToolkit, 'full', 'sanity: subagentToolkit is documented, not part of the undocumented set');
|
||||
|
||||
const { effective, warnings } = negotiateHostCapabilities(ANTIGRAVITY_AXES);
|
||||
|
||||
assert.equal(effective.dispatch.namedDispatch, false, 'undocumented namedDispatch must degrade to false, never true');
|
||||
assert.equal(effective.dispatch.nested, false, 'undocumented nested must degrade to false, never true');
|
||||
assert.equal(effective.dispatch.maxDepth, 0, 'undocumented maxDepth must degrade to 0, never -1/unbounded');
|
||||
assert.equal(effective.dispatch.backgroundDispatch, false, 'undocumented backgroundDispatch must degrade to false, never true');
|
||||
|
||||
// subagentToolkit is documented 'full' (not undocumented) — it is trusted
|
||||
// and survives negotiation, in contrast to the 4 sub-axes above.
|
||||
assert.equal(effective.dispatch.subagentToolkit, 'full', "documented 'full' subagentToolkit is trusted, unlike the undocumented sub-axes");
|
||||
|
||||
// background is declared `true` (documented, not undocumented) but the
|
||||
// struct-consistency cap in negotiateHostCapabilities still zeroes it
|
||||
// because its sibling namedDispatch degraded to false — a host-declared
|
||||
// `true` never overrides the fail-closed floor forced by a degraded axis.
|
||||
assert.equal(effective.dispatch.background, false, 'background is capped to false once namedDispatch degrades closed');
|
||||
|
||||
for (const axis of ['namedDispatch', 'nested', 'backgroundDispatch']) {
|
||||
assert.ok(
|
||||
warnings.some((w) => w.includes(`dispatch.${axis}`) && w.includes('undocumented')),
|
||||
`a warning must be raised for the undocumented dispatch.${axis} axis`,
|
||||
);
|
||||
}
|
||||
assert.ok(
|
||||
warnings.some((w) => w.includes('dispatch.maxDepth')),
|
||||
'a warning must be raised for the undocumented dispatch.maxDepth axis (reported as missing/non-number)',
|
||||
);
|
||||
});
|
||||
|
||||
// -- AC3: the validator accepts the negotiated/folded descriptor values ------
|
||||
|
||||
test('capabilities/antigravity/capability.json validates — subagentToolkit "full" + permissionWriter "antigravity" are accepted', () => {
|
||||
const errors = validateCapability(ANTIGRAVITY_CAP, 'antigravity');
|
||||
assert.deepEqual(errors, [], `validateCapability must return no errors, got: ${JSON.stringify(errors)}`);
|
||||
assert.equal(ANTIGRAVITY_AXES.dispatch.subagentToolkit, 'full');
|
||||
assert.equal(ANTIGRAVITY_CAP.runtime.permissionWriter, 'antigravity');
|
||||
});
|
||||
|
||||
// -- AC2: the folded-in hostBehaviors + subagentToolkit upgrade --------------
|
||||
|
||||
test('antigravity descriptor declares runtime.hostBehaviors (the folded-in behaviors) + the subagentToolkit upgrade', () => {
|
||||
const hb = ANTIGRAVITY_CAP.runtime.hostBehaviors;
|
||||
assert.ok(hb && typeof hb === 'object');
|
||||
assert.equal(hb.reviewerCli, true);
|
||||
assert.equal(hb.projectInstructionFile, 'GEMINI.md');
|
||||
assert.equal(hb.noPathRewrite, true);
|
||||
assert.equal(hb.hookPathStyle, 'raw');
|
||||
assert.equal(ANTIGRAVITY_AXES.dispatch.subagentToolkit, 'full',
|
||||
'subagentToolkit flipped undocumented -> full (antigravity.google/docs/cli/features)');
|
||||
});
|
||||
|
||||
// -- AC2: the hardcoded branches are retired across all folded modules -------
|
||||
|
||||
test('no `runtime === "antigravity"` string-equality branch (nor `isAntigravity` / `canonical === "antigravity"`) remains in the descriptor-migrated modules (AC2)', () => {
|
||||
const strip = (src) => src
|
||||
.replace(/\/\*[\s\S]*?\*\//g, '')
|
||||
.replace(/\/\/[^\r\n]*/g, '')
|
||||
.replace(/`[^`]*`/g, '');
|
||||
const repoRoot = path.join(__dirname, '..');
|
||||
const files = [
|
||||
path.join(repoRoot, 'bin', 'install.js'),
|
||||
path.join(repoRoot, 'src', 'runtime-artifact-conversion.cts'),
|
||||
path.join(repoRoot, 'src', 'shell-command-projection.cts'),
|
||||
path.join(repoRoot, 'src', 'runtime-name-policy.cts'),
|
||||
];
|
||||
for (const file of files) {
|
||||
const src = fs.readFileSync(file, 'utf8');
|
||||
const stripped = strip(src);
|
||||
|
||||
const eqOffenders = stripped.match(/runtime\s*[!=]==\s*'antigravity'/g) || [];
|
||||
assert.deepEqual(eqOffenders, [],
|
||||
`AC2: no hardcoded runtime==='antigravity' branch may remain in ${path.relative(repoRoot, file)}; found: ${eqOffenders.join(', ')}`);
|
||||
|
||||
const isAntigravityHits = stripped.match(/\bisAntigravity\b/g) || [];
|
||||
assert.deepEqual(isAntigravityHits, [],
|
||||
`AC2: no isAntigravity helper may remain in ${path.relative(repoRoot, file)}; found ${isAntigravityHits.length} occurrence(s)`);
|
||||
|
||||
const canonicalOffenders = stripped.match(/canonical\s*===\s*'antigravity'/g) || [];
|
||||
assert.deepEqual(canonicalOffenders, [],
|
||||
`AC2: no canonical==='antigravity' branch may remain in ${path.relative(repoRoot, file)}; found: ${canonicalOffenders.join(', ')}`);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// ────────────────────────────────────────────────────────────────────────
|
||||
// Folded from tests/bug-3608-antigravity-update-runtime-classification.test.cjs — consolidation epic #1969 (B3 #1972)
|
||||
|
||||
@@ -336,6 +336,7 @@
|
||||
"hooks/lib/git-cmd.js": "268ba15992ca0b23",
|
||||
"hooks/lib/gsd-graphify-rebuild.sh": "66af89601074d2a9",
|
||||
"hooks/managed-hooks-registry.cjs": "721d696556b7509f",
|
||||
"mcp_config.json": "9956d6a6e88a49e1",
|
||||
"package.json": "dbf8353f77358bc1",
|
||||
"scripts/changeset/README.md": "86ff89331dfd94b2",
|
||||
"scripts/changeset/cli.cjs": "68f92a344b199271",
|
||||
|
||||
@@ -343,9 +343,14 @@ describe('bug #1906: local hook commands use $CLAUDE_PROJECT_DIR', () => {
|
||||
* dir as cwd. Claude Code and others still use "$CLAUDE_PROJECT_DIR"/ (#1906).
|
||||
*
|
||||
* #1928: Google sunset Gemini CLI (2026-06-18) and the `gemini` runtime was
|
||||
* removed from GSD entirely. `projectLocalHookPrefix` now special-cases only
|
||||
* `antigravity` — an unrecognized runtime string like the former `'gemini'`
|
||||
* falls through to the default $CLAUDE_PROJECT_DIR-anchored prefix.
|
||||
* removed from GSD entirely.
|
||||
*
|
||||
* #2096: `projectLocalHookPrefix` no longer special-cases `antigravity` by
|
||||
* name — it branches on the caller-supplied `hookPathStyle` (sourced from
|
||||
* the runtime's `hostBehaviors.hookPathStyle` descriptor field). An
|
||||
* unrecognized runtime string like the former `'gemini'`, or any runtime
|
||||
* that doesn't declare `hookPathStyle: 'raw'`, falls through to the default
|
||||
* $CLAUDE_PROJECT_DIR-anchored prefix.
|
||||
*/
|
||||
|
||||
const { describe, test } = require('node:test');
|
||||
@@ -357,7 +362,13 @@ const { projectLocalHookPrefix, projectShellCommandText } = projection;
|
||||
|
||||
describe('bug #2557: Antigravity local hooks use relative paths (not $CLAUDE_PROJECT_DIR); gemini runtime removed (#1928)', () => {
|
||||
test('Antigravity local prefix is bare dirName', () => {
|
||||
assert.equal(projectLocalHookPrefix({ runtime: 'antigravity', dirName: '.agents' }), '.agents');
|
||||
// #2096: hookPathStyle is now the caller-supplied descriptor value
|
||||
// (bin/install.js resolves it from hostBehaviors.hookPathStyle); the
|
||||
// function itself no longer knows the runtime name 'antigravity'.
|
||||
assert.equal(
|
||||
projectLocalHookPrefix({ runtime: 'antigravity', dirName: '.agents', hookPathStyle: 'raw' }),
|
||||
'.agents',
|
||||
);
|
||||
});
|
||||
|
||||
test('non-Antigravity local prefix remains $CLAUDE_PROJECT_DIR anchored', () => {
|
||||
@@ -512,7 +523,13 @@ describe('bug #3439: shell projection module owns managed-hook policy and legacy
|
||||
});
|
||||
|
||||
test('projectLocalHookPrefix centralizes runtime-specific project-dir interpolation policy', () => {
|
||||
assert.equal(projectLocalHookPrefix({ runtime: 'antigravity', dirName: '.agents' }), '.agents');
|
||||
// #2096: 'raw' hookPathStyle (descriptor-driven) is what produces the
|
||||
// bare-dirName behavior now — the function no longer branches on the
|
||||
// 'antigravity' runtime name itself.
|
||||
assert.equal(
|
||||
projectLocalHookPrefix({ runtime: 'antigravity', dirName: '.agents', hookPathStyle: 'raw' }),
|
||||
'.agents',
|
||||
);
|
||||
assert.equal(
|
||||
projectLocalHookPrefix({ runtime: 'claude', dirName: '.claude' }),
|
||||
'"$CLAUDE_PROJECT_DIR"/.claude',
|
||||
|
||||
Reference in New Issue
Block a user