Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e87e0b3
fix(e2e): restore sandbox fake API reachability
prekshivyas Sep 1, 2026
7165c49
Merge remote-tracking branch 'origin/main' into codex/fix-e2e-proxy-b…
prekshivyas Sep 1, 2026
e450ab9
test(e2e): map Hermes Discord bridge proof
prekshivyas Sep 1, 2026
55d311b
fix(e2e): harden fake API proxy readiness
prekshivyas Sep 1, 2026
ba045b8
test(e2e): complete fake API proxy migration
prekshivyas Sep 1, 2026
5591017
test(e2e): capture fake API startup diagnostics
prekshivyas Sep 1, 2026
6333239
test(e2e): prove proxy upstream reachability
prekshivyas Sep 1, 2026
cef370f
test(e2e): preserve proxy failure diagnostics
prekshivyas Sep 1, 2026
1406187
fix(e2e): handle proxy readiness socket errors
cv Sep 1, 2026
d33e618
test(e2e): handle proxy readiness resets
prekshivyas Sep 1, 2026
d10fdcf
fix(e2e): tighten Discord fixture diagnostics
cv Sep 1, 2026
d1f1bcb
refactor(e2e): consolidate fake API readiness
prekshivyas Sep 1, 2026
848f5fd
test(e2e): map pairing helper parity proof
cv Sep 1, 2026
d545462
test(e2e): remove retired Vitest import
cv Sep 1, 2026
b0bc674
test(e2e): own pairing helper parity
prekshivyas Sep 1, 2026
639f64b
test(e2e): clarify best-effort diagnostics
cv Sep 1, 2026
be75a56
test(e2e): verify fake API Docker topology
prekshivyas Sep 1, 2026
2b796e5
test(e2e): strengthen fake API topology proofs
cv Sep 1, 2026
404dba6
test(e2e): use valid Discord fixture contract
cv Sep 1, 2026
b098f29
test(e2e): complete topology regression proof
prekshivyas Sep 1, 2026
a360c93
refactor(e2e): inline Hermes fixture setup
cv Sep 1, 2026
8f1fccc
test(e2e): use independent topology evidence
prekshivyas Sep 1, 2026
2cba16d
fix(e2e): preserve stopped fixture diagnostics
prekshivyas Sep 1, 2026
be5d0c6
test(e2e): prove fake API Docker topology
prekshivyas Sep 1, 2026
d672507
test(e2e): register topology proof parity
prekshivyas Sep 1, 2026
7e89676
fix(e2e): scope Hermes Discord policy binary
prekshivyas Sep 1, 2026
9eff794
test(e2e): assert diagnostic artifact outcomes
prekshivyas Sep 1, 2026
dc16294
Merge remote-tracking branch 'origin/main' into codex/fix-e2e-proxy-b…
prekshivyas Sep 1, 2026
18ee35f
fix(e2e): keep proxy environment credential-free
prekshivyas Sep 1, 2026
3c8d563
refactor(e2e): consolidate topology validation
prekshivyas Sep 1, 2026
3796452
test(e2e): derive topology from Docker commands
prekshivyas Sep 1, 2026
b3bb16e
test(e2e): isolate proxy proof environment
prekshivyas Sep 1, 2026
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
102 changes: 81 additions & 21 deletions test/e2e/fixtures/hermes-discord-policy-binding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,100 @@ const policyBoundary = (
) as typeof policyBoundaryModule;
const { parseOpenShellPolicy } = policyBoundary;

function findHermesDiscordPolicyEndpoint(
policy: { network_policies?: Record<string, unknown> },
host: string,
port: number,
protocol: string,
): { endpoint: Record<string, unknown>; policyEntry: Record<string, unknown> } {
for (const candidate of Object.values(policy.network_policies ?? {})) {
if (typeof candidate !== "object" || candidate === null || Array.isArray(candidate)) continue;
const policyEntry = candidate as Record<string, unknown>;
if (!Array.isArray(policyEntry.endpoints)) continue;
const endpoint = policyEntry.endpoints.find((entry) => {
if (typeof entry !== "object" || entry === null || Array.isArray(entry)) return false;
const value = entry as { host?: unknown; port?: unknown; protocol?: unknown };
return value.host === host && value.port === port && value.protocol === protocol;
});
if (typeof endpoint === "object" && endpoint !== null && !Array.isArray(endpoint)) {
return { endpoint: endpoint as Record<string, unknown>, policyEntry };
}
}
throw new Error("fake Discord endpoint is missing from the base policy");
}

function readPolicy(policyFile: string) {
const source = fs.readFileSync(policyFile, "utf8");
return parseOpenShellPolicy(source).policy;
}

export function bindHermesDiscordPolicyEndpoint(
policyFile: string,
providerName: string,
host: string,
port: number,
protocol: string,
): void {
const source = fs.readFileSync(policyFile, "utf8");
const policy = parseOpenShellPolicy(source).policy;
const endpoints = Object.values(policy.network_policies ?? {}).flatMap((entry) => {
if (typeof entry !== "object" || entry === null || Array.isArray(entry)) return [];
const candidateEndpoints = (entry as { endpoints?: unknown }).endpoints;
return Array.isArray(candidateEndpoints) ? candidateEndpoints : [];
});
const endpoint = endpoints.find((candidate) => {
if (typeof candidate !== "object" || candidate === null || Array.isArray(candidate)) {
return false;
}
const value = candidate as { host?: unknown; port?: unknown; protocol?: unknown };
return (
value.host === host &&
value.port === port &&
value.protocol === protocol
);
}) as Record<string, unknown> | undefined;
if (!endpoint) throw new Error("fake Discord endpoint is missing from the base policy");

const policy = readPolicy(policyFile);
const { endpoint } = findHermesDiscordPolicyEndpoint(policy, host, port, protocol);
endpoint.credential_binding = { provider: providerName };
fs.writeFileSync(policyFile, YAML.stringify(policy));
fs.chmodSync(policyFile, 0o600);
}

export function assertHermesDiscordPolicyEndpointBinaries(
policyFile: string,
host: string,
port: number,
protocol: string,
expectedBinaries: string[],
): void {
const { policyEntry } = findHermesDiscordPolicyEndpoint(
readPolicy(policyFile),
host,
port,
protocol,
);
if (!Array.isArray(policyEntry.binaries)) {
throw new Error("fake Discord endpoint policy has no binary restrictions");
}
const binaries = policyEntry.binaries.map((candidate) => {
if (typeof candidate !== "object" || candidate === null || Array.isArray(candidate)) {
throw new Error("fake Discord endpoint policy has an invalid binary restriction");
}
const binaryPath = (candidate as { path?: unknown }).path;
if (typeof binaryPath !== "string") {
throw new Error("fake Discord endpoint policy has an invalid binary path");
}
return binaryPath;
});
if (JSON.stringify(binaries) !== JSON.stringify(expectedBinaries)) {
throw new Error(
`fake Discord endpoint policy binaries ${JSON.stringify(binaries)} did not match ${JSON.stringify(expectedBinaries)}`,
);
}
}

function main(): void {
const [policyFile, providerName, host, rawPort, protocol] = process.argv.slice(2);
const args = process.argv.slice(2);
if (args[0] === "--assert-binaries") {
const [, policyFile, host, rawPort, protocol, ...expectedBinaries] = args;
if (!policyFile || !host || !rawPort || !protocol || expectedBinaries.length === 0) {
throw new Error(
"usage: hermes-discord-policy-binding --assert-binaries <policy-file> <host> <port> <protocol> <binary>...",
);
}
assertHermesDiscordPolicyEndpointBinaries(
policyFile,
host,
Number(rawPort),
protocol,
expectedBinaries,
);
return;
}

const [policyFile, providerName, host, rawPort, protocol] = args;
if (!policyFile || !providerName || !host || !rawPort || !protocol) {
throw new Error(
"usage: hermes-discord-policy-binding <policy-file> <provider> <host> <port> <protocol>",
Expand Down
Loading
Loading