# Project export: PolicyTwin

This document was generated by HackStack to give an AI agent context about a hackathon project. Sections are labeled with their provenance; content marked as truncated was cut to keep this document small.

## Project metadata

- Hackathon: OpenAI Build Week
- Tagline: Turn policy text into verified product behavior.
- Devpost: https://devpost.com/software/policytwin
- GitHub: https://github.com/sel-chan/policytwin
- Video: https://www.youtube.com/embed/h7o1vXmWC-M?enablejsapi=1&hl=en_US&rel=0&start=&version=3&wmode=transparent
- Team: 1 GitHub contributor(s) — sel-chan (142 commits)

## Devpost submission (written by the team)

### Overview

Business policies live in prose while customer decisions live in code. A single strict inequality or misplaced exception can silently change who receives a refund. PolicyTwin connects each policy sentence to an explicit decision, executable rule, edge case, application behavior, code location, and reviewable proof. The seeded Build Week workflow starts with a synthetic SaaS refund policy. Policy Studio keeps source-clause traceability and a strict PolicyIR. Decision Queue records three material ambiguity choices instead of hiding them in a prompt. Deterministic code compiles the accepted model to Rego, and checksum-pinned OPA 1.18.2 evaluates 41 golden, boundary, conflict, and generated cases. Integration / Drift compares the same accepted expectations with a deliberately buggy TypeScript fixture and exposes 16 counterexamples caused by three defects: excluding exactly day 14, excluding exactly 20% usage, and allowing an approved promotion to bypass final-sale precedence. The bounded local challenge run then asked GPT-5.6 Sol through Codex SDK/CLI 0.144.6 to repair a fresh fixture copy. Codex returned complete replacements for the two fixed files without seeing the evaluation-only expected implementation. PolicyTwin derived the filesystem diff, ran the fixed typecheck and seven regression tests, replayed all 41 accepted policy cases, and required a distinct read-only Codex review. The captured result is 41/41, zero drift, and APPROVE with no blocking finding; prompt, schema, thread, tree, command, result, and diff hashes are checked into artifacts/challenge-evidence/. The Proof view keeps claims attached to machine-readable evidence and leaves unavailable capabilities marked as not run. The local challenge profile is deliberately separate from the production verify:live contract: it may use a logged-in Codex SDK run on a disposable fixture, but it never claims cgroup-v2 isolation, direct Responses API evidence, deployment security, or production attestation. Judges can reproduce the deterministic seeded workflow with pnpm demo:run, inspect all six views with pnpm dev, run the full offline gate with pnpm verify, and validate the captured GPT-5.6/Codex proof with pnpm challenge:check.

## README (from the GitHub repository)

# PolicyTwin

**Turn a policy sentence into rules, tests, application behavior, and reviewable proof.**

Refund policies are written in prose, but products enforce them in code. A single `<` instead of `<=`, or one exception in the wrong order, can change who receives a refund. PolicyTwin keeps the policy and the implementation in sync.

![PolicyTwin Policy Studio](artifacts/screenshots/01-policy-studio.png)

## Build Week result

PolicyTwin found three seeded bugs in a TypeScript refund application, asked GPT-5.6 Sol through Codex to repair a disposable copy, and then checked the result independently.

| Result | Evidence |
|---|---:|
| Seeded application bugs | 3 |
| Counterexamples before repair | 16 |
| Codex-authored files changed | 2 |
| Regression tests after repair | 7 / 7 |
| Accepted policy cases after repair | 41 / 41 |
| Application drift after repair | 0 |
| Independent review | `APPROVE` |

- [Watch the 2:48 demo](https://youtu.be/h7o1vXmWC-M)
- [View the submitted Devpost entry](https://devpost.com/software/policytwin)
- [Inspect the captured GPT-5.6/Codex evidence](artifacts/challenge-evidence/summary.md)
- Primary Codex `/feedback` session: `019f5dcf-0233-7a80-9147-af10c7bbfb28`

## How it works

1. **Policy Studio** links each source clause to a strict, versioned `PolicyIR`.
2. **Decision Queue** makes boundary and precedence choices explicit instead of hiding them in a prompt.
3. A deterministic compiler converts accepted `PolicyIR` into Rego, and checksum-pinned OPA evaluates it.
4. **Case Lab** generates boundary, conflict, contrast, and mutation cases.
5. **Integration / Drift** runs the same expectations against the TypeScript application and shows concrete counterexamples.
6. Codex repairs only the two approved fixture files; PolicyTwin derives the diff, runs fixed commands, replays all 41 cases, and requires an independent review.

```mermaid
flowchart LR
    A[Policy text] --> B[Versioned PolicyIR]
    B --> C[Rego + OPA]
    B --> D[41 accepted cases]
    D --> E[TypeScript application]
    E --> F[Drift report]
    F --> G[GPT-5.6 + Codex repair]
    G --> H[7/7 tests · 41/41 cases · zero drift · APPROVE]
```

## Try the judge path

Requirements: Node.js 22+, pnpm 11.7+, and Windows PowerShell. The deterministic demo does not need an API key.

```powershell
pnpm install --frozen-lockfile
pnpm opa:install
pnpm demo:run
pnpm dev
```

Open `http://localhost:3000`, then review these views in order:

1. Policy Studio
2. Decision Queue
3. Case Lab
4. Integration / Drift
5. Proof
6. Change Impact

`pnpm demo:run` resets only the bundled trusted fixture and must report exactly the three seeded drifts. The strongest result is visible in **Integration / Drift**: two changed files, 7/7 regressions, 41/41 accepted cases, zero drift, and `APPROVE`.

## What is demonstrated—and what is next

| Area | Current Build Week evidence |
|---|---|
| Policy contract, decisions, Rego, OPA, cases, and drift | Working deterministic product flow |
| GPT-5.6/Codex repair | Captured real bounded run with filesystem-derived diff and independent review |
| Natural-language interpretation | The judge demo starts from a recorded, schema-validated `PolicyIR`; a fresh direct Responses API interpretation was not run |
| Browser-triggered repair | The UI presents the verified captured repair; a fresh hosted repair worker is not connected to the button |
| Production deployment and isolation | Separate future hardening track, not a Build Week result claim |

These boundaries are intentional and visible. PolicyTwin never turns missing production infrastructure into a success claim.

## Reproduce the captured result

The checked-in capture can be validated without making a new model call:

```powershell
pnpm challenge:check
pnpm challenge:submission:check
```

Key evidence:

- [`artifacts/challenge-evidence/summary.md`](artifacts/challenge-evidence/summary.md) — human-readable repair result
- [`artifacts/challenge-evidence/local-challenge-run.json`](artifacts/challenge-evidence/local-challenge-run.json) — model, commands, cases, review, and hashes
- [`artifacts/challenge-evidence/integration.diff`](artifacts/challenge-evidence/integration.diff) — filesystem-derived repair diff
- [`artifacts/evidence/summary.md`](artifacts/evidence/summary.md) — deterministic reference evidence
- [`artifacts/challenge-submission/`](artifacts/challenge-submission/) — final challenge handoff

## Useful commands

| Command | Purpose |
|---|---|
| `pnpm demo:reset` | Restore the trusted demo fixture and local demo state |
| `pnpm demo:run` | Reproduce the three seeded drifts |
| `pnpm dev` | Start the six-view web workspace |
| `pnpm challenge:check` | Validate the captured GPT-5.6/Codex repair evidence |
| `pnpm challenge:submission:check` | Validate challenge links, video binding, and handoff metadata |
| `pnpm verify` | Run the deterministic offline repository gate |
| `pnpm verify:live` | Separate production-live gate; not required to inspect the captured challenge result |

The last recorded offline gate passed 452 unit tests, 82 integration tests, 22 evaluation tests, 3 browser tests, production build, clean-copy replay, and security/history checks. See [`PROGRESS.md`](PROGRESS.md) for the exact checkpoint.

## Optional server configuration

Copy `.env.example` only when working on server-side integrations. Never expose these values to the browser or commit them.

| Variable | Purpose |
|---|---|
| `OPENAI_API_KEY` | Server-side Responses API credential |
| `OPENAI_MODEL` | Configurable interpretation model; defaults to `gpt-5.6` |
| `CODEX_MODEL` | Explicit Codex repair model |
| `POLICYTWIN_RUN_TOKEN` | Protects the interpretation route |
| `POLICYTWIN_DATABASE_PATH` | Optional SQLite location |

The bounded Build Week capture used `gpt-5.6-sol` through the project-pinned Codex SDK/CLI 0.144.6 against a disposable fixture. Codex produced complete replacements for `src/refund.ts` and `tests/refund.test.mjs`; PolicyTwin—not model prose—derived and verified the result.

## Architecture, safety, and limitations

PolicyTwin executes only the bundled trusted refund fixture. It does not execute uploaded or arbitrary repositories. It is a software verification aid, not legal advice; real policy deployment requires human approval.

Detailed engineering material is kept out of the quick judge path:

- [Architecture](docs/architecture.md)
- [Demo runbook](docs/demo-runbook.md)
- [Threat model](docs/threat-model.md)
- [Limitations](docs/limitations.md)
- [Decision record](DECISIONS.md)
- [Submission record](SUBMISSION.md)

## License

MIT License. Copyright (c) 2026 CHAN. See [`LICENSE`](LICENSE) and [`NOTICE.md`](NOTICE.md).


## Detected evidence (automated analysis)

Indexed codebase: 194 recognized source files, 2382 KB.
- C (language) — detected in the code
- CSS (language) — detected in the code
- Next.js (technology) — detected in the code
- OpenAI (technology) — detected in the code
- React (technology) — detected in the code
- TypeScript (language) — detected in the code
- AI coding agent: Codex — evidence: config files committed to the repository

## Codebase structure (from repository index)

### Files (120 of 465)

```
.dockerignore
.env.example
.gitattributes
.gitignore
AGENTS.md
app/api/evidence/[name]/route.ts
app/api/evidence/archive/route.ts
app/api/health/route.ts
app/api/interpret/route.ts
app/api/policies/[policyId]/versions/[version]/ambiguities/[ambiguityId]/resolve/route.ts
app/api/policies/[policyId]/versions/[version]/repair-runs/[runId]/events/route.ts
app/api/policies/[policyId]/versions/[version]/repair-runs/route.ts
app/api/policies/[policyId]/versions/[version]/source/route.ts
app/api/policies/[policyId]/workspace/route.ts
app/cases/page.tsx
app/components/workspace-shell.tsx
app/decisions/decision-queue-client.tsx
app/decisions/page.tsx
app/error.tsx
app/globals.css
app/impact/change-impact-client.tsx
app/impact/page.tsx
app/integration/integration-run-client.tsx
app/integration/page.tsx
app/layout.tsx
app/lib/change-impact-contract.ts
app/lib/demo-data.ts
app/lib/evidence-download.ts
app/lib/policy-meaning.ts
app/lib/policy-workspace-store.ts
app/lib/repair-run-contract.ts
app/lib/repair-run-input.ts
app/lib/workspace-contract.ts
app/lib/workspace-http.ts
app/loading.tsx
app/not-found.tsx
app/overrides.css
app/page.tsx
app/policy-studio-client.tsx
app/proof/page.tsx
app/proof/proof-session-boundary.tsx
app/proof/proof.module.css
artifacts/challenge-evidence/integration.diff
artifacts/challenge-evidence/local-challenge-run.json
artifacts/challenge-evidence/summary.md
artifacts/challenge-submission/final-checklist.md
artifacts/challenge-submission/how-we-built-it.md
artifacts/challenge-submission/links.json
artifacts/challenge-submission/long-description.md
artifacts/challenge-submission/openai-and-codex-usage.md
artifacts/challenge-submission/publication-receipt.json
artifacts/challenge-submission/release-state.json
artifacts/challenge-submission/short-description.txt
artifacts/challenge-submission/tagline.txt
artifacts/challenge-submission/testing-instructions.md
artifacts/challenge-submission/title.txt
artifacts/demo-draft/captions.srt
artifacts/demo-draft/demo-data.json
artifacts/demo-draft/demo-script.md
artifacts/demo-draft/shot-list.md
artifacts/demo/captions.srt
artifacts/demo/demo-data.json
artifacts/demo/demo-script.md
artifacts/demo/narration.json
artifacts/demo/shot-list.md
artifacts/demo/video-manifest.json
artifacts/evidence/app-results-after.json
artifacts/evidence/app-results-before.json
artifacts/evidence/browser-run-details.json
artifacts/evidence/browser-run-summary.json
artifacts/evidence/codex-cartography.json
artifacts/evidence/codex-command-receipts.json
artifacts/evidence/codex-review.json
artifacts/evidence/codex-run-summary.json
artifacts/evidence/compiled-policy.rego
artifacts/evidence/compiler-manifest.json
artifacts/evidence/container-run-details.json
artifacts/evidence/container-run-summary.json
artifacts/evidence/deployment-health-response.json
artifacts/evidence/deployment-run-summary.json
artifacts/evidence/drift-report-after.json
artifacts/evidence/drift-report-before.json
artifacts/evidence/eval-scorecard.json
artifacts/evidence/evidence-manifest.json
artifacts/evidence/fixture-tree-after.json
artifacts/evidence/fixture-tree-before.json
artifacts/evidence/generated-cases.json
artifacts/evidence/golden-cases.json
artifacts/evidence/gpt-run-summary.json
artifacts/evidence/impact-report.json
artifacts/evidence/integration.diff
artifacts/evidence/mutation-opa-results.json
artifacts/evidence/mutation-report.json
artifacts/evidence/mutation-run-summary.json
artifacts/evidence/opa-results.json
artifacts/evidence/policy-ir.json
artifacts/evidence/prompt-manifest.json
artifacts/evidence/run-metadata.json
artifacts/evidence/security-report.json
artifacts/evidence/security-review.md
artifacts/evidence/summary.md
artifacts/evidence/test-command-log.json
artifacts/evidence/traceability.json
artifacts/evidence/verification-summary.json
artifacts/security/clean-checkout-report.json
artifacts/security/container-report.json
artifacts/security/container-static-report.json
artifacts/security/egress-container-report.json
artifacts/security/license-report.json
artifacts/security/native-helper-container-report.json
artifacts/security/native-helper-local-build-report.json
artifacts/security/offline-verify-report.json
artifacts/security/security-report.json
artifacts/security/worker-container-report.json
artifacts/submission-draft/accomplishments.md
artifacts/submission-draft/challenges.md
artifacts/submission-draft/claim-audit.md
artifacts/submission-draft/final-checklist.md
artifacts/submission-draft/how-we-built-it.md
artifacts/submission-draft/inspiration.md
[345 more files omitted for size]
```

### Dependencies

- package.json: @openai/codex-sdk@0.144.6, @playwright/test@1.61.1, @types/node@26.1.1, @types/react@19.2.17, @types/react-dom@19.2.3, eslint@9.39.5, eslint-config-next@16.2.10, next@16.2.10, openai@6.46.0, react@19.2.7, react-dom@19.2.7, typescript@6.0.3, vitest@4.1.10, zod@4.4.3

### Recent commits (newest first)

- docs: close Devpost confirmation capture
- chore: record confirmed submission gate
- chore: refresh submission confirmation reports
- docs: capture Devpost submission confirmation
- docs: close judge UI regression checkpoint
- chore: record verified judge UI checkpoint
- test: align browser checks with judge UI
- docs: record unverified clarity checkpoint
- feat: simplify judge-facing product story
- chore: seal final challenge verification
- docs: record public release verification
- chore: record final offline verification
- docs: finalize replacement submission media
- chore: record verified media release tree
- chore: refresh clean and security file counts
- feat: refresh challenge video and repair evidence screenshots
- docs: record public release verification
- docs: seal release verification receipt
- test: isolate release HEAD regression
- fix: verify release HEAD on removable drives

## Key source files (fetched from GitHub, selected and truncated for size)

### NOTICE.md

```markdown
# Third-party notices

PolicyTwin uses the following direct production packages under their respective licenses:

- `@openai/codex-sdk` 0.144.6 — Apache-2.0;
- `openai` 6.46.0 — Apache-2.0;
- `next` 16.2.10 — MIT;
- `react` 19.2.7 and `react-dom` 19.2.7 — MIT;
- `zod` 4.4.3 — MIT.

The resolved production graph also contains components licensed under MIT, Apache-2.0, ISC, BSD-3-Clause, 0BSD, and CC-BY-4.0. The Windows Next.js image-processing path includes the sharp platform distribution, whose package metadata declares `Apache-2.0 AND LGPL-3.0-or-later`. Final distribution must retain all notices and license texts required by the selected build artifacts.

Local policy verification uses Open Policy Agent 1.18.2 under Apache-2.0. Its executable is checksum-verified after download and is not committed to this repository.

Environment tools used during development include Node.js, pnpm, TypeScript, Git, Codex CLI, Playwright, and Docker CLI. Their licenses remain with their respective authors. Browser binaries and the final container base must be added after those release artifacts are selected.

The refund policy text and fixture data in this repository are synthetic.

```

### PACK_MANIFEST.md

```markdown
# PACK_MANIFEST.md

Generated validation summary for the PolicyTwin Codex Goal Pack.

- Goal objective characters: **3712 / 4000**
- `AGENTS.md` bytes: **16244 / 32768** default discovery budget
- Markdown fence balance: **PASS**
- Milestones M0–M10 present: **PASS**

| File | Bytes | Lines | SHA-256 |
|---|---:|---:|---|
| `.gitattributes` | 213 | 13 | `bddf5b2a99abda24a5675597d84f5c431812f067d61857c1cdde5765e59ddcd2` |
| `.gitignore` | 421 | 35 | `dee557cb28896a21b807cc673a4bba1e411f49de9ebca7dec9e9ddd848661fc3` |
| `AGENTS.md` | 16244 | 382 | `21bdfe2045d85897c0431f1c5511beaf06ecb825bb26f2482573b44e8c6abae9` |
| `DECISIONS.md` | 19876 | 276 | `ed8f674399fdea393ccad2f5fe21d6307c63665ead3add1cecab9e86570c0061` |
| `GOAL_PROMPT.md` | 6548 | 82 | `6a8ac93abf3232d2853d732577f63401fd9a9383bff4578a6cdb5713663632a3` |
| `PLAN.md` | 49274 | 1712 | `51116d4f11ccc83258ac65d773b24e9ec3c6d7c87febbad5f9f9cbbbb82cc926` |
| `PROGRESS.md` | 32648 | 369 | `afd20b0c40a3306cb11d9319d555c9be3e9a7868e6c004d4e738364f1e6a9c4d` |
| `START_HERE.md` | 5099 | 120 | `2671af37c7e07a6f07920747713210ac23e68f761e4a90e1001e31d59c983399` |
| `START_HERE_KO.md` | 3713 | 81 | `663c7ba86be6b43f638012e6ac1fb1e029deff72bb7bdafede4d28fabd41983d` |
| `SUBMISSION.md` | 18852 | 516 | `09ad25cf7e65cf31889f3afa248d2650eae7a24c994ff741810daf7ae08e80b7` |

This manifest verifies document structure only. Product, deployment, and submission gates remain for Codex to execute.

```

### Dockerfile

```
# No tag fallback is allowed. container:verify supplies the immutable image
# reference recorded in container-contract.json.
ARG NODE_BASE_IMAGE

FROM ${NODE_BASE_IMAGE} AS build

ARG NODE_BASE_IMAGE
RUN node -e "const image=process.env.NODE_BASE_IMAGE??'';if(!/^node:22\\.22\\.2-[A-Za-z0-9._-]+@sha256:[0-9a-f]{64}$/.test(image)){console.error('NODE_BASE_IMAGE must be an immutable Node 22.22.2 digest.');process.exit(64)}"

ENV NEXT_TELEMETRY_DISABLED=1
WORKDIR /app

COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
RUN corepack enable
RUN corepack prepare pnpm@11.7.0 --activate
RUN pnpm install --frozen-lockfile

COPY . .
RUN pnpm opa:install
RUN pnpm build

FROM ${NODE_BASE_IMAGE} AS runtime

ARG NODE_BASE_IMAGE
RUN node -e "const image=process.env.NODE_BASE_IMAGE??'';if(!/^node:22\\.22\\.2-[A-Za-z0-9._-]+@sha256:[0-9a-f]{64}$/.test(image)){console.error('NODE_BASE_IMAGE must be an immutable Node 22.22.2 digest.');process.exit(64)}"

ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ENV HOSTNAME=0.0.0.0
ENV PORT=3000
ENV OPA_PATH=/usr/local/bin/opa
ENV POLICYTWIN_DATABASE_PATH=/data/policytwin.sqlite

WORKDIR /app

COPY --from=build --chown=node:node /app/.next/standalone ./
COPY --from=build --chown=node:node /app/.next/static ./.next/static
COPY --from=build --chown=node:node /app/public ./public
COPY --from=build --chown=node:node /app/.tools/opa/1.18.2/opa /usr/local/bin/opa

RUN mkdir /data
RUN chown node:node /data

USER node
EXPOSE 3000

HEALTHCHECK --interval=10s --timeout=3s --start-period=20s --retries=6 CMD ["node", "-e", "fetch('http://127.0.0.1:3000/api/health').then(async(response)=>{const body=await response.json();if(!response.ok||body.status!=='ok'||body.service!=='policytwin'||body.schemaVersion!=='1')process.exit(1)}).catch(()=>process.exit(1))"]

CMD ["node", "server.js"]

```

### package.json

```
{
  "name": "policytwin",
  "version": "0.0.0",
  "private": true,
  "description": "Evidence-first AI policy engineering for SaaS refund behavior.",
  "type": "module",
  "exports": {
    ".": {
      "types": "./src/index.ts",
      "default": "./dist/index.js"
    }
  },
  "packageManager": "pnpm@11.7.0",
  "engines": {
    "node": ">=22.0.0",
    "pnpm": ">=11.7.0"
  },
  "dependencies": {
    "@openai/codex-sdk": "0.144.6",
    "next": "16.2.10",
    "openai": "6.46.0",
    "react": "19.2.7",
    "react-dom": "19.2.7",
    "zod": "4.4.3"
  },
  "devDependencies": {
    "@playwright/test": "1.61.1",
    "@types/node": "26.1.1",
    "@types/react": "19.2.17",
    "@types/react-dom": "19.2.3",
    "eslint": "9.39.5",
    "eslint-config-next": "16.2.10",
    "typescript": "6.0.3",
    "vitest": "4.1.10"
  },
  "scripts": {
    "dev": "node scripts/dev.mjs",
    "lint": "node scripts/lint.mjs",
    "typecheck": "node scripts/typecheck.mjs",
    "test": "node scripts/run-tests.mjs unit",
    "test:integration": "node scripts/run-tests.mjs integration",
    "test:e2e": "playwright test",
    "eval": "node scripts/run-tests.mjs eval",
    "build": "node scripts/build.mjs",
    "schema:check": "node scripts/policy-ir-schema.mjs --check",
    "schema:write": "node scripts/policy-ir-schema.mjs --write",
    "verify": "node scripts/verify.mjs",
    "verify:live": "node scripts/live-gate.mjs",
    "demo:reset": "node scripts/demo-reset.mjs",
    "demo:run": "node scripts/demo-run.mjs",
    "challenge:run": "node scripts/local-challenge.mjs run",
    "challenge:check": "node scripts/local-challenge.mjs check",
    "challenge:submission:check": "node scripts/challenge-submission-check.mjs --local",
    "challenge:submission:release": "node scripts/challenge-submission-check.mjs --release",
    "demo:video:capture": "playwright test --config=playwright.challenge-video.config.ts",
    "demo:video:render": "node scripts/render-challenge-video.mjs",
    "opa:install": "node scripts/opa-install.mjs",
    "evidence:offline": "node scripts/generate-offline-evidence.mjs",
    "security:check": "node scripts/security-check.mjs",
    "license:check": "node scripts/license-check.mjs",
    "clean:check": "node scripts/clean-checkout.mjs",
    "container:check": "node scripts/container-check.mjs",
    "container:verify": "node scripts/container-verify.mjs",
    "worker:verify": "node scripts/worker-container-verify.mjs",
    "egress:verify": "node scripts/egress-container-verify.mjs",
    "helper:build:local": "node scripts/native-helper-build.mjs",
    "helper:verify": "node scripts/native-helper-container-verify.mjs",
    "submission:draft": "node scripts/generate-submission-draft.mjs",
    "submission:draft:check": "node scripts/submission-draft-check.mjs",
    "submission:architecture": "node scripts/render-architecture.mjs",
    "submission:check": "node scripts/submission-check.mjs"
  }
}

```

### fixtures/refund-demo/baseline/package.json

```
{
  "name": "policytwin-refund-fixture",
  "version": "0.0.0",
  "private": true,
  "type": "module",
  "scripts": {
    "build": "tsc -p tsconfig.json",
    "pretest": "npm run build",
    "test": "node tests/refund.test.mjs"
  }
}

```

### app/page.tsx

```typescript
import { PolicyStudioClient } from "./policy-studio-client";

export const dynamic = "force-dynamic";

export default function PolicyStudioPage() {
  return <PolicyStudioClient />;
}

```

### app/layout.tsx

```typescript
import type { Metadata } from "next";
import "./globals.css";
import "./overrides.css";

export const metadata: Metadata = {
  metadataBase: new URL(process.env.NEXT_PUBLIC_SITE_URL ?? "http://localhost:3000"),
  title: { default: "PolicyTwin — Executable policy proof", template: "%s · PolicyTwin" },
  description: "Turn a refund policy sentence into traceable rules, tests, application behavior, and proof.",
  openGraph: {
    type: "website",
    title: "PolicyTwin — Executable policy proof",
    description: "Turn policy text into verified product behavior.",
    images: [{ url: "/og.png", width: 1716, height: 920, alt: "PolicyTwin evidence pipeline" }],
  },
  twitter: {
    card: "summary_large_image",
    title: "PolicyTwin — Executable policy proof",
    description: "Turn policy text into verified product behavior.",
    images: ["/og.png"],
  },
};

export default function RootLayout({ children }: Readonly<{ children: React.ReactNode }>) {
  return <html lang="en"><body>{children}</body></html>;
}

```

### src/index.ts

```typescript
export const PROJECT_NAME = "PolicyTwin" as const;

export const REQUIRED_ROOT_SCRIPTS = [
  "dev",
  "lint",
  "typecheck",
  "test",
  "test:integration",
  "test:e2e",
  "eval",
  "build",
  "verify",
  "verify:live",
  "demo:reset",
  "demo:run",
  "submission:check",
] as const;

export * from "./domain/decision.js";
export * from "./domain/refund.js";
export * from "./domain/refund-schema.js";
export * from "./domain/cases.js";
export * from "./domain/case-validation.js";
export * from "./policy-ir/types.js";
export * from "./policy-ir/zod-schema.js";
export * from "./policy-ir/clauses.js";
export * from "./policy-ir/validate.js";
export * from "./policy-ir/evaluate.js";
export * from "./policy-ir/resolve.js";
export * from "./policy-ir/state.js";
export * from "./compiler/types.js";
export * from "./compiler/rego.js";
export * from "./opa/types.js";
export * from "./opa/runner.js";
export * from "./cases/generate.js";
export * from "./cases/analyze.js";
export * from "./mutation/mutate.js";
export * from "./mutation/report.js";
export * from "./differential/types.js";
export * from "./differential/run.js";
export * from "./codex/types.js";
export * from "./codex/safety.js";
export * from "./codex/diff.js";
export * from "./codex/validate.js";
export * from "./codex/orchestrate.js";
export * from "./codex/worker-rpc-contract.js";
export * from "./codex/worker-rpc-client.js";
export * from "./codex/worker-rpc-mtls.js";
export * from "./codex/worker-rpc-replay-sqlite.js";
export * from "./codex/cpu-budget-contract.js";
export * from "./codex/live-linux-cgroup-cpu-proof.js";
export * from "./codex/live-linux-cgroup-cpu-evidence-v2.js";
export * from "./impact/types.js";
export * from "./impact/analyze.js";
export * from "./traceability/report.js";
export * from "./evidence/validate.js";
export * from "./evidence/archive.js";
export * from "./evidence/files.js";
export * from "./workspace/service.js";
export * from "./workspace/http.js";
export * from "./openai/interpreter.js";
export * from "./openai/request-guard.js";
export * from "./repair-runs/types.js";
export * from "./repair-runs/sqlite.js";
export * from "./repair-runs/coordinator.js";
export * from "./repair-runs/validated-result.js";

```

### app/decisions/page.tsx

```typescript
import { DecisionQueueClient } from "./decision-queue-client";

export const metadata = { title: "Decision Queue" };
export const dynamic = "force-dynamic";

export default function DecisionsPage() {
  return <DecisionQueueClient />;
}

```

### app/impact/page.tsx

```typescript
import { seededChangeImpactContract } from "../lib/change-impact-contract";
import { ChangeImpactClient } from "./change-impact-client";

export const metadata = { title: "Change Impact" };
export const dynamic = "force-dynamic";

export default function ChangeImpactPage() {
  const { changedSourceText, impact, referencePolicyMeaning } = seededChangeImpactContract();
  return <ChangeImpactClient
    changedSourceText={changedSourceText}
    impact={impact}
    referencePolicyMeaning={referencePolicyMeaning}
  />;
}

```

[178 more indexed source files omitted to keep this export small. The full file list is in the Codebase structure section above.]