audrey 0.21.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +238 -0
- package/LICENSE +21 -21
- package/README.md +281 -33
- package/SECURITY.md +30 -0
- package/benchmarks/adapter-kit.mjs +20 -0
- package/benchmarks/adapter-self-test.mjs +166 -0
- package/benchmarks/adapters/example-allow.mjs +28 -0
- package/benchmarks/adapters/mem0-platform.mjs +267 -0
- package/benchmarks/adapters/registry.json +51 -0
- package/benchmarks/adapters/zep-cloud.mjs +280 -0
- package/benchmarks/baselines.js +169 -0
- package/benchmarks/build-leaderboard.mjs +170 -0
- package/benchmarks/cases.js +537 -0
- package/benchmarks/create-conformance-card.mjs +139 -0
- package/benchmarks/create-submission-bundle.mjs +176 -0
- package/benchmarks/dry-run-external-adapters.mjs +165 -0
- package/benchmarks/guardbench.js +1035 -0
- package/benchmarks/output/adapter-self-test/guardbench-adapter-self-test.json +50 -0
- package/benchmarks/output/external/guardbench-external-dry-run.json +69 -0
- package/benchmarks/output/external/guardbench-external-evidence.json +56 -0
- package/benchmarks/output/guardbench-conformance-card.json +63 -0
- package/benchmarks/output/guardbench-manifest.json +414 -0
- package/benchmarks/output/guardbench-raw.json +1171 -0
- package/benchmarks/output/guardbench-summary.json +1981 -0
- package/benchmarks/output/leaderboard/guardbench-leaderboard.json +93 -0
- package/benchmarks/output/leaderboard/guardbench-leaderboard.md +7 -0
- package/benchmarks/output/submission-bundle/guardbench-conformance-card.json +63 -0
- package/benchmarks/output/submission-bundle/guardbench-manifest.json +414 -0
- package/benchmarks/output/submission-bundle/guardbench-raw.json +1171 -0
- package/benchmarks/output/submission-bundle/guardbench-summary.json +1981 -0
- package/benchmarks/output/submission-bundle/schemas/guardbench-adapter-registry.schema.json +69 -0
- package/benchmarks/output/submission-bundle/schemas/guardbench-adapter-self-test.schema.json +156 -0
- package/benchmarks/output/submission-bundle/schemas/guardbench-conformance-card.schema.json +184 -0
- package/benchmarks/output/submission-bundle/schemas/guardbench-external-dry-run.schema.json +74 -0
- package/benchmarks/output/submission-bundle/schemas/guardbench-external-evidence.schema.json +108 -0
- package/benchmarks/output/submission-bundle/schemas/guardbench-external-run.schema.json +160 -0
- package/benchmarks/output/submission-bundle/schemas/guardbench-leaderboard.schema.json +179 -0
- package/benchmarks/output/submission-bundle/schemas/guardbench-manifest.schema.json +213 -0
- package/benchmarks/output/submission-bundle/schemas/guardbench-publication-verification.schema.json +47 -0
- package/benchmarks/output/submission-bundle/schemas/guardbench-raw.schema.json +164 -0
- package/benchmarks/output/submission-bundle/schemas/guardbench-submission-manifest.schema.json +151 -0
- package/benchmarks/output/submission-bundle/schemas/guardbench-summary.schema.json +228 -0
- package/benchmarks/output/submission-bundle/submission-manifest.json +131 -0
- package/benchmarks/output/submission-bundle/validation-report.json +31 -0
- package/benchmarks/output/summary.json +2354 -0
- package/benchmarks/perf-snapshot.js +304 -0
- package/benchmarks/perf.bench.js +161 -0
- package/benchmarks/public-paths.mjs +78 -0
- package/benchmarks/reference-results.js +70 -0
- package/benchmarks/report.js +259 -0
- package/benchmarks/run-external-guardbench.mjs +281 -0
- package/benchmarks/run.js +682 -0
- package/benchmarks/schemas/guardbench-adapter-registry.schema.json +69 -0
- package/benchmarks/schemas/guardbench-adapter-self-test.schema.json +156 -0
- package/benchmarks/schemas/guardbench-conformance-card.schema.json +184 -0
- package/benchmarks/schemas/guardbench-external-dry-run.schema.json +74 -0
- package/benchmarks/schemas/guardbench-external-evidence.schema.json +108 -0
- package/benchmarks/schemas/guardbench-external-run.schema.json +160 -0
- package/benchmarks/schemas/guardbench-leaderboard.schema.json +179 -0
- package/benchmarks/schemas/guardbench-manifest.schema.json +213 -0
- package/benchmarks/schemas/guardbench-publication-verification.schema.json +47 -0
- package/benchmarks/schemas/guardbench-raw.schema.json +164 -0
- package/benchmarks/schemas/guardbench-submission-manifest.schema.json +151 -0
- package/benchmarks/schemas/guardbench-summary.schema.json +228 -0
- package/benchmarks/snapshots/perf-0.22.2.json +123 -0
- package/benchmarks/snapshots/perf-0.23.0.json +123 -0
- package/benchmarks/validate-adapter-module.mjs +104 -0
- package/benchmarks/validate-adapter-registry.mjs +134 -0
- package/benchmarks/validate-adapter-self-test.mjs +96 -0
- package/benchmarks/validate-guardbench-artifacts.mjs +343 -0
- package/benchmarks/verify-external-evidence.mjs +296 -0
- package/benchmarks/verify-publication-artifacts.mjs +286 -0
- package/benchmarks/verify-submission-bundle.mjs +167 -0
- package/dist/mcp-server/config.d.ts +5 -4
- package/dist/mcp-server/config.d.ts.map +1 -1
- package/dist/mcp-server/config.js +6 -8
- package/dist/mcp-server/config.js.map +1 -1
- package/dist/mcp-server/index.d.ts +281 -23
- package/dist/mcp-server/index.d.ts.map +1 -1
- package/dist/mcp-server/index.js +1186 -82
- package/dist/mcp-server/index.js.map +1 -1
- package/dist/src/action-key.d.ts +9 -0
- package/dist/src/action-key.d.ts.map +1 -0
- package/dist/src/action-key.js +49 -0
- package/dist/src/action-key.js.map +1 -0
- package/dist/src/adaptive.d.ts.map +1 -1
- package/dist/src/adaptive.js +8 -6
- package/dist/src/adaptive.js.map +1 -1
- package/dist/src/affect.d.ts +4 -1
- package/dist/src/affect.d.ts.map +1 -1
- package/dist/src/affect.js +14 -12
- package/dist/src/affect.js.map +1 -1
- package/dist/src/audrey.d.ts +57 -4
- package/dist/src/audrey.d.ts.map +1 -1
- package/dist/src/audrey.js +512 -65
- package/dist/src/audrey.js.map +1 -1
- package/dist/src/capsule.d.ts +2 -1
- package/dist/src/capsule.d.ts.map +1 -1
- package/dist/src/capsule.js +18 -8
- package/dist/src/capsule.js.map +1 -1
- package/dist/src/causal.d.ts.map +1 -1
- package/dist/src/causal.js +23 -5
- package/dist/src/causal.js.map +1 -1
- package/dist/src/confidence.d.ts.map +1 -1
- package/dist/src/confidence.js +3 -0
- package/dist/src/confidence.js.map +1 -1
- package/dist/src/consolidate.d.ts +1 -0
- package/dist/src/consolidate.d.ts.map +1 -1
- package/dist/src/consolidate.js +70 -54
- package/dist/src/consolidate.js.map +1 -1
- package/dist/src/controller.d.ts +94 -0
- package/dist/src/controller.d.ts.map +1 -0
- package/dist/src/controller.js +350 -0
- package/dist/src/controller.js.map +1 -0
- package/dist/src/db.d.ts.map +1 -1
- package/dist/src/db.js +181 -169
- package/dist/src/db.js.map +1 -1
- package/dist/src/decay.d.ts.map +1 -1
- package/dist/src/decay.js +62 -55
- package/dist/src/decay.js.map +1 -1
- package/dist/src/embedding.d.ts +2 -1
- package/dist/src/embedding.d.ts.map +1 -1
- package/dist/src/embedding.js +60 -22
- package/dist/src/embedding.js.map +1 -1
- package/dist/src/encode.d.ts +9 -2
- package/dist/src/encode.d.ts.map +1 -1
- package/dist/src/encode.js +25 -12
- package/dist/src/encode.js.map +1 -1
- package/dist/src/export.d.ts.map +1 -1
- package/dist/src/export.js +5 -3
- package/dist/src/export.js.map +1 -1
- package/dist/src/feedback.d.ts +35 -0
- package/dist/src/feedback.d.ts.map +1 -0
- package/dist/src/feedback.js +129 -0
- package/dist/src/feedback.js.map +1 -0
- package/dist/src/forget.d.ts.map +1 -1
- package/dist/src/forget.js +68 -60
- package/dist/src/forget.js.map +1 -1
- package/dist/src/fts.js +1 -1
- package/dist/src/fts.js.map +1 -1
- package/dist/src/hybrid-recall.d.ts +2 -1
- package/dist/src/hybrid-recall.d.ts.map +1 -1
- package/dist/src/hybrid-recall.js +41 -32
- package/dist/src/hybrid-recall.js.map +1 -1
- package/dist/src/impact.d.ts +47 -0
- package/dist/src/impact.d.ts.map +1 -0
- package/dist/src/impact.js +146 -0
- package/dist/src/impact.js.map +1 -0
- package/dist/src/import.d.ts +177 -1
- package/dist/src/import.d.ts.map +1 -1
- package/dist/src/import.js +235 -46
- package/dist/src/import.js.map +1 -1
- package/dist/src/index.d.ts +5 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/interference.d.ts +5 -2
- package/dist/src/interference.d.ts.map +1 -1
- package/dist/src/interference.js +39 -32
- package/dist/src/interference.js.map +1 -1
- package/dist/src/introspect.js +18 -18
- package/dist/src/llm.d.ts.map +1 -1
- package/dist/src/llm.js +1 -0
- package/dist/src/llm.js.map +1 -1
- package/dist/src/migrate.d.ts.map +1 -1
- package/dist/src/migrate.js +21 -9
- package/dist/src/migrate.js.map +1 -1
- package/dist/src/preflight.d.ts +2 -1
- package/dist/src/preflight.d.ts.map +1 -1
- package/dist/src/preflight.js +66 -5
- package/dist/src/preflight.js.map +1 -1
- package/dist/src/profile.d.ts +23 -0
- package/dist/src/profile.d.ts.map +1 -0
- package/dist/src/profile.js +51 -0
- package/dist/src/profile.js.map +1 -0
- package/dist/src/promote.d.ts.map +1 -1
- package/dist/src/promote.js +8 -9
- package/dist/src/promote.js.map +1 -1
- package/dist/src/prompts.d.ts.map +1 -1
- package/dist/src/prompts.js +165 -136
- package/dist/src/prompts.js.map +1 -1
- package/dist/src/recall.d.ts +9 -6
- package/dist/src/recall.d.ts.map +1 -1
- package/dist/src/recall.js +204 -62
- package/dist/src/recall.js.map +1 -1
- package/dist/src/redact.d.ts +7 -1
- package/dist/src/redact.d.ts.map +1 -1
- package/dist/src/redact.js +94 -11
- package/dist/src/redact.js.map +1 -1
- package/dist/src/reflexes.d.ts +1 -0
- package/dist/src/reflexes.d.ts.map +1 -1
- package/dist/src/reflexes.js +3 -0
- package/dist/src/reflexes.js.map +1 -1
- package/dist/src/rollback.d.ts.map +1 -1
- package/dist/src/rollback.js +13 -8
- package/dist/src/rollback.js.map +1 -1
- package/dist/src/routes.d.ts +1 -0
- package/dist/src/routes.d.ts.map +1 -1
- package/dist/src/routes.js +251 -6
- package/dist/src/routes.js.map +1 -1
- package/dist/src/rules-compiler.d.ts.map +1 -1
- package/dist/src/rules-compiler.js +36 -6
- package/dist/src/rules-compiler.js.map +1 -1
- package/dist/src/server.d.ts +2 -1
- package/dist/src/server.d.ts.map +1 -1
- package/dist/src/server.js +42 -4
- package/dist/src/server.js.map +1 -1
- package/dist/src/tool-trace.d.ts.map +1 -1
- package/dist/src/tool-trace.js +42 -29
- package/dist/src/tool-trace.js.map +1 -1
- package/dist/src/types.d.ts +28 -1
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/ulid.d.ts.map +1 -1
- package/dist/src/ulid.js +52 -2
- package/dist/src/ulid.js.map +1 -1
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +8 -1
- package/dist/src/utils.js.map +1 -1
- package/dist/src/validate.d.ts +2 -0
- package/dist/src/validate.d.ts.map +1 -1
- package/dist/src/validate.js +77 -46
- package/dist/src/validate.js.map +1 -1
- package/docs/AUDREY_PAPER_OUTLINE.md +175 -0
- package/docs/MEMORY_BENCHMARKING.md +59 -0
- package/docs/PRODUCTION_BACKLOG.md +304 -0
- package/docs/paper/00-master.md +48 -0
- package/docs/paper/01-introduction.md +27 -0
- package/docs/paper/02-related-work.md +47 -0
- package/docs/paper/03-problem-definition.md +108 -0
- package/docs/paper/04-design.md +164 -0
- package/docs/paper/05-guardbench-spec.md +412 -0
- package/docs/paper/06-implementation.md +113 -0
- package/docs/paper/07-evaluation.md +168 -0
- package/docs/paper/08-discussion-limitations.md +61 -0
- package/docs/paper/09-conclusion.md +11 -0
- package/docs/paper/SUBMISSION_README.md +162 -0
- package/docs/paper/appendix-a-demo-transcript.md +114 -0
- package/docs/paper/arxiv-compile-report.schema.json +116 -0
- package/docs/paper/arxiv-source.schema.json +61 -0
- package/docs/paper/audrey-paper-v1.md +1106 -0
- package/docs/paper/browser-launch-plan.json +209 -0
- package/docs/paper/browser-launch-plan.schema.json +100 -0
- package/docs/paper/browser-launch-results.json +86 -0
- package/docs/paper/browser-launch-results.schema.json +66 -0
- package/docs/paper/claim-register.json +138 -0
- package/docs/paper/claim-register.schema.json +81 -0
- package/docs/paper/evidence-ledger.md +103 -0
- package/docs/paper/output/arxiv/README-arxiv.txt +8 -0
- package/docs/paper/output/arxiv/arxiv-manifest.json +41 -0
- package/docs/paper/output/arxiv/main.tex +949 -0
- package/docs/paper/output/arxiv/references.bib +222 -0
- package/docs/paper/output/arxiv-compile-report.json +24 -0
- package/docs/paper/output/submission-bundle/LICENSE +21 -0
- package/docs/paper/output/submission-bundle/README.md +533 -0
- package/docs/paper/output/submission-bundle/benchmarks/output/adapter-self-test/guardbench-adapter-self-test.json +50 -0
- package/docs/paper/output/submission-bundle/benchmarks/output/external/guardbench-external-dry-run.json +69 -0
- package/docs/paper/output/submission-bundle/benchmarks/output/external/guardbench-external-evidence.json +56 -0
- package/docs/paper/output/submission-bundle/benchmarks/output/guardbench-conformance-card.json +63 -0
- package/docs/paper/output/submission-bundle/benchmarks/output/guardbench-manifest.json +414 -0
- package/docs/paper/output/submission-bundle/benchmarks/output/guardbench-raw.json +1171 -0
- package/docs/paper/output/submission-bundle/benchmarks/output/guardbench-summary.json +1981 -0
- package/docs/paper/output/submission-bundle/benchmarks/output/leaderboard/guardbench-leaderboard.json +93 -0
- package/docs/paper/output/submission-bundle/benchmarks/output/leaderboard/guardbench-leaderboard.md +7 -0
- package/docs/paper/output/submission-bundle/benchmarks/output/submission-bundle/submission-manifest.json +131 -0
- package/docs/paper/output/submission-bundle/benchmarks/output/submission-bundle/validation-report.json +31 -0
- package/docs/paper/output/submission-bundle/benchmarks/output/summary.json +2354 -0
- package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-adapter-registry.schema.json +69 -0
- package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-adapter-self-test.schema.json +156 -0
- package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-conformance-card.schema.json +184 -0
- package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-external-dry-run.schema.json +74 -0
- package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-external-evidence.schema.json +108 -0
- package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-external-run.schema.json +160 -0
- package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-leaderboard.schema.json +179 -0
- package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-manifest.schema.json +213 -0
- package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-publication-verification.schema.json +47 -0
- package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-raw.schema.json +164 -0
- package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-submission-manifest.schema.json +151 -0
- package/docs/paper/output/submission-bundle/benchmarks/schemas/guardbench-summary.schema.json +228 -0
- package/docs/paper/output/submission-bundle/docs/AUDREY_PAPER_OUTLINE.md +175 -0
- package/docs/paper/output/submission-bundle/docs/paper/00-master.md +48 -0
- package/docs/paper/output/submission-bundle/docs/paper/01-introduction.md +27 -0
- package/docs/paper/output/submission-bundle/docs/paper/02-related-work.md +47 -0
- package/docs/paper/output/submission-bundle/docs/paper/03-problem-definition.md +108 -0
- package/docs/paper/output/submission-bundle/docs/paper/04-design.md +164 -0
- package/docs/paper/output/submission-bundle/docs/paper/05-guardbench-spec.md +412 -0
- package/docs/paper/output/submission-bundle/docs/paper/06-implementation.md +113 -0
- package/docs/paper/output/submission-bundle/docs/paper/07-evaluation.md +168 -0
- package/docs/paper/output/submission-bundle/docs/paper/08-discussion-limitations.md +61 -0
- package/docs/paper/output/submission-bundle/docs/paper/09-conclusion.md +11 -0
- package/docs/paper/output/submission-bundle/docs/paper/SUBMISSION_README.md +162 -0
- package/docs/paper/output/submission-bundle/docs/paper/appendix-a-demo-transcript.md +114 -0
- package/docs/paper/output/submission-bundle/docs/paper/arxiv-compile-report.schema.json +116 -0
- package/docs/paper/output/submission-bundle/docs/paper/arxiv-source.schema.json +61 -0
- package/docs/paper/output/submission-bundle/docs/paper/audrey-paper-v1.md +1106 -0
- package/docs/paper/output/submission-bundle/docs/paper/browser-launch-plan.json +209 -0
- package/docs/paper/output/submission-bundle/docs/paper/browser-launch-plan.schema.json +100 -0
- package/docs/paper/output/submission-bundle/docs/paper/browser-launch-results.json +86 -0
- package/docs/paper/output/submission-bundle/docs/paper/browser-launch-results.schema.json +66 -0
- package/docs/paper/output/submission-bundle/docs/paper/claim-register.json +138 -0
- package/docs/paper/output/submission-bundle/docs/paper/claim-register.schema.json +81 -0
- package/docs/paper/output/submission-bundle/docs/paper/evidence-ledger.md +103 -0
- package/docs/paper/output/submission-bundle/docs/paper/output/arxiv/README-arxiv.txt +8 -0
- package/docs/paper/output/submission-bundle/docs/paper/output/arxiv/arxiv-manifest.json +41 -0
- package/docs/paper/output/submission-bundle/docs/paper/output/arxiv/main.tex +949 -0
- package/docs/paper/output/submission-bundle/docs/paper/output/arxiv/references.bib +222 -0
- package/docs/paper/output/submission-bundle/docs/paper/output/arxiv-compile-report.json +24 -0
- package/docs/paper/output/submission-bundle/docs/paper/paper-submission-bundle.schema.json +70 -0
- package/docs/paper/output/submission-bundle/docs/paper/publication-pack.json +81 -0
- package/docs/paper/output/submission-bundle/docs/paper/publication-pack.schema.json +60 -0
- package/docs/paper/output/submission-bundle/docs/paper/references.bib +222 -0
- package/docs/paper/output/submission-bundle/package.json +212 -0
- package/docs/paper/output/submission-bundle/paper-submission-manifest.json +379 -0
- package/docs/paper/paper-submission-bundle.schema.json +70 -0
- package/docs/paper/publication-pack.json +81 -0
- package/docs/paper/publication-pack.schema.json +60 -0
- package/docs/paper/references.bib +222 -0
- package/package.json +103 -26
- package/scripts/audit-release-completion.mjs +362 -0
- package/scripts/create-arxiv-source.mjs +362 -0
- package/scripts/create-paper-submission-bundle.mjs +210 -0
- package/scripts/finalize-release.mjs +526 -0
- package/scripts/prepare-release-cut.mjs +269 -0
- package/scripts/publish-release-bundle.mjs +209 -0
- package/scripts/publish-release-github-api.mjs +429 -0
- package/scripts/run-vitest.mjs +34 -0
- package/scripts/smoke-cli.js +72 -0
- package/scripts/sync-paper-artifacts.mjs +109 -0
- package/scripts/verify-arxiv-compile.mjs +440 -0
- package/scripts/verify-arxiv-source.mjs +194 -0
- package/scripts/verify-browser-launch-plan.mjs +237 -0
- package/scripts/verify-browser-launch-results.mjs +285 -0
- package/scripts/verify-paper-artifacts.mjs +338 -0
- package/scripts/verify-paper-claims.mjs +226 -0
- package/scripts/verify-paper-submission-bundle.mjs +207 -0
- package/scripts/verify-publication-pack.mjs +196 -0
- package/scripts/verify-python-package.py +201 -0
- package/scripts/verify-release-readiness.mjs +741 -0
- package/docs/assets/benchmarks/local-benchmark.svg +0 -45
- package/docs/assets/benchmarks/operations-benchmark.svg +0 -45
- package/docs/assets/benchmarks/published-memory-standards.svg +0 -50
- package/docs/audrey-for-dummies.md +0 -670
- package/docs/benchmarking.md +0 -151
- package/docs/future-of-llm-memory.md +0 -452
- package/docs/mcp-hosts.md +0 -206
- package/docs/ollama-local-agents.md +0 -128
- package/docs/production-readiness.md +0 -128
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { cpSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { dirname, join, relative, resolve } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
|
|
6
|
+
const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
7
|
+
const DEFAULT_OUT_DIR = 'docs/paper/output/arxiv';
|
|
8
|
+
const SOURCE_MARKDOWN = 'docs/paper/audrey-paper-v1.md';
|
|
9
|
+
const SOURCE_BIB = 'docs/paper/references.bib';
|
|
10
|
+
const PUBLICATION_PACK = 'docs/paper/publication-pack.json';
|
|
11
|
+
const MANIFEST_FILE = 'arxiv-manifest.json';
|
|
12
|
+
const SEEDED_SECRET = 'sk-guardbench-secret-0000000000000000000000000000';
|
|
13
|
+
|
|
14
|
+
function fromRoot(path) {
|
|
15
|
+
return resolve(ROOT, path);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function readText(path) {
|
|
19
|
+
return readFileSync(fromRoot(path), 'utf-8');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function readJson(path) {
|
|
23
|
+
return JSON.parse(readText(path));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function sha256File(path) {
|
|
27
|
+
return createHash('sha256').update(readFileSync(path)).digest('hex');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function countBibEntries(text) {
|
|
31
|
+
return [...text.matchAll(/@\w+\s*\{/g)].length;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function sanitizePublicText(text) {
|
|
35
|
+
return text
|
|
36
|
+
.replaceAll(SEEDED_SECRET, '[REDACTED:guardbench_seeded_secret]')
|
|
37
|
+
.replace(/\b[A-Z]:\\[^\s`|)\]]+/g, '[LOCAL-PATH]');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function latexEscape(text) {
|
|
41
|
+
return text
|
|
42
|
+
.replaceAll('\\', '\\textbackslash{}')
|
|
43
|
+
.replaceAll('&', '\\&')
|
|
44
|
+
.replaceAll('%', '\\%')
|
|
45
|
+
.replaceAll('$', '\\$')
|
|
46
|
+
.replaceAll('#', '\\#')
|
|
47
|
+
.replaceAll('_', '\\_')
|
|
48
|
+
.replaceAll('{', '\\{')
|
|
49
|
+
.replaceAll('}', '\\}')
|
|
50
|
+
.replaceAll('~', '\\textasciitilde{}')
|
|
51
|
+
.replaceAll('^', '\\textasciicircum{}');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function protectInline(text) {
|
|
55
|
+
const tokens = [];
|
|
56
|
+
const protect = value => {
|
|
57
|
+
const token = `@@AUDREY_LATEX_TOKEN_${tokens.length}@@`;
|
|
58
|
+
tokens.push([token, value]);
|
|
59
|
+
return token;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
let next = text.replace(/\[([^\]]+)\]\((https?:\/\/[^)]+)\)/g, (_, label, url) =>
|
|
63
|
+
protect(`\\href{${latexEscape(url)}}{${latexEscape(label)}}`));
|
|
64
|
+
next = next.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_, label, url) =>
|
|
65
|
+
protect(`\\texttt{${latexEscape(label)}} (${latexEscape(url)})`));
|
|
66
|
+
next = next.replace(/\[@([^\]]+)\]/g, (_, rawIds) => {
|
|
67
|
+
const ids = rawIds
|
|
68
|
+
.split(/;\s*@?|\s*,\s*@?/)
|
|
69
|
+
.map(id => id.replace(/^@/, '').trim())
|
|
70
|
+
.filter(Boolean);
|
|
71
|
+
return protect(`\\cite{${ids.join(',')}}`);
|
|
72
|
+
});
|
|
73
|
+
next = next.replace(/`([^`]+)`/g, (_, value) => protect(`\\texttt{${latexEscape(value)}}`));
|
|
74
|
+
next = latexEscape(next);
|
|
75
|
+
for (const [token, value] of tokens) next = next.replaceAll(latexEscape(token), value);
|
|
76
|
+
return next;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function latexCommandForHeading(level) {
|
|
80
|
+
if (level <= 2) return 'section';
|
|
81
|
+
if (level === 3) return 'subsection';
|
|
82
|
+
return 'subsubsection';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function isTableLine(line) {
|
|
86
|
+
return /^\s*\|.*\|\s*$/.test(line);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function isTableSeparator(line) {
|
|
90
|
+
return /^\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)+\|?\s*$/.test(line);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function flushParagraph(lines, output) {
|
|
94
|
+
if (!lines.length) return;
|
|
95
|
+
output.push(`${protectInline(lines.join(' ').replace(/\s+/g, ' ').trim())}\n`);
|
|
96
|
+
lines.length = 0;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function flushList(items, output, environment) {
|
|
100
|
+
if (!items.length) return;
|
|
101
|
+
output.push(`\\begin{${environment}}`);
|
|
102
|
+
for (const item of items) output.push(`\\item ${protectInline(item)}`);
|
|
103
|
+
output.push(`\\end{${environment}}\n`);
|
|
104
|
+
items.length = 0;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function markdownToLatex(markdown) {
|
|
108
|
+
const lines = markdown.replace(/\r\n/g, '\n').split('\n');
|
|
109
|
+
const output = [];
|
|
110
|
+
const paragraph = [];
|
|
111
|
+
const bullets = [];
|
|
112
|
+
const numbers = [];
|
|
113
|
+
let inCode = false;
|
|
114
|
+
let code = [];
|
|
115
|
+
let codeBlocks = 0;
|
|
116
|
+
let tableBlocks = 0;
|
|
117
|
+
let skippedTitle = false;
|
|
118
|
+
|
|
119
|
+
function flushInlineBlocks() {
|
|
120
|
+
flushParagraph(paragraph, output);
|
|
121
|
+
flushList(bullets, output, 'itemize');
|
|
122
|
+
flushList(numbers, output, 'enumerate');
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
for (let i = 0; i < lines.length; i++) {
|
|
126
|
+
const line = lines[i];
|
|
127
|
+
if (/^```/.test(line)) {
|
|
128
|
+
if (inCode) {
|
|
129
|
+
output.push('\\begin{verbatim}');
|
|
130
|
+
output.push(...code);
|
|
131
|
+
output.push('\\end{verbatim}\n');
|
|
132
|
+
code = [];
|
|
133
|
+
inCode = false;
|
|
134
|
+
codeBlocks += 1;
|
|
135
|
+
} else {
|
|
136
|
+
flushInlineBlocks();
|
|
137
|
+
inCode = true;
|
|
138
|
+
}
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (inCode) {
|
|
142
|
+
code.push(line);
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (isTableLine(line)) {
|
|
146
|
+
flushInlineBlocks();
|
|
147
|
+
const table = [];
|
|
148
|
+
while (i < lines.length && isTableLine(lines[i])) {
|
|
149
|
+
if (!isTableSeparator(lines[i])) table.push(lines[i]);
|
|
150
|
+
i += 1;
|
|
151
|
+
}
|
|
152
|
+
i -= 1;
|
|
153
|
+
output.push('\\begin{verbatim}');
|
|
154
|
+
output.push(...table);
|
|
155
|
+
output.push('\\end{verbatim}\n');
|
|
156
|
+
tableBlocks += 1;
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
const heading = /^(#{1,6})\s+(.+)$/.exec(line);
|
|
160
|
+
if (heading) {
|
|
161
|
+
flushInlineBlocks();
|
|
162
|
+
if (!skippedTitle && heading[1].length === 1) {
|
|
163
|
+
skippedTitle = true;
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
const command = latexCommandForHeading(heading[1].length);
|
|
167
|
+
output.push(`\\${command}{${protectInline(heading[2])}}\n`);
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
const bullet = /^\s*[-*]\s+(.+)$/.exec(line);
|
|
171
|
+
if (bullet) {
|
|
172
|
+
flushParagraph(paragraph, output);
|
|
173
|
+
flushList(numbers, output, 'enumerate');
|
|
174
|
+
bullets.push(bullet[1]);
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
const numbered = /^\s*\d+\.\s+(.+)$/.exec(line);
|
|
178
|
+
if (numbered) {
|
|
179
|
+
flushParagraph(paragraph, output);
|
|
180
|
+
flushList(bullets, output, 'itemize');
|
|
181
|
+
numbers.push(numbered[1]);
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
if (!line.trim()) {
|
|
185
|
+
flushInlineBlocks();
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
paragraph.push(line.trim());
|
|
189
|
+
}
|
|
190
|
+
flushInlineBlocks();
|
|
191
|
+
|
|
192
|
+
return {
|
|
193
|
+
body: output.join('\n'),
|
|
194
|
+
codeBlocks,
|
|
195
|
+
tableBlocks,
|
|
196
|
+
citationCount: [...output.join('\n').matchAll(/\\cite\{/g)].length,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function publicationEntry(pack, id) {
|
|
201
|
+
const entry = pack.entries.find(row => row.id === id);
|
|
202
|
+
if (!entry) throw new Error(`Missing publication-pack entry: ${id}`);
|
|
203
|
+
return entry.text;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function buildLatex() {
|
|
207
|
+
const pack = readJson(PUBLICATION_PACK);
|
|
208
|
+
const markdown = sanitizePublicText(readText(SOURCE_MARKDOWN));
|
|
209
|
+
const converted = markdownToLatex(markdown);
|
|
210
|
+
const title = publicationEntry(pack, 'arxiv-title');
|
|
211
|
+
const abstract = sanitizePublicText(publicationEntry(pack, 'arxiv-abstract'));
|
|
212
|
+
|
|
213
|
+
const tex = `\\documentclass[11pt]{article}
|
|
214
|
+
\\usepackage[margin=1in]{geometry}
|
|
215
|
+
\\usepackage[T1]{fontenc}
|
|
216
|
+
\\usepackage[utf8]{inputenc}
|
|
217
|
+
\\usepackage{hyperref}
|
|
218
|
+
\\usepackage{url}
|
|
219
|
+
\\usepackage{verbatim}
|
|
220
|
+
|
|
221
|
+
\\title{${protectInline(title)}}
|
|
222
|
+
\\author{Tyler Eveland}
|
|
223
|
+
\\date{\\today}
|
|
224
|
+
|
|
225
|
+
\\begin{document}
|
|
226
|
+
\\maketitle
|
|
227
|
+
|
|
228
|
+
\\begin{abstract}
|
|
229
|
+
${protectInline(abstract)}
|
|
230
|
+
\\end{abstract}
|
|
231
|
+
|
|
232
|
+
${converted.body}
|
|
233
|
+
|
|
234
|
+
\\bibliographystyle{plain}
|
|
235
|
+
\\bibliography{references}
|
|
236
|
+
|
|
237
|
+
\\end{document}
|
|
238
|
+
`;
|
|
239
|
+
|
|
240
|
+
return {
|
|
241
|
+
tex,
|
|
242
|
+
citationCount: converted.citationCount,
|
|
243
|
+
codeBlocks: converted.codeBlocks,
|
|
244
|
+
tableBlocks: converted.tableBlocks,
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function fileRecord(outDir, path, source) {
|
|
249
|
+
const absolute = join(outDir, path);
|
|
250
|
+
return {
|
|
251
|
+
path,
|
|
252
|
+
source,
|
|
253
|
+
bytes: readFileSync(absolute).byteLength,
|
|
254
|
+
sha256: sha256File(absolute),
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function parseArgs(argv = process.argv.slice(2)) {
|
|
259
|
+
const args = {
|
|
260
|
+
outDir: DEFAULT_OUT_DIR,
|
|
261
|
+
json: false,
|
|
262
|
+
};
|
|
263
|
+
for (let i = 0; i < argv.length; i++) {
|
|
264
|
+
const token = argv[i];
|
|
265
|
+
if (token === '--out-dir' && argv[i + 1]) args.outDir = argv[++i];
|
|
266
|
+
else if (token === '--json') args.json = true;
|
|
267
|
+
else if (token === '--help' || token === '-h') args.help = true;
|
|
268
|
+
else throw new Error(`Unknown argument: ${token}`);
|
|
269
|
+
}
|
|
270
|
+
return args;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function usage() {
|
|
274
|
+
return `Usage: node scripts/create-arxiv-source.mjs [options]
|
|
275
|
+
|
|
276
|
+
Options:
|
|
277
|
+
--out-dir <path> Output directory. Default: ${DEFAULT_OUT_DIR}.
|
|
278
|
+
--json Print the machine-readable manifest.
|
|
279
|
+
`;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export function writeArxivSourcePackage(options = {}) {
|
|
283
|
+
const outDir = resolve(ROOT, options.outDir ?? DEFAULT_OUT_DIR);
|
|
284
|
+
const bib = readText(SOURCE_BIB);
|
|
285
|
+
const built = buildLatex();
|
|
286
|
+
rmSync(outDir, { recursive: true, force: true });
|
|
287
|
+
mkdirSync(outDir, { recursive: true });
|
|
288
|
+
|
|
289
|
+
writeFileSync(join(outDir, 'main.tex'), built.tex, 'utf-8');
|
|
290
|
+
cpSync(fromRoot(SOURCE_BIB), join(outDir, 'references.bib'));
|
|
291
|
+
writeFileSync(join(outDir, 'README-arxiv.txt'), [
|
|
292
|
+
'Audrey arXiv source package',
|
|
293
|
+
'',
|
|
294
|
+
'Main file: main.tex',
|
|
295
|
+
'Bibliography: references.bib',
|
|
296
|
+
'',
|
|
297
|
+
'Generated from docs/paper/audrey-paper-v1.md and docs/paper/publication-pack.json.',
|
|
298
|
+
'This host did not require a local TeX compiler to generate the source package.',
|
|
299
|
+
'Before final arXiv upload, compile with a TeX toolchain and preview the PDF in arXiv.',
|
|
300
|
+
'',
|
|
301
|
+
].join('\n'), 'utf-8');
|
|
302
|
+
|
|
303
|
+
const files = [
|
|
304
|
+
fileRecord(outDir, 'main.tex', SOURCE_MARKDOWN),
|
|
305
|
+
fileRecord(outDir, 'references.bib', SOURCE_BIB),
|
|
306
|
+
fileRecord(outDir, 'README-arxiv.txt', 'generated'),
|
|
307
|
+
];
|
|
308
|
+
const manifest = {
|
|
309
|
+
schemaVersion: '1.0.0',
|
|
310
|
+
suite: 'Audrey arXiv source package',
|
|
311
|
+
generatedAt: new Date().toISOString(),
|
|
312
|
+
sourceMarkdown: SOURCE_MARKDOWN,
|
|
313
|
+
publicationPack: PUBLICATION_PACK,
|
|
314
|
+
sourceHashes: {
|
|
315
|
+
sourceMarkdown: sha256File(fromRoot(SOURCE_MARKDOWN)),
|
|
316
|
+
publicationPack: sha256File(fromRoot(PUBLICATION_PACK)),
|
|
317
|
+
referencesBib: sha256File(fromRoot(SOURCE_BIB)),
|
|
318
|
+
},
|
|
319
|
+
files,
|
|
320
|
+
tex: {
|
|
321
|
+
mainFile: 'main.tex',
|
|
322
|
+
titleEntry: 'arxiv-title',
|
|
323
|
+
abstractEntry: 'arxiv-abstract',
|
|
324
|
+
citationCount: built.citationCount,
|
|
325
|
+
bibEntryCount: countBibEntries(bib),
|
|
326
|
+
codeBlocks: built.codeBlocks,
|
|
327
|
+
tableBlocks: built.tableBlocks,
|
|
328
|
+
},
|
|
329
|
+
};
|
|
330
|
+
writeFileSync(join(outDir, MANIFEST_FILE), `${JSON.stringify(manifest, null, 2)}\n`, 'utf-8');
|
|
331
|
+
|
|
332
|
+
return {
|
|
333
|
+
outDir,
|
|
334
|
+
manifestPath: join(outDir, MANIFEST_FILE),
|
|
335
|
+
manifest,
|
|
336
|
+
files: files.map(file => file.path),
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function main() {
|
|
341
|
+
const args = parseArgs();
|
|
342
|
+
if (args.help) {
|
|
343
|
+
console.log(usage());
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
const result = writeArxivSourcePackage(args);
|
|
347
|
+
if (args.json) console.log(JSON.stringify(result.manifest, null, 2));
|
|
348
|
+
else {
|
|
349
|
+
console.log(`arXiv source package: ${result.outDir}`);
|
|
350
|
+
console.log(`Files: ${result.files.length}`);
|
|
351
|
+
console.log(`Manifest: ${result.manifestPath}`);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
356
|
+
try {
|
|
357
|
+
main();
|
|
358
|
+
} catch (error) {
|
|
359
|
+
console.error(error.stack ?? error.message);
|
|
360
|
+
process.exit(1);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { cpSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { dirname, isAbsolute, join, relative, resolve } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { verifyPaperClaims } from './verify-paper-claims.mjs';
|
|
6
|
+
import { verifyPublicationPack } from './verify-publication-pack.mjs';
|
|
7
|
+
|
|
8
|
+
const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
9
|
+
const DEFAULT_OUT_DIR = 'docs/paper/output/submission-bundle';
|
|
10
|
+
const PAPER_FILES = [
|
|
11
|
+
'README.md',
|
|
12
|
+
'LICENSE',
|
|
13
|
+
'package.json',
|
|
14
|
+
'docs/AUDREY_PAPER_OUTLINE.md',
|
|
15
|
+
'docs/paper/00-master.md',
|
|
16
|
+
'docs/paper/01-introduction.md',
|
|
17
|
+
'docs/paper/02-related-work.md',
|
|
18
|
+
'docs/paper/03-problem-definition.md',
|
|
19
|
+
'docs/paper/04-design.md',
|
|
20
|
+
'docs/paper/05-guardbench-spec.md',
|
|
21
|
+
'docs/paper/06-implementation.md',
|
|
22
|
+
'docs/paper/07-evaluation.md',
|
|
23
|
+
'docs/paper/08-discussion-limitations.md',
|
|
24
|
+
'docs/paper/09-conclusion.md',
|
|
25
|
+
'docs/paper/appendix-a-demo-transcript.md',
|
|
26
|
+
'docs/paper/arxiv-compile-report.schema.json',
|
|
27
|
+
'docs/paper/arxiv-source.schema.json',
|
|
28
|
+
'docs/paper/audrey-paper-v1.md',
|
|
29
|
+
'docs/paper/browser-launch-plan.json',
|
|
30
|
+
'docs/paper/browser-launch-plan.schema.json',
|
|
31
|
+
'docs/paper/browser-launch-results.json',
|
|
32
|
+
'docs/paper/browser-launch-results.schema.json',
|
|
33
|
+
'docs/paper/claim-register.json',
|
|
34
|
+
'docs/paper/claim-register.schema.json',
|
|
35
|
+
'docs/paper/evidence-ledger.md',
|
|
36
|
+
'docs/paper/paper-submission-bundle.schema.json',
|
|
37
|
+
'docs/paper/publication-pack.json',
|
|
38
|
+
'docs/paper/publication-pack.schema.json',
|
|
39
|
+
'docs/paper/references.bib',
|
|
40
|
+
'docs/paper/SUBMISSION_README.md',
|
|
41
|
+
'docs/paper/output/arxiv/main.tex',
|
|
42
|
+
'docs/paper/output/arxiv/references.bib',
|
|
43
|
+
'docs/paper/output/arxiv/README-arxiv.txt',
|
|
44
|
+
'docs/paper/output/arxiv/arxiv-manifest.json',
|
|
45
|
+
'docs/paper/output/arxiv-compile-report.json',
|
|
46
|
+
];
|
|
47
|
+
const OPTIONAL_PAPER_FILES = [
|
|
48
|
+
'docs/paper/output/arxiv-compile/main.pdf',
|
|
49
|
+
'docs/paper/output/arxiv-compile/arxiv-compile.log',
|
|
50
|
+
];
|
|
51
|
+
const BENCHMARK_FILES = [
|
|
52
|
+
'benchmarks/output/summary.json',
|
|
53
|
+
'benchmarks/output/guardbench-manifest.json',
|
|
54
|
+
'benchmarks/output/guardbench-summary.json',
|
|
55
|
+
'benchmarks/output/guardbench-raw.json',
|
|
56
|
+
'benchmarks/output/guardbench-conformance-card.json',
|
|
57
|
+
'benchmarks/output/adapter-self-test/guardbench-adapter-self-test.json',
|
|
58
|
+
'benchmarks/output/external/guardbench-external-dry-run.json',
|
|
59
|
+
'benchmarks/output/external/guardbench-external-evidence.json',
|
|
60
|
+
'benchmarks/output/leaderboard/guardbench-leaderboard.json',
|
|
61
|
+
'benchmarks/output/leaderboard/guardbench-leaderboard.md',
|
|
62
|
+
'benchmarks/output/submission-bundle/submission-manifest.json',
|
|
63
|
+
'benchmarks/output/submission-bundle/validation-report.json',
|
|
64
|
+
];
|
|
65
|
+
const SCHEMA_FILES = [
|
|
66
|
+
'benchmarks/schemas/guardbench-adapter-registry.schema.json',
|
|
67
|
+
'benchmarks/schemas/guardbench-adapter-self-test.schema.json',
|
|
68
|
+
'benchmarks/schemas/guardbench-conformance-card.schema.json',
|
|
69
|
+
'benchmarks/schemas/guardbench-external-dry-run.schema.json',
|
|
70
|
+
'benchmarks/schemas/guardbench-external-evidence.schema.json',
|
|
71
|
+
'benchmarks/schemas/guardbench-external-run.schema.json',
|
|
72
|
+
'benchmarks/schemas/guardbench-leaderboard.schema.json',
|
|
73
|
+
'benchmarks/schemas/guardbench-manifest.schema.json',
|
|
74
|
+
'benchmarks/schemas/guardbench-publication-verification.schema.json',
|
|
75
|
+
'benchmarks/schemas/guardbench-raw.schema.json',
|
|
76
|
+
'benchmarks/schemas/guardbench-submission-manifest.schema.json',
|
|
77
|
+
'benchmarks/schemas/guardbench-summary.schema.json',
|
|
78
|
+
];
|
|
79
|
+
|
|
80
|
+
function fromRoot(path) {
|
|
81
|
+
return resolve(ROOT, path);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function readJson(path) {
|
|
85
|
+
return JSON.parse(readFileSync(fromRoot(path), 'utf-8'));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function sha256File(path) {
|
|
89
|
+
return createHash('sha256').update(readFileSync(path)).digest('hex');
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function bundleDisplayPath(path) {
|
|
93
|
+
const rel = relative(ROOT, path);
|
|
94
|
+
if (rel && !rel.startsWith('..') && !isAbsolute(rel)) return rel.replaceAll('\\', '/');
|
|
95
|
+
return path.replaceAll('\\', '/');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function parseArgs(argv = process.argv.slice(2)) {
|
|
99
|
+
const args = {
|
|
100
|
+
outDir: DEFAULT_OUT_DIR,
|
|
101
|
+
json: false,
|
|
102
|
+
};
|
|
103
|
+
for (let i = 0; i < argv.length; i++) {
|
|
104
|
+
const token = argv[i];
|
|
105
|
+
if (token === '--out-dir' && argv[i + 1]) args.outDir = argv[++i];
|
|
106
|
+
else if (token === '--json') args.json = true;
|
|
107
|
+
else if (token === '--help' || token === '-h') args.help = true;
|
|
108
|
+
else throw new Error(`Unknown argument: ${token}`);
|
|
109
|
+
}
|
|
110
|
+
return args;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function usage() {
|
|
114
|
+
return `Usage: node scripts/create-paper-submission-bundle.mjs [options]
|
|
115
|
+
|
|
116
|
+
Options:
|
|
117
|
+
--out-dir <path> Output directory. Default: ${DEFAULT_OUT_DIR}.
|
|
118
|
+
--json Print the machine-readable bundle manifest.
|
|
119
|
+
`;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function copyIntoBundle(source, outDir) {
|
|
123
|
+
const sourcePath = fromRoot(source);
|
|
124
|
+
if (!existsSync(sourcePath)) throw new Error(`Missing source file for paper bundle: ${source}`);
|
|
125
|
+
const target = join(outDir, source.replaceAll('\\', '/'));
|
|
126
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
127
|
+
cpSync(sourcePath, target);
|
|
128
|
+
return {
|
|
129
|
+
path: relative(outDir, target).replaceAll('\\', '/'),
|
|
130
|
+
source,
|
|
131
|
+
bytes: readFileSync(target).byteLength,
|
|
132
|
+
sha256: sha256File(target),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export async function writePaperSubmissionBundle(options = {}) {
|
|
137
|
+
const outDir = fromRoot(options.outDir ?? DEFAULT_OUT_DIR);
|
|
138
|
+
const claimVerification = await verifyPaperClaims();
|
|
139
|
+
const publicationPackVerification = await verifyPublicationPack();
|
|
140
|
+
if (!claimVerification.ok) {
|
|
141
|
+
throw new Error(`Cannot create paper submission bundle with invalid claims: ${claimVerification.failures.join('; ')}`);
|
|
142
|
+
}
|
|
143
|
+
if (!publicationPackVerification.ok) {
|
|
144
|
+
throw new Error(`Cannot create paper submission bundle with invalid publication pack: ${publicationPackVerification.failures.join('; ')}`);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
rmSync(outDir, { recursive: true, force: true });
|
|
148
|
+
mkdirSync(outDir, { recursive: true });
|
|
149
|
+
const optionalFiles = OPTIONAL_PAPER_FILES.filter(source => existsSync(fromRoot(source)));
|
|
150
|
+
const files = [...PAPER_FILES, ...optionalFiles, ...BENCHMARK_FILES, ...SCHEMA_FILES]
|
|
151
|
+
.map(source => copyIntoBundle(source, outDir))
|
|
152
|
+
.sort((a, b) => a.path.localeCompare(b.path));
|
|
153
|
+
const guardSummary = readJson('benchmarks/output/guardbench-summary.json');
|
|
154
|
+
const manifest = {
|
|
155
|
+
schemaVersion: '1.0.0',
|
|
156
|
+
suite: 'Audrey paper submission bundle',
|
|
157
|
+
generatedAt: new Date().toISOString(),
|
|
158
|
+
sourceRoot: '.',
|
|
159
|
+
outDir: bundleDisplayPath(outDir),
|
|
160
|
+
claimVerification: {
|
|
161
|
+
ok: claimVerification.ok,
|
|
162
|
+
count: claimVerification.claims.length,
|
|
163
|
+
},
|
|
164
|
+
publicationPackVerification: {
|
|
165
|
+
ok: publicationPackVerification.ok,
|
|
166
|
+
count: publicationPackVerification.entries.length,
|
|
167
|
+
},
|
|
168
|
+
guardBenchSnapshot: {
|
|
169
|
+
passed: guardSummary.passed,
|
|
170
|
+
scenarios: guardSummary.scenarios,
|
|
171
|
+
redactionLeaks: guardSummary.redactionLeaks,
|
|
172
|
+
artifactLeaks: guardSummary.artifactRedactionSweep?.leakCount ?? 0,
|
|
173
|
+
latencyP50Ms: guardSummary.latency?.p50Ms ?? 0,
|
|
174
|
+
latencyP95Ms: guardSummary.latency?.p95Ms ?? 0,
|
|
175
|
+
},
|
|
176
|
+
files,
|
|
177
|
+
};
|
|
178
|
+
const manifestPath = join(outDir, 'paper-submission-manifest.json');
|
|
179
|
+
writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`, 'utf-8');
|
|
180
|
+
|
|
181
|
+
return {
|
|
182
|
+
outDir,
|
|
183
|
+
manifestPath,
|
|
184
|
+
manifest,
|
|
185
|
+
files: files.map(file => file.path),
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
async function main() {
|
|
190
|
+
const args = parseArgs();
|
|
191
|
+
if (args.help) {
|
|
192
|
+
console.log(usage());
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const result = await writePaperSubmissionBundle(args);
|
|
197
|
+
if (args.json) console.log(JSON.stringify(result.manifest, null, 2));
|
|
198
|
+
else {
|
|
199
|
+
console.log(`Paper submission bundle: ${result.outDir}`);
|
|
200
|
+
console.log(`Files: ${result.manifest.files.length}`);
|
|
201
|
+
console.log(`Manifest: ${result.manifestPath}`);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
206
|
+
main().catch(error => {
|
|
207
|
+
console.error(error.stack ?? error.message);
|
|
208
|
+
process.exit(1);
|
|
209
|
+
});
|
|
210
|
+
}
|