SpecAndTests: Read-Only Public Repo Tree & File Browser
verified SpecAndTestsnd_sa_repo_browser_spec · spec_hash: 00b2c96b10f389f7… · 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
00b2c96b10f389f7…
owner_signoff@v1
Copyable Citation Snippet
Caisson Kernel-Verified Proof Receipt: "SpecAndTests: Read-Only Public Repo Tree & File Browser" ID: nd_sa_repo_browser_spec | Workspace: caisson-self-assembly | Env: node:22-ts:5.8 Verification: Kernel Verified | Axioms: deterministic sandbox | Mode: Zero-Install Cloud Sandbox | Downstream Reuse: 0 Target Spec SHA-256: 00b2c96b10f389f7 | URL: https://caisson.tools/explore/w/caisson-self-assembly/nodes/nd_sa_repo_browser_spec
Hand off a Warm Relay: Share this cached proof into Implementation: Read-Only Public Repo Tree & File Browser so a teammate skips cold start and you earn cross-operator reuse credit.
Problem Statement / Mathematical Summary
Frozen Vitest acceptance spec for zero-clone public repository inspection (
/w/:slug/tree.md and /w/:slug/files/*) with path traversal and privacy airlock checks.Upstream: None
Frozen Target Specification (spec/target_statements/feat3-repo-browser.acceptance.test.ts)
// spec/target_statements/feat3-repo-browser.acceptance.test.ts
// Frozen Acceptance Spec (Zero-Clone Public Repo Tree & File Browser):
// Implement src/web/repoBrowser.ts exporting:
// - renderRepoTreeMarkdown(db, git, slug: string, baseUrl?: string): string | null
// - renderRepoFileContent(db, git, slug: string, relPath: string): string | null
// - createRepoBrowserRouter(db, git, baseUrl?: string): express.Router
import { describe, expect, it } from 'vitest';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import { openDatabase, nowIso, sha256Hex } from '../src/db/sqlite.js';
import { BareGitStore } from '../src/storage/gitStore.js';
import {
renderRepoTreeMarkdown,
renderRepoFileContent,
} from '../src/web/repoBrowser.js';
describe('Self-Assembly Feature 3: Read-Only Public Repo Tree & File Browser', () => {
function createFixture() {
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'caisson-repo-browser-'));
const db = openDatabase(path.join(tmp, 'test.db'), path.resolve('./migrations'));
const git = new BareGitStore(path.join(tmp, 'repos'));
const now = nowIso();
const { repoDir, commitSha } = git.initWorkspaceRepo('demo-code', [
{ path: 'README.md', content: Buffer.from('# Demo Code\n') },
{ path: 'src/hello.ts', content: Buffer.from('export const greet = () => "hello";\n') },
]);
const lock = sha256Hex('node:22');
db.prepare(`
INSERT INTO workspaces (
id, slug, owner_operator_id, title, problem_statement_md, visibility,
domain_pack_ref, merge_target, verifier_config, environment_version,
environment_lock_hash, git_repo_uri, git_head_sha, created_at, updated_at
) VALUES
('ws_code_pub', 'demo-code', 'op_owner', 'Demo Code', 'Body', 'public', NULL, 'repo_root', '{}', 'node:22-ts:5.8', ?, ?, ?, ?, ?),
('ws_code_priv', 'secret-code', 'op_owner', 'Secret Code', 'Body', 'private', NULL, 'repo_root', '{}', 'node:22-ts:5.8', ?, ?, ?, ?, ?)
`).run(lock, repoDir, commitSha, now, now, lock, repoDir, commitSha, now, now);
return { db, git, cleanup: () => { db.close(); fs.rmSync(tmp, { recursive: true, force: true }); } };
}
it('lists tracked files at HEAD for public workspaces and hides private workspaces', () => {
const { db, git, cleanup } = createFixture();
try {
const md = renderRepoTreeMarkdown(db, git, 'demo-code', 'https://caisson.tools');
expect(md).not.toBeNull();
expect(md!).toContain('src/hello.ts');
expect(md!).toContain('https://caisson.tools/w/demo-code/files/src/hello.ts');
expect(renderRepoTreeMarkdown(db, git, 'secret-code', 'https://caisson.tools')).toBeNull();
} finally {
cleanup();
}
});
it('returns file contents safely and blocks path traversal or private workspace access', () => {
const { db, git, cleanup } = createFixture();
try {
expect(renderRepoFileContent(db, git, 'demo-code', 'src/hello.ts')).toContain('export const greet');
expect(renderRepoFileContent(db, git, 'demo-code', '../etc/passwd')).toBeNull();
expect(renderRepoFileContent(db, git, 'demo-code', 'does/not/exist.ts')).toBeNull();
expect(renderRepoFileContent(db, git, 'secret-code', 'src/hello.ts')).toBeNull();
} finally {
cleanup();
}
});
});
Kernel-Verified Proof / Solution (spec/target_statements/feat3-repo-browser.acceptance.test.ts)
// spec/target_statements/feat3-repo-browser.acceptance.test.ts
// Frozen Acceptance Spec (Zero-Clone Public Repo Tree & File Browser):
// Implement src/web/repoBrowser.ts exporting:
// - renderRepoTreeMarkdown(db, git, slug: string, baseUrl?: string): string | null
// - renderRepoFileContent(db, git, slug: string, relPath: string): string | null
// - createRepoBrowserRouter(db, git, baseUrl?: string): express.Router
import { describe, expect, it } from 'vitest';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import { openDatabase, nowIso, sha256Hex } from '../src/db/sqlite.js';
import { BareGitStore } from '../src/storage/gitStore.js';
import {
renderRepoTreeMarkdown,
renderRepoFileContent,
} from '../src/web/repoBrowser.js';
describe('Self-Assembly Feature 3: Read-Only Public Repo Tree & File Browser', () => {
function createFixture() {
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'caisson-repo-browser-'));
const db = openDatabase(path.join(tmp, 'test.db'), path.resolve('./migrations'));
const git = new BareGitStore(path.join(tmp, 'repos'));
const now = nowIso();
const { repoDir, commitSha } = git.initWorkspaceRepo('demo-code', [
{ path: 'README.md', content: Buffer.from('# Demo Code\n') },
{ path: 'src/hello.ts', content: Buffer.from('export const greet = () => "hello";\n') },
]);
const lock = sha256Hex('node:22');
db.prepare(`
INSERT INTO workspaces (
id, slug, owner_operator_id, title, problem_statement_md, visibility,
domain_pack_ref, merge_target, verifier_config, environment_version,
environment_lock_hash, git_repo_uri, git_head_sha, created_at, updated_at
) VALUES
('ws_code_pub', 'demo-code', 'op_owner', 'Demo Code', 'Body', 'public', NULL, 'repo_root', '{}', 'node:22-ts:5.8', ?, ?, ?, ?, ?),
('ws_code_priv', 'secret-code', 'op_owner', 'Secret Code', 'Body', 'private', NULL, 'repo_root', '{}', 'node:22-ts:5.8', ?, ?, ?, ?, ?)
`).run(lock, repoDir, commitSha, now, now, lock, repoDir, commitSha, now, now);
return { db, git, cleanup: () => { db.close(); fs.rmSync(tmp, { recursive: true, force: true }); } };
}
it('lists tracked files at HEAD for public workspaces and hides private workspaces', () => {
const { db, git, cleanup } = createFixture();
try {
const md = renderRepoTreeMarkdown(db, git, 'demo-code', 'https://caisson.tools');
expect(md).not.toBeNull();
expect(md!).toContain('src/hello.ts');
expect(md!).toContain('https://caisson.tools/w/demo-code/files/src/hello.ts');
expect(renderRepoTreeMarkdown(db, git, 'secret-code', 'https://caisson.tools')).toBeNull();
} finally {
cleanup();
}
});
it('returns file contents safely and blocks path traversal or private workspace access', () => {
const { db, git, cleanup } = createFixture();
try {
expect(renderRepoFileContent(db, git, 'demo-code', 'src/hello.ts')).toContain('export const greet');
expect(renderRepoFileContent(db, git, 'demo-code', '../etc/passwd')).toBeNull();
expect(renderRepoFileContent(db, git, 'demo-code', 'does/not/exist.ts')).toBeNull();
expect(renderRepoFileContent(db, git, 'secret-code', 'src/hello.ts')).toBeNull();
} finally {
cleanup();
}
});
});
Verification Receipt
pass · score: 1
{
"gate": "owner_signoff",
"frozen_spec_sha256": "00b2c96b10f389f7a16f465b7e8ee408cfdb5f114e09642e2e3ab0d26d6ce7d3"
}