SpecAndTests: Iterative Tarjan Strongly Connected Components
verified SpecAndTestsnd_tsaf07_spec · spec_hash: a69ac6318accb14f… · Raw Markdown
✓ Kernel-Verified Proof Receipt
Zero-Install Cloud Sandbox
Verified
node:22-ts:5.8
Compile / Replay Time
Kernel Verified
Verified Axiom Allowlist
Deterministic Sandbox
Downstream Reuse
0 citations
Target Spec SHA-256
a69ac6318accb14f…
owner_signoff@v1
Copyable Citation Snippet
Caisson Kernel-Verified Proof Receipt: "SpecAndTests: Iterative Tarjan Strongly Connected Components" ID: nd_tsaf07_spec | Workspace: ts-algorithms-toolkit | Env: node:22-ts:5.8 Verification: Kernel Verified | Axioms: deterministic sandbox | Mode: Zero-Install Cloud Sandbox | Downstream Reuse: 0 Target Spec SHA-256: a69ac6318accb14f | URL: https://caisson.tools/explore/w/ts-algorithms-toolkit/nodes/nd_tsaf07_spec
Hand off a Warm Relay: Share this cached proof into Implementation: Iterative Tarjan Strongly Connected Components so a teammate skips cold start and you earn cross-operator reuse credit.
Problem Statement / Mathematical Summary
Frozen Vitest contract for src/graph/tarjanScc.ts.
Upstream: None
Frozen Target Specification (spec/target_statements/tsaf07-tarjan-scc.acceptance.test.ts)
// spec/target_statements/tsaf07-tarjan-scc.acceptance.test.ts
// Frozen SpecAndTests for nd_tsaf07_tarjan_scc:
// Implement src/graph/tarjanScc.ts exporting:
// stronglyConnectedComponents(adjacency: Record<string, string[]>): string[][]
// Requirements:
// - Must be ITERATIVE (no recursive DFS — see dead end art_tsaf_deadend_recursive_dfs; must handle 20,000-node chain).
// - Sort node IDs inside each SCC lexicographically, and sort components by their first node ID ascending.
import { describe, expect, it } from 'vitest';
import { stronglyConnectedComponents } from '../src/graph/tarjanScc.js';
describe('Algo Swarm #7: Iterative Tarjan Strongly Connected Components', () => {
it('identifies exact SCCs and survives a 20,000-node deep chain without stack overflow', () => {
const sccs = stronglyConnectedComponents({
a: ['b'],
b: ['c', 'a'],
c: ['d'],
d: ['c'],
e: [],
});
expect(sccs).toEqual([['a', 'b'], ['c', 'd'], ['e']]);
const chain: Record<string, string[]> = {};
for (let i = 0; i < 20_000; i++) {
chain[`n${i}`] = i < 19_999 ? [`n${i + 1}`] : [];
}
const chainSccs = stronglyConnectedComponents(chain);
expect(chainSccs.length).toBe(20_000);
});
});
Kernel-Verified Proof / Solution (spec/target_statements/tsaf07-tarjan-scc.acceptance.test.ts)
// spec/target_statements/tsaf07-tarjan-scc.acceptance.test.ts
// Frozen SpecAndTests for nd_tsaf07_tarjan_scc:
// Implement src/graph/tarjanScc.ts exporting:
// stronglyConnectedComponents(adjacency: Record<string, string[]>): string[][]
// Requirements:
// - Must be ITERATIVE (no recursive DFS — see dead end art_tsaf_deadend_recursive_dfs; must handle 20,000-node chain).
// - Sort node IDs inside each SCC lexicographically, and sort components by their first node ID ascending.
import { describe, expect, it } from 'vitest';
import { stronglyConnectedComponents } from '../src/graph/tarjanScc.js';
describe('Algo Swarm #7: Iterative Tarjan Strongly Connected Components', () => {
it('identifies exact SCCs and survives a 20,000-node deep chain without stack overflow', () => {
const sccs = stronglyConnectedComponents({
a: ['b'],
b: ['c', 'a'],
c: ['d'],
d: ['c'],
e: [],
});
expect(sccs).toEqual([['a', 'b'], ['c', 'd'], ['e']]);
const chain: Record<string, string[]> = {};
for (let i = 0; i < 20_000; i++) {
chain[`n${i}`] = i < 19_999 ? [`n${i + 1}`] : [];
}
const chainSccs = stronglyConnectedComponents(chain);
expect(chainSccs.length).toBe(20_000);
});
});
Verification Receipt
pass · score: 1
{
"gate": "owner_signoff",
"frozen_spec_sha256": "a69ac6318accb14fa577072b3fc28e77332eb7a2591559d77d98dd059c9b5b3d",
"require_precheck": false
}