diff --git a/.coderabbit.yaml b/.coderabbit.yaml new file mode 100644 index 0000000..7a5a471 --- /dev/null +++ b/.coderabbit.yaml @@ -0,0 +1,41 @@ +# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json +language: en-US +reviews: + profile: chill + auto_approvals: + enabled: true + max_merge_risk: low + # max_security_risk requires Advanced; the current plan is Essentials. + overrides: + - enabled: false + paths: + - '.github/**' + high_level_summary_in_walkthrough: true + review_status: true + # Publish the commit status required by the main ruleset, as in Delaunay. + review_progress: false + commit_status: true + fail_commit_status: true + poem: false + auto_review: + enabled: true + auto_incremental_review: true + drafts: true + path_filters: + - '!**/*.pdf' + - '!**/*.png' + - '!**/*.vsd' + - '!target/**' + - '!uv.lock' + path_instructions: + - path: '**/*.tex' + instructions: >- + Preserve author-owned manuscript prose, scientific claims, attribution, + captions, and TODOs. Review mechanical LaTeX correctness, references, + bibliography and figure paths, and build reproducibility. Give critique + rather than replacement publication prose. + - path: '.github/**' + instructions: >- + Check least-privilege permissions, pinned and allowlisted actions, + untrusted PR input handling, required-check names, and cleanup after + failed builds. PDF build outputs must not be committed or uploaded. diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..bc7cb33 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,26 @@ +* text=auto +*.bib text eol=lf +*.md text eol=lf +*.py text eol=lf +*.sh text eol=lf +*.tex text eol=lf +*.toml text eol=lf +*.yml text eol=lf +justfile text eol=lf +*.pdf binary +*.png binary + +# Preserve historical manuscript and calculation bytes across checkout platforms. +agent-based-modeling/** -text +cdt-newtonian-limit/** -text +cdt-survey/** -text +efficient-cdt/** -text +higgs/** -text +ligo/** -text +local-global-flatness/** -text +newtonian-derivation-cdt/** -text +orions-arm-wormholes/** -text +shared/bibliography/** -text +traversable-wormholes/** -text +weyl-metric-calculations/** -text +docs/legacy-catalog.txt -text diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..2a933c3 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,4 @@ +# Human review covers approval policy and GitHub controls, including this file. +/.coderabbit.yaml @acgetchell +/.coderabbit.yml @acgetchell +/.github/** @acgetchell diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..f6ad92e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: true +contact_links: + - name: Report a security vulnerability privately + url: https://github.com/acgetchell/Papers/security/advisories/new + about: Use private vulnerability reporting for security-sensitive build or tooling issues. diff --git a/.github/actionlint.yaml b/.github/actionlint.yaml new file mode 100644 index 0000000..0749c5a --- /dev/null +++ b/.github/actionlint.yaml @@ -0,0 +1,6 @@ +# Remove when actionlint supports self-repository references: +# https://github.com/rhysd/actionlint/issues/711 +paths: + .github/workflows/*.yml: + ignore: + - '^specifying action "\$/\.github/actions/setup-just" in invalid format because ref is missing\.' diff --git a/.github/actions/setup-just/action.yml b/.github/actions/setup-just/action.yml new file mode 100644 index 0000000..fc50341 --- /dev/null +++ b/.github/actions/setup-just/action.yml @@ -0,0 +1,36 @@ +name: Set up shared tooling +description: Install the locked published package and declared base tools. + +runs: + using: composite + steps: + - name: Install declared uv + uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0 + with: + version-file: pyproject.toml + enable-cache: false + + - name: Cache managed tools + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: ~/.cache/research-repo-tools + key: managed-tools-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('pyproject.toml','rust-toolchain.toml','.python-version','tooling/papers.toml') }} + restore-keys: managed-tools-${{ runner.os }}-${{ runner.arch }}- + + - name: Install the locked tooling package + shell: bash + run: uv sync --locked --managed-python --only-group tooling + + - name: Install verified release binaries + shell: bash + env: + GH_TOKEN: ${{ github.token }} + run: uv run --locked --no-sync --no-python-downloads research-repo-tools toolchain sync-binaries + + - name: Install and export declared base tools + shell: bash + run: | + set -euo pipefail + uv run --locked --managed-python --only-group tooling research-repo-tools toolchain sync + uv sync --locked --managed-python --group dev --group papers + uv run --locked --no-sync --no-python-downloads research-repo-tools toolchain export diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..06ed70a --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,20 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + cooldown: + default-days: 7 + groups: + actions: + patterns: ['*'] + - package-ecosystem: uv + directory: / + schedule: + interval: weekly + cooldown: + default-days: 7 + groups: + python: + patterns: ['*'] diff --git a/.github/settings/actions-selected.json b/.github/settings/actions-selected.json new file mode 100644 index 0000000..15472f5 --- /dev/null +++ b/.github/settings/actions-selected.json @@ -0,0 +1,13 @@ +{ + "github_owned_allowed": false, + "verified_allowed": false, + "patterns_allowed": [ + "actions/cache@*", + "actions/checkout@*", + "actions/upload-artifact@*", + "astral-sh/setup-uv@*", + "github/codeql-action/analyze@*", + "github/codeql-action/init@*", + "github/codeql-action/upload-sarif@*" + ] +} diff --git a/.github/settings/main-ruleset.json b/.github/settings/main-ruleset.json new file mode 100644 index 0000000..66cd152 --- /dev/null +++ b/.github/settings/main-ruleset.json @@ -0,0 +1,41 @@ +{ + "name": "main", + "target": "branch", + "enforcement": "active", + "bypass_actors": [ + {"actor_id": 5, "actor_type": "RepositoryRole", "bypass_mode": "always"} + ], + "conditions": { + "ref_name": {"include": ["~DEFAULT_BRANCH"], "exclude": []} + }, + "rules": [ + {"type": "deletion"}, + {"type": "non_fast_forward"}, + { + "type": "pull_request", + "parameters": { + "allowed_merge_methods": ["merge", "squash", "rebase"], + "dismiss_stale_reviews_on_push": true, + "require_code_owner_review": true, + "require_last_push_approval": false, + "required_approving_review_count": 1, + "required_review_thread_resolution": true + } + }, + { + "type": "required_status_checks", + "parameters": { + "do_not_enforce_on_create": true, + "strict_required_status_checks_policy": true, + "required_status_checks": [ + {"context": "Tooling validation", "integration_id": 15368}, + {"context": "Gitleaks secret scan", "integration_id": 15368}, + {"context": "OSV dependency scan", "integration_id": 15368}, + {"context": "GitHub Actions Security Analysis", "integration_id": 15368}, + {"context": "Changed paper builds", "integration_id": 15368}, + {"context": "CodeRabbit", "integration_id": 347564} + ] + } + } + ] +} diff --git a/.github/settings/repository.json b/.github/settings/repository.json new file mode 100644 index 0000000..92d2852 --- /dev/null +++ b/.github/settings/repository.json @@ -0,0 +1,3 @@ +{ + "allow_auto_merge": true +} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..08088fd --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,27 @@ +name: CI + +on: + pull_request: + push: + branches: [main] + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: ci-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + tooling: + name: Tooling validation + runs-on: ubuntu-24.04 + timeout-minutes: 45 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: $/.github/actions/setup-just + - name: Validate active tooling and pinned inputs + run: just ci diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..3baad17 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,42 @@ +name: CodeQL + +on: + push: + branches: [main] + pull_request: + branches: [main] + schedule: + - cron: '38 11 * * 6' + workflow_dispatch: + +permissions: + actions: read + contents: read + security-events: write + +concurrency: + group: codeql-${{ github.ref }} + cancel-in-progress: true + +jobs: + analyze: + name: Analyze (${{ matrix.language }}) + runs-on: ubuntu-24.04 + timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + language: [actions, python] + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: Initialize CodeQL + uses: github/codeql-action/init@24c54180a607b1449ed407dd24f251e4e9147c8d # v4.38.3 + with: + languages: ${{ matrix.language }} + queries: security-extended + - name: Analyze source and workflows + uses: github/codeql-action/analyze@24c54180a607b1449ed407dd24f251e4e9147c8d # v4.38.3 + with: + category: /language:${{ matrix.language }} diff --git a/.github/workflows/gitleaks.yml b/.github/workflows/gitleaks.yml new file mode 100644 index 0000000..b91096d --- /dev/null +++ b/.github/workflows/gitleaks.yml @@ -0,0 +1,40 @@ +name: Gitleaks + +on: + push: + branches: [main] + pull_request: + branches: [main] + schedule: + - cron: '30 6 * * 1' + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: gitleaks-${{ github.ref }} + cancel-in-progress: true + +jobs: + scan: + name: Gitleaks secret scan + runs-on: ubuntu-24.04 + timeout-minutes: 60 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + persist-credentials: false + - uses: $/.github/actions/setup-just + - name: Scan reachable history and current files + id: scan + run: just security-secrets + - name: Retain redacted security reports + if: ${{ !cancelled() && steps.scan.outcome != 'skipped' }} + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: gitleaks-reports + path: target/security/gitleaks-* + if-no-files-found: error + retention-days: 7 diff --git a/.github/workflows/osv.yml b/.github/workflows/osv.yml new file mode 100644 index 0000000..5acfc35 --- /dev/null +++ b/.github/workflows/osv.yml @@ -0,0 +1,39 @@ +name: OSV-Scanner + +on: + push: + branches: [main] + pull_request: + branches: [main] + schedule: + - cron: '15 6 * * 1' + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: osv-${{ github.ref }} + cancel-in-progress: true + +jobs: + scan: + name: OSV dependency scan + runs-on: ubuntu-24.04 + timeout-minutes: 60 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: $/.github/actions/setup-just + - name: Audit the root Python lockfile + id: scan + run: just security-osv + - name: Retain dependency scan reports + if: ${{ !cancelled() && steps.scan.outcome != 'skipped' }} + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: osv-reports + path: target/security/osv-* + if-no-files-found: error + retention-days: 7 diff --git a/.github/workflows/papers.yml b/.github/workflows/papers.yml new file mode 100644 index 0000000..f0b5d4a --- /dev/null +++ b/.github/workflows/papers.yml @@ -0,0 +1,91 @@ +name: Papers + +on: + pull_request: + branches: [main] + push: + branches: [main] + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: papers-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + select: + name: Select changed papers + runs-on: ubuntu-24.04 + timeout-minutes: 10 + outputs: + sources: ${{ steps.select.outputs.sources }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + persist-credentials: false + - uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0 + with: + version-file: pyproject.toml + enable-cache: false + - name: Install shared selection and process helpers + run: uv sync --locked --managed-python --only-group tooling + - name: Select affected standalone manuscripts + id: select + run: | + sources="$(uv run --locked --no-sync python scripts/build_changed_papers.py changed)" + echo "sources=$sources" >> "$GITHUB_OUTPUT" + + compile: + name: Compile changed LaTeX papers + needs: select + if: needs.select.outputs.sources != '[]' + runs-on: macos-15 + timeout-minutes: 120 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + persist-credentials: false + - uses: $/.github/actions/setup-just + - name: Install native paper dependencies and pinned TeX tools + run: bash scripts/ci-paper-setup.sh + - name: Resolve the Tectonic typesetting cache + id: bundle + run: | + cache_dir="$(uv run --locked --no-sync research-repo-tools --root . --config tooling/papers.toml \ + toolchain run -- tectonic -X show user-cache-dir)" + test -n "$cache_dir" + mkdir -p "$cache_dir" + echo "path=$cache_dir" >> "$GITHUB_OUTPUT" + - name: Cache the typesetting bundle + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: ${{ steps.bundle.outputs.path }} + key: tectonic-bundle-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('tooling/papers.toml') }} + - name: Warm the Tectonic typesetting bundle + run: bash scripts/ci-paper-warmup.sh + - name: Lint and build selected papers without refreshing reviewer PDFs + env: + PAPER_SOURCES_JSON: ${{ needs.select.outputs.sources }} + run: just paper-build-selected + - name: Remove generated LaTeX output even after failure + if: always() + run: just paper-clean + + result: + name: Changed paper builds + needs: [select, compile] + if: always() + runs-on: ubuntu-24.04 + timeout-minutes: 5 + steps: + - name: Require selection and every selected paper build to succeed + env: + SELECT_RESULT: ${{ needs.select.result }} + BUILD_RESULT: ${{ needs.compile.result }} + run: | + test "$SELECT_RESULT" = success + test "$BUILD_RESULT" = success || test "$BUILD_RESULT" = skipped diff --git a/.github/workflows/zizmor.yml b/.github/workflows/zizmor.yml new file mode 100644 index 0000000..6a304d1 --- /dev/null +++ b/.github/workflows/zizmor.yml @@ -0,0 +1,46 @@ +name: zizmor + +on: + push: + branches: [main] + pull_request: + branches: [main] + schedule: + - cron: '42 18 * * 5' + workflow_dispatch: + +permissions: {} + +concurrency: + group: zizmor-${{ github.ref }} + cancel-in-progress: true + +jobs: + analyze: + name: GitHub Actions Security Analysis + runs-on: ubuntu-24.04 + timeout-minutes: 45 + permissions: + actions: read + contents: read + security-events: write + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: $/.github/actions/setup-just + - name: Audit Actions using the shared tooling + env: + GH_TOKEN: ${{ github.token }} + run: | + mkdir -p target/security + just security-workflows --require-online --format sarif > target/security/zizmor.sarif + - name: Upload workflow security analysis + if: >- + always() && hashFiles('target/security/zizmor.sarif') != '' && + (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) + uses: github/codeql-action/upload-sarif@24c54180a607b1449ed407dd24f251e4e9147c8d # v4.38.3 + with: + sarif_file: target/security/zizmor.sarif + category: zizmor + wait-for-processing: true diff --git a/.gitignore b/.gitignore index a95e20d..1910059 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,16 @@ Exported Items.bib # Maple *.bak + +# Root development environment and generated build output +.venv/ +.pytest_cache/ +.ruff_cache/ +__pycache__/ +*.pyc +target/ + +# Preserve the already tracked historical backups after directory organization. +!cdt-newtonian-limit/cdt-newtonian-limit-biblio.bib.bak +!cdt-newtonian-limit/cdt-newtonian-limit.tex.bak +!newtonian-derivation-cdt/newtonian-derivation-cdt-v2.tex.bak diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..93a848f --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.15 diff --git a/.yamllint.yml b/.yamllint.yml new file mode 100644 index 0000000..de68921 --- /dev/null +++ b/.yamllint.yml @@ -0,0 +1,8 @@ +extends: default +rules: + document-start: disable + line-length: + max: 160 + truthy: + allowed-values: ['true', 'false'] + check-keys: false diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..06fecb2 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,34 @@ +# Working in Papers + +Read [CONTRIBUTING.md](CONTRIBUTING.md) before changing tooling and +[docs/BUILDING.md](docs/BUILDING.md) before changing paper builds or inputs. + +- Preserve author-owned manuscript prose, claims, captions, attribution, and + existing TODOs. Mechanical TeX, bibliography, figure-path, and build changes + are allowed; substantive publication prose belongs to the author. +- Keep each manuscript in its own root directory, with versions of the same + paper together. Preserve stored manuscripts and their inputs; active builds + cover only explicitly configured manuscripts. +- Use one root Python environment, `pyproject.toml`, `uv.lock`, and Just entry + point. Reuse the exact published `research-repo-tools` package for common + tooling. Do not introduce per-paper environments or generic fetching systems. +- Inherit Python and Python tool versions from the published shared package. + Local selectors and metadata are checked mirrors, not independent pins. Use + the shared adoption workflow when changing that package's baseline. +- Keep scientific experiments, rendering code, notebooks, and canonical figures + in their software repository. Compile only the checked, pinned local inputs. +- Check/build commands must preserve tracked files. Refresh reviewer PDFs only + through `just paper-refresh` when that refresh is explicitly requested. +- Use patch editing for manual source changes. Preserve unrelated user edits. +- Run `just check` during development and `just ci` for final tooling validation. + Paper CI compiles changed standalone LaTeX manuscripts and shared-input + consumers, then removes generated output even on failure. Manual dispatch + builds all available TeX sources. Pilot changes also require + `just paper-artifact-check` and visual inspection of the rebuilt PDF. +- Do not run CodeRabbit or send repository content to external review services + without the maintainer's explicit request. +- Git mutations require maintainer authorization. Follow established branch + names, otherwise use `/` without agent prefixes. +- Keep README focused on navigation and quickstart; CONTRIBUTING owns contributor + checks; BUILDING owns reproduction and deliberate input updates. Sort command + definitions and reference tables lexicographically. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..f4a9a4d --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,101 @@ +# Contributing + +Use the root environment and [README setup](README.md#quickstart). Python 3.15, +uv, Rust, and managed tools follow the declarations in `.python-version`, +`pyproject.toml`, `rust-toolchain.toml`, and `tooling/papers.toml`. The published +shared package owns the Python minimum and development baseline; local Python +selectors, project metadata, and Ruff targets are validated mirrors. Ruff, ty, +and pytest also inherit their exact versions from that package. + +## Validation + +```sh +just check +just test +``` + +`check` validates the lock, Just, Python formatting/lint/types, TOML, Markdown, +shell scripts, spelling, workflow YAML, Actions security, and pinned manuscript inputs. +`test` runs the consumer integration tests under `tests/papers/`. Use `just ci` +once for final validation; it composes both gates. Ordinary tooling checks and +tooling CI do not install or invoke TeX tools, compile manuscripts, or execute notebooks. + +Paper changes also require: + +```sh +just paper-artifact-check +``` + +Inspect the rebuilt PDF visually. Structural comparison checks page text and +geometry; it does not prove identical rendering or scientific correctness. +The separate Papers workflow builds affected manuscripts on PRs and pushes to +`main`; manual dispatch builds every available standalone TeX source. The pilot +also receives the retained-artifact comparison. Every generated paper build +directory is removed on success or failure; the workflow uploads no LaTeX +artifacts and never refreshes tracked reviewer PDFs. +Selected legacy sources receive advisory ChkTeX checks. ChkTeX findings and +overfull/underfull box warnings appear in the build log and CI job summary; +layout warnings remain advisory for every paper. The pilot retains its existing +ChkTeX policy. Missing tools, failed checks, and compilation errors still fail +the build. + +### Merge requirements + +The stable `Changed paper builds` result is a required merge check, including +for native auto-merge. It fails on selection or compilation failure. When no +paper is affected it passes without compiling; the remaining required reviews, +CI, and security checks still apply. + +The hosted ruleset requires CODEOWNER approval for `.coderabbit.yaml`, +`.coderabbit.yml`, and `.github/**`, including CODEOWNERS itself. Paper files +have no human ownership requirement, so eligible paper PRs can still receive +CodeRabbit approval and use native auto-merge. GitHub evaluates ownership from +the base branch; a PR cannot remove its own required owner by editing the file. + +## Explicit writes + +`just fix` formats active tooling and documentation. `just paper-tex-fmt` +formats only the configured active manuscript. `just paper-refresh` deliberately +replaces its reviewer PDF after the paper checks pass. These commands never +rewrite the older archived manuscripts. Reproduction and input updates are +documented in [BUILDING](docs/BUILDING.md). + +Use `just update-python-dependencies` for deliberate dependency maintenance and +`just update-tools` for declared native-tool updates. Review the resulting pins +and lockfile. Do not edit generated locks or changelogs manually. + +When upgrading `research-repo-tools`, preview `just shared-python-plan VERSION` +and apply `just shared-python-update VERSION`. The exported shared bootstrap +selects a compatible interpreter from the target release's published metadata, +then delegates adoption of the Python mirrors and tool versions to that release. +Do not choose or upgrade the Python baseline independently. + +## Security + +Run `just security` to compose the root lockfile and full-history/current-input +scans, or select `just security-osv` and `just security-secrets` individually. +They use the shared managed scanners. Use `just security-workflows --require-online` +for authenticated workflow-security auditing. +Workflows use read-only repository permissions and pinned external actions. +Dependabot proposes Python and Actions updates; maintainers review them before +merging. CodeRabbit is configured for automatic PR and incremental review, +including drafts, and approves eligible low merge-risk PRs after its findings +are addressed and the latest commit is reviewed. Automatic approval is disabled +for PRs changing `.github/**`; the hosted CODEOWNER rule also protects approval +configuration independently of CodeRabbit's settings. +GitHub native auto-merge can be enabled per ready PR; it +waits for the required approval, resolved threads, CI/security checks, and +successful LaTeX compilation of affected papers. PRs with no affected papers +pass the paper gate without compilation. Other external review services require +a separate request. +See [SECURING](docs/SECURING.md) for live setting ownership, required checks, +and the administrator bypass inherited from Delaunay's policy. + +## Changes + +Preserve author-owned prose and attribution. Keep common tooling in +`research-repo-tools`; consumer tests should cover manuscript policy and input +integrity. Use conventional commit subjects and focused branches such as +`build/reproducible-paper-builds`. Keep Git changes scoped to the work the +maintainer authorized. Record validation in the change description, not a +parallel permanent validation log. diff --git a/README.md b/README.md new file mode 100644 index 0000000..7a4c048 --- /dev/null +++ b/README.md @@ -0,0 +1,68 @@ +# Papers + +Active manuscripts and reproducible paper production for the Rust research +projects. The default branch is `main`. + +## Manuscripts + +| Manuscript | Source and build inputs | Reviewer copy | +| --- | --- | --- | +| Delaunay validation | [Project notes](delaunay-validation/README.md) | [PDF](delaunay-validation/validation.pdf) | + +Each paper has a directory at the repository root. Versions and related drafts +of the same paper stay together. The stored manuscripts below are outside the +automatic formatting scope; their existing filenames, prose, and PDF +bytes are preserved. Legacy TeX received mechanical encoding and bibliography +fixes so the existing sources compile with the pinned toolchain. + +| Stored manuscript | Directory | +| --- | --- | +| Agent-based modeling | [agent-based-modeling](agent-based-modeling/) | +| CDT Newtonian limit, including the DataScience copy | [cdt-newtonian-limit](cdt-newtonian-limit/) | +| CDT survey | [cdt-survey](cdt-survey/) | +| Efficient CDT, with its existing figures | [efficient-cdt](efficient-cdt/) | +| Higgs search | [higgs](higgs/) | +| LIGO | [ligo](ligo/) | +| Local and global flatness | [local-global-flatness](local-global-flatness/) | +| Newtonian derivation, versions and oral-exam draft | [newtonian-derivation-cdt](newtonian-derivation-cdt/) | +| Orion's Arm wormholes | [orions-arm-wormholes](orions-arm-wormholes/) | +| Traversable wormholes | [traversable-wormholes](traversable-wormholes/) | +| Weyl metric, figures, and symbolic calculations | [weyl-metric-calculations](weyl-metric-calculations/) | + +The [original catalog](docs/legacy-catalog.txt) is retained verbatim as a +historical note. Unassigned exported bibliography/style assets live under +`shared/bibliography/`. The existing Newtonian bibliographies each have one +owner and are referenced relatively by the other manuscripts that use them. +Available standalone LaTeX sources are compiled when their paper or a shared +input changes. PDF-only records have no LaTeX source to build in this repository. + +## Quickstart + +Install the uv version declared in [pyproject.toml](pyproject.toml), then +bootstrap the shared tooling from the repository root: + +```sh +uv run --locked --managed-python --only-group tooling research-repo-tools setup +just +``` + +Setup installs the declared tools and a user-level Just command. Open a new +terminal if setup changes PATH. No environment activation is needed. + +For manuscript production, provision the [native prerequisites](docs/BUILDING.md#prerequisites), +then run: + +```sh +just paper-setup +just paper-artifact-check +``` + +The build writes to `target/papers/` and preserves the retained reviewer copy. +See [reproduction and input updates](docs/BUILDING.md) and +[contributor checks](CONTRIBUTING.md). Scientific notebooks and canonical +figures remain in their software repositories. + +PRs receive CodeRabbit review, tooling and security checks, and affected-paper +LaTeX builds. Build output is removed afterward. The full paper build remains +available through manual dispatch. See [repository protections](docs/SECURING.md) +and the separate [blog publishing issue](https://github.com/acgetchell/Papers/issues/2). diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..55e2335 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,21 @@ +# Security policy + +Security maintenance covers the current paper-production tooling and workflows +on `main`. Older stored manuscripts and calculation files are preserved as +research records; they are not separately maintained software releases. + +## Reporting a vulnerability + +Use [GitHub private vulnerability reporting](https://github.com/acgetchell/Papers/security/advisories/new) +or email [adam@adamgetchell.org](mailto:adam@adamgetchell.org). Include the +affected revision, reproduction steps, and expected impact. Report security +vulnerabilities privately rather than in a public issue. + +Relevant reports include compromised build inputs, unsafe handling of untrusted +LaTeX or filenames, credential exposure, vulnerable dependencies, and workflow +permission or publication defects. Scientific critique and manuscript +corrections can use ordinary issues when they contain no sensitive information. + +The maintainer will triage reports as availability allows and coordinate fixes +and any necessary disclosure. Publication delivery is tracked separately in +[issue #2](https://github.com/acgetchell/Papers/issues/2). diff --git a/Agent-based-Modeling.pdf b/agent-based-modeling/Agent-based-Modeling.pdf similarity index 100% rename from Agent-based-Modeling.pdf rename to agent-based-modeling/Agent-based-Modeling.pdf diff --git a/DataScience.pdf b/cdt-newtonian-limit/DataScience.pdf similarity index 100% rename from DataScience.pdf rename to cdt-newtonian-limit/DataScience.pdf diff --git a/DataScience.tex b/cdt-newtonian-limit/DataScience.tex similarity index 100% rename from DataScience.tex rename to cdt-newtonian-limit/DataScience.tex diff --git a/cdt-newtonian-limit-biblio.bib b/cdt-newtonian-limit/cdt-newtonian-limit-biblio.bib similarity index 99% rename from cdt-newtonian-limit-biblio.bib rename to cdt-newtonian-limit/cdt-newtonian-limit-biblio.bib index 108a859..55c1235 100644 --- a/cdt-newtonian-limit-biblio.bib +++ b/cdt-newtonian-limit/cdt-newtonian-limit-biblio.bib @@ -236,7 +236,9 @@ @article{david_simplicial_1993 annote = {Read 0}, file = {arXiv.org Snapshot:/Users/getchell/Library/Application Support/Zotero/Profiles/2wundcq4.default/zotero/storage/4VRDCHUT/9303127.html:text/html;hep-th/9303127 PDF:/Users/getchell/Library/Application Support/Zotero/Profiles/2wundcq4.default/zotero/storage/E5R34SRP/David - 1993 - Simplicial Quantum Gravity and Random Lattices.pdf:application/pdf} - @book{carroll_spacetime_2003, +} + +@book{carroll_spacetime_2003, title = {Spacetime and Geometry: An Introduction to General Relativity}, isbn = {0805387323}, shorttitle = {Spacetime and Geometry}, @@ -244,4 +246,4 @@ @book{carroll_spacetime_2003 author = {Carroll, Sean}, month = sep, year = {2003} -} \ No newline at end of file +} diff --git a/cdt-newtonian-limit-biblio.bib.bak b/cdt-newtonian-limit/cdt-newtonian-limit-biblio.bib.bak similarity index 100% rename from cdt-newtonian-limit-biblio.bib.bak rename to cdt-newtonian-limit/cdt-newtonian-limit-biblio.bib.bak diff --git a/cdt-newtonian-limit.pdf b/cdt-newtonian-limit/cdt-newtonian-limit.pdf similarity index 100% rename from cdt-newtonian-limit.pdf rename to cdt-newtonian-limit/cdt-newtonian-limit.pdf diff --git a/cdt-newtonian-limit.tex b/cdt-newtonian-limit/cdt-newtonian-limit.tex similarity index 100% rename from cdt-newtonian-limit.tex rename to cdt-newtonian-limit/cdt-newtonian-limit.tex diff --git a/cdt-newtonian-limit.tex.bak b/cdt-newtonian-limit/cdt-newtonian-limit.tex.bak similarity index 100% rename from cdt-newtonian-limit.tex.bak rename to cdt-newtonian-limit/cdt-newtonian-limit.tex.bak diff --git a/cdt-survey.pdf b/cdt-survey/cdt-survey.pdf similarity index 100% rename from cdt-survey.pdf rename to cdt-survey/cdt-survey.pdf diff --git a/delaunay-validation/LICENSE.delaunay b/delaunay-validation/LICENSE.delaunay new file mode 100644 index 0000000..3b11651 --- /dev/null +++ b/delaunay-validation/LICENSE.delaunay @@ -0,0 +1,28 @@ +# BSD 3-Clause License + +Copyright (c) 2023, Adam Getchell + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/delaunay-validation/README.md b/delaunay-validation/README.md new file mode 100644 index 0000000..0b1a4f6 --- /dev/null +++ b/delaunay-validation/README.md @@ -0,0 +1,47 @@ +# Delaunay validation manuscript + +This directory holds the active TeX source, paper-local bibliography, retained +reviewer PDF, and pinned scientific figure inputs migrated from +[Delaunay](https://github.com/acgetchell/delaunay). + +## Source identity + +- Scientific input revision: + [`e365c531ea157469c0f8767153e75d0ac6db920e`](https://github.com/acgetchell/delaunay/tree/e365c531ea157469c0f8767153e75d0ac6db920e). +- Crate version at that revision: `0.8.2`; the revision is 17 commits after + the `v0.8.2` release commit + [`1892b823c4600b56f9720517ed34dad4b155fb0f`](https://github.com/acgetchell/delaunay/tree/1892b823c4600b56f9720517ed34dad4b155fb0f). + It is not the released `v0.8.2` source tree. +- [Original manuscript](https://github.com/acgetchell/delaunay/blob/e365c531ea157469c0f8767153e75d0ac6db920e/papers/validation.tex), + [bibliography](https://github.com/acgetchell/delaunay/blob/e365c531ea157469c0f8767153e75d0ac6db920e/papers/validation.bib), + and [reviewer copy](https://github.com/acgetchell/delaunay/blob/e365c531ea157469c0f8767153e75d0ac6db920e/papers/validation.pdf). +- [Figure notebook](https://github.com/acgetchell/delaunay/blob/e365c531ea157469c0f8767153e75d0ac6db920e/notebooks/01_validation.ipynb) + and [renderer](https://github.com/acgetchell/delaunay/blob/e365c531ea157469c0f8767153e75d0ac6db920e/tooling/python/notebook_validation_rendering.py) + remain owned by Delaunay. +- The [provenance manifest](inputs.toml) records the exact upstream figure paths, + SHA-256 hashes, and initial manuscript/BibTeX/PDF hashes. The six PNG images in + `figures/` are exact snapshots of the canonical Delaunay Git blobs. +- The [upstream license](LICENSE.delaunay) is retained with these inputs. + +The migration preserves manuscript prose, author TODOs, citations, and +attribution. Its only TeX edits change the six figure paths to local snapshots. +The bibliography and retained reviewer PDF are copied byte-for-byte. The +original PDF-normalization identity remains `papers/validation.tex`. + +## Reproduction + +Run these commands from anywhere within this repository after +[setup](../docs/BUILDING.md#prerequisites): + +```sh +just paper-artifact-check +``` + +Output is written to `target/papers/delaunay-validation/validation.pdf`. +The tracked [reviewer copy](validation.pdf) is not replaced by build or check +commands. See [BUILDING](../docs/BUILDING.md) for deliberate input updates and +reviewer refreshes. + +The historical +[v0.8.0 reviewer artifact guide](https://github.com/acgetchell/delaunay/blob/ee0b1992071552ecf8669418ea74444a699343a9/papers/ARTIFACT.md) +and its release evidence retain their original Delaunay ownership and links. diff --git a/delaunay-validation/figures/validation_hierarchy.png b/delaunay-validation/figures/validation_hierarchy.png new file mode 100644 index 0000000..543924c Binary files /dev/null and b/delaunay-validation/figures/validation_hierarchy.png differ diff --git a/delaunay-validation/figures/validation_level_1_element_validity.png b/delaunay-validation/figures/validation_level_1_element_validity.png new file mode 100644 index 0000000..a053a7a Binary files /dev/null and b/delaunay-validation/figures/validation_level_1_element_validity.png differ diff --git a/delaunay-validation/figures/validation_level_2_combinatorial_consistency.png b/delaunay-validation/figures/validation_level_2_combinatorial_consistency.png new file mode 100644 index 0000000..e1199b7 Binary files /dev/null and b/delaunay-validation/figures/validation_level_2_combinatorial_consistency.png differ diff --git a/delaunay-validation/figures/validation_level_3_intrinsic_pl_topology.png b/delaunay-validation/figures/validation_level_3_intrinsic_pl_topology.png new file mode 100644 index 0000000..86c30db Binary files /dev/null and b/delaunay-validation/figures/validation_level_3_intrinsic_pl_topology.png differ diff --git a/delaunay-validation/figures/validation_level_4_valid_realization.png b/delaunay-validation/figures/validation_level_4_valid_realization.png new file mode 100644 index 0000000..29a4223 Binary files /dev/null and b/delaunay-validation/figures/validation_level_4_valid_realization.png differ diff --git a/delaunay-validation/figures/validation_level_5_geometric_predicates.png b/delaunay-validation/figures/validation_level_5_geometric_predicates.png new file mode 100644 index 0000000..a16fcba Binary files /dev/null and b/delaunay-validation/figures/validation_level_5_geometric_predicates.png differ diff --git a/delaunay-validation/inputs.toml b/delaunay-validation/inputs.toml new file mode 100644 index 0000000..d574313 --- /dev/null +++ b/delaunay-validation/inputs.toml @@ -0,0 +1,46 @@ +schema = 1 + +[source] +repository = "https://github.com/acgetchell/delaunay" +commit = "e365c531ea157469c0f8767153e75d0ac6db920e" +crate-version = "0.8.2" +base-release = "v0.8.2" +base-release-commit = "1892b823c4600b56f9720517ed34dad4b155fb0f" +commits-after-release = 17 +notebook = "notebooks/01_validation.ipynb" +renderer = "tooling/python/notebook_validation_rendering.py" + +[migration] +"validation.tex" = "675c3422750037354f5eec0ad05784d6a23e419dfccf12edbf622b2d6f164b75" +"validation.bib" = "3ee15c96d0041b337cc396206241b3fdc4fce1d3c8626b9f3bea51f3c38ac6a4" +"validation.pdf" = "165879fe3e397a556d767068cf5931397d15ba175ba71d5da7404ad4478f1e96" + +[[figures]] +path = "figures/validation_hierarchy.png" +upstream = "docs/assets/validation/validation_hierarchy.png" +sha256 = "7c9014faa8223e0280ee4328b77749788d6c9047ecb65046f52880516920e6f4" + +[[figures]] +path = "figures/validation_level_1_element_validity.png" +upstream = "docs/assets/validation/validation_level_1_element_validity.png" +sha256 = "2af25da247230d6b0e5e0d8d4cd2a7c7a62b3d048eccb0fab83be483ac5732cc" + +[[figures]] +path = "figures/validation_level_2_combinatorial_consistency.png" +upstream = "docs/assets/validation/validation_level_2_combinatorial_consistency.png" +sha256 = "68fc64e354a48ddf4988d7d34cb32c9799ff41e9ae78354160ade06cc0d14477" + +[[figures]] +path = "figures/validation_level_3_intrinsic_pl_topology.png" +upstream = "docs/assets/validation/validation_level_3_intrinsic_pl_topology.png" +sha256 = "bbbb16f5565a7862d84d6440f316658c9d03fb8135b226f1694b82cbea59c916" + +[[figures]] +path = "figures/validation_level_4_valid_realization.png" +upstream = "docs/assets/validation/validation_level_4_valid_realization.png" +sha256 = "0a8ed860a41acd73a0781274d2e69bf2a689029e581a4d54ce419867a42ba760" + +[[figures]] +path = "figures/validation_level_5_geometric_predicates.png" +upstream = "docs/assets/validation/validation_level_5_geometric_predicates.png" +sha256 = "9aa5e75c195fb01c69a4d4d34e427b57740a4a1d487c54853461eeda80e00070" diff --git a/delaunay-validation/validation.bib b/delaunay-validation/validation.bib new file mode 100644 index 0000000..6075638 --- /dev/null +++ b/delaunay-validation/validation.bib @@ -0,0 +1,78 @@ +@inproceedings{leibon_delaunay_2000, + address = {Clear Water Bay Kowloon Hong Kong}, + title = {Delaunay triangulations and {Voronoi} diagrams for {Riemannian} manifolds}, + isbn = {978-1-58113-224-3}, + url = {https://dl.acm.org/doi/10.1145/336154.336221}, + doi = {10.1145/336154.336221}, + abstract = {For a sufficiently dense set of points in any closed Riemannian manifold, we prove that a unique Delannay triangulation exists. This triangulation has the same properties as in Euclidean space. Algorithms for constructing these triangulations will also be described.}, + language = {en}, + urldate = {2026-07-06}, + booktitle = {Proceedings of the sixteenth annual symposium on {Computational} geometry}, + publisher = {ACM}, + author = {Leibon, Greg and Letscher, David}, + month = may, + year = {2000}, + pages = {341--349}, +} + +@incollection{lickorish_simplicial_1999, + title = {Simplicial moves on complexes and manifolds}, + booktitle = {Proceedings of the Kirbyfest}, + series = {Geometry \& Topology Monographs}, + volume = {2}, + pages = {299--320}, + url = {https://msp.org/gtm/1999/02/gtm-1999-02-016p.pdf}, + doi = {10.2140/gtm.1999.2.299}, + abstract = {Here are versions of the proofs of two classic theorems of combinatorial topology. The first is the result that piecewise linearly homeomorphic simplicial complexes are related by stellar moves. This is used in the proof, modelled on that of Pachner, of the second theorem. This states that moves from only a finite collection are needed to relate two triangulations of a piecewise linear manifold.}, + urldate = {2026-07-06}, + publisher = {Geometry and Topology Publications}, + author = {Lickorish, W. B. R.}, + month = nov, + year = {1999}, + note = {arXiv:math/9911256}, + keywords = {Mathematics - Geometric Topology}, +} + +@book{edelsbrunner2001, + author = {Edelsbrunner, Herbert}, + title = {Geometry and Topology for Mesh Generation}, + publisher = {Cambridge University Press}, + year = {2001}, + address = {Cambridge, United Kingdom}, + doi = {10.1017/CBO9780511530067}, +} + +@article{pachner1991, + author = {Pachner, Udo}, + title = {P.L. Homeomorphic Manifolds Are Equivalent by Elementary Shellings}, + journal = {European Journal of Combinatorics}, + volume = {12}, + number = {2}, + pages = {129--145}, + year = {1991}, + doi = {10.1016/S0195-6698(13)80080-7}, +} + +@article{shewchuk1997, + author = {Shewchuk, Jonathan Richard}, + title = {Adaptive Precision Floating-Point Arithmetic and Fast Robust Geometric Predicates}, + journal = {Discrete \& Computational Geometry}, + volume = {18}, + number = {3}, + pages = {305--363}, + year = {1997}, + doi = {10.1007/PL00009321}, +} + +@inproceedings{caroli2010, + author = {Caroli, Manuel and de Castro, Pedro M. M. and Loriot, Sébastien and Rouiller, Olivier and Teillaud, Monique and Wormser, Camille}, + title = {Robust and Efficient Delaunay Triangulations of Points on or Close to a Sphere}, + booktitle = {Experimental Algorithms}, + series = {Lecture Notes in Computer Science}, + volume = {6049}, + pages = {462--473}, + publisher = {Springer}, + address = {Berlin, Heidelberg}, + year = {2010}, + doi = {10.1007/978-3-642-13193-6_39}, +} diff --git a/delaunay-validation/validation.pdf b/delaunay-validation/validation.pdf new file mode 100644 index 0000000..8961c11 Binary files /dev/null and b/delaunay-validation/validation.pdf differ diff --git a/delaunay-validation/validation.tex b/delaunay-validation/validation.tex new file mode 100644 index 0000000..bf8eb01 --- /dev/null +++ b/delaunay-validation/validation.tex @@ -0,0 +1,437 @@ +% Keep nonacm until this draft is actually submitted to ACM/TOMS. +\documentclass[manuscript,nonacm]{acmart} + +\setcopyright{none} +\settopmatter{printacmref=false} +\raggedbottom{} +\acmJournal{TOMS} + +\title{Construction and Validation Architecture in delaunay} + +\author{Adam Getchell} +\email{adam@adamgetchell.org} +\orcid{0000-0002-0797-0021} % chktex 8 +\affiliation{% + \institution{The George Washington University} + \city{Washington} + \state{DC} + \country{USA} +} + +% Keep this explicit so CI rebuilds do not rewrite the reviewer-copy date. +\date{July 6, 2026} + +% Authorship note: +% This source is intentionally an author-facing outline. Agents may maintain +% TeX structure, build tooling, citation plumbing, figures, and TODO prompts, +% but Adam writes the substantive paper prose. +\newcommand{\AuthorTodo}[1]{\textbf{Author TODO.} #1} +\begin{abstract} + \AuthorTodo{Write the abstract in your own words.} +\end{abstract} + +\keywords{TODO author-supplied keywords} + +\begin{document} +\maketitle + +\section{Introduction} + +\begin{itemize} + \item \AuthorTodo{State the problem and motivation.} + \item \AuthorTodo{Explain why proof-bearing construction and validation + architecture matter for a scientific computational-geometry library.} + \item \AuthorTodo{Summarize the central contribution in your own words.} + \item \AuthorTodo{Preview the paper structure.} +\end{itemize} + +Applications such as Causal Dynamical Triangulation (CDT) require a robust and +reliable triangulation library, capable of maintaining correct properties of the +triangulation in simulations that may alter their structure millions +of times per +simulation. +These invariant properties should be verifiable during construction +and mutation, +and violations of these properties should be detectable and diagnosable, so that +fixable errors may be corrected and unfixable errors may be reported. + +Delaunay is a Rust library for constructing and mutating triangulations with +insertion, deletion, and bi-stellar k-flip operations, while maintaining a range +of invariant properties important for the construction of Pseudo- and +Piecewise-Linear (PL) manifolds, +the evaluation of geometric predicates, and the embedding of +triangulations in Euclidean, +toroidal, and spherical spaces. + +\AuthorTodo{Qualify the preceding overview so the ordinary mutable + Euclidean/toroidal workflows are distinguished from the separate bounded +\(S^2\)/\(S^3\) spherical prototype.} + +\section{Background and Definitions} + +\begin{itemize} + \item \AuthorTodo{Define the triangulation, simplex, ridge, facet, and + realization terms used throughout the paper.} + \item \AuthorTodo{Introduce PL-manifold terminology and the link condition.} + \item \AuthorTodo{Introduce Euclidean, toroidal, and spherical realization + models.} + \item \AuthorTodo{Introduce Delaunay and future geometric-predicate + terminology.} +\end{itemize} + +\section{Proof-Bearing Construction Architecture} + +\subsection{Vocabulary and API Roles} + +\begin{itemize} + \raggedright + \item \AuthorTodo{Define a published owner as a domain value whose Rust type + carries cumulative invariants. Suggested examples: \texttt{Tds}, + \texttt{Triangulation}, and \texttt{DelaunayTriangulation}.} + \item \AuthorTodo{Define a builder as a configurable public workflow that + may coordinate several proof boundaries before returning an owner or a + typed failure. Suggested examples: \texttt{TdsBuilder}, + \texttt{TriangulationBuilder}, \texttt{DelaunayRefinementBuilder}, + \texttt{DelaunayTriangulation}\hspace{0pt}\texttt{Builder}, and + \texttt{DelaunayIncremental}\hspace{0pt}\texttt{Builder}.} + \item \AuthorTodo{Define a draft as an unpublished representation attached + to one promotion boundary. Suggested examples: \texttt{TdsDraft}, + \texttt{TriangulationDraft}, and the private + \texttt{DelaunayTriangulation}\hspace{0pt}\texttt{Draft}.} + \item \AuthorTodo{Define a workspace as private mutable algorithm state that + may contain incomplete bootstrap, repair, retry, cache, or + scheduling data. + Suggested examples: + \texttt{DelaunayBootstrap}\hspace{0pt}\texttt{Workspace} and + \texttt{DelaunayBatch}\hspace{0pt}\texttt{Workspace}.} + \item \AuthorTodo{Explain why the architecture avoids the ambiguous term + ``candidate'': a proof-boundary value is a draft, while mutable algorithm + state is a workspace.} +\end{itemize} + +\subsection{Incremental Promotion Through Proof Layers} + +\begin{itemize} + \raggedright + \item \AuthorTodo{Present the explicit-connectivity ladder: raw vertices and + simplex specifications to \texttt{Tds} at Levels 1--2, then + \texttt{Triangulation} at Levels 1--4, then + \texttt{DelaunayTriangulation} at Levels 1--5.} + \item \AuthorTodo{Explain that each promotion preserves established lower + proofs and checks only the missing layer unless a cumulative diagnostic + audit is explicitly requested.} + \item \AuthorTodo{Describe why lower layers cannot infer connectivity using + a higher-layer Delaunay policy. Suggested contrast: explicit simplex + specifications at the TDS boundary versus point-set inference in a + Delaunay builder.} + \item \AuthorTodo{Describe the point-driven batch path through + \texttt{DelaunayBatch}\hspace{0pt}\texttt{Workspace} and the final + private + \texttt{DelaunayTriangulation}\hspace{0pt}\texttt{Draft}.} + \item \AuthorTodo{Describe the incremental path through + \texttt{DelaunayIncremental}\hspace{0pt}\texttt{Builder}: bootstrap in a + \texttt{DelaunayBootstrap}\hspace{0pt}\texttt{Workspace} containing + \texttt{TdsDraft}, followed + by ordered Levels 1--2, 3--4, and 5 promotion when the first + maximal simplex + exists.} + \item \AuthorTodo{Explain why the public incremental type is a builder rather + than a draft: it is long-lived, fluent, and coordinates multiple proof + boundaries before and after the first maximal simplex.} +\end{itemize} + +\subsection{Failure Atomicity, Recovery, and Fast Paths} + +\begin{itemize} + \item \AuthorTodo{State the publication rule: success returns a valid owner + for the promised layer; failure returns a typed error and never exposes an + invalid published owner.} + \item \AuthorTodo{Describe consuming promotions that return the original + lower owner on failure so callers may retry with a different policy.} + \item \AuthorTodo{Contrast strict, non-mutating promotion with explicitly + selected canonicalization or repair modes that use rollback workspaces.} + \item \AuthorTodo{Explain how construction-owned fast-path evidence is bound + to the exact owner identity, structural generation, and topology so stale + evidence cannot publish a stronger owner.} + \item \AuthorTodo{Discuss the empty-complex boundary: empty drafts are + trivially publishable when their layer invariants hold, while nonempty + partial bootstrap state cannot be published.} +\end{itemize} + +\section{Construction and Validation Hierarchy} + +\begin{figure}[htbp] + \centering + \includegraphics[width=0.95\linewidth] + {figures/validation_hierarchy.png} + \caption{Overview of the validation hierarchy in delaunay: \texttt{Tds} + owns Levels 1--2, \texttt{Triangulation} adds Levels 3--4, and + \texttt{Delaunay}\hspace{0pt}\texttt{Triangulation} adds Level 5.} + \label{fig:validation-hierarchy} + \Description{The five validation levels and their proof-bearing Rust + owners. Tds owns Levels 1--2, Triangulation adds Levels 3--4, and + DelaunayTriangulation adds Level 5.} +\end{figure} + +\subsection{Level 1: Element Validity} + +\begin{itemize} + \item \AuthorTodo{Describe what individual vertices, simplices, facets, and + coordinates must prove locally.} + \item \AuthorTodo{Explain what this level deliberately does not check.} +\end{itemize} + +\subsection{Level 2: Combinatorial Consistency} + +\begin{itemize} + \item \AuthorTodo{Describe adjacency, incidence, neighbor symmetry, and TDS + integrity.} + \item \AuthorTodo{Distinguish coherent stored simplex orderings, including + periodic quotient facets, from intrinsic orientability.} + \item \AuthorTodo{Explain the separation from topology and geometry.} +\end{itemize} + +\subsection{Level 3: Intrinsic PL Topology} + +\begin{itemize} + \item \AuthorTodo{State the PL-manifold and boundary conditions.} + \item \AuthorTodo{Discuss pseudomanifold and strict PL-manifold policy + choices.} + \item \AuthorTodo{Describe the 2D/3D intrinsic orientation witness and + periodic quotient parity constraints.} + \item \AuthorTodo{Explain why this layer is independent of Euclidean, + toroidal, and spherical realizations.} +\end{itemize} + +\subsection{Level 4: Valid Realization} + +\begin{itemize} + \item \AuthorTodo{Use the terminology stack: Level 4 Valid Realization; + Euclidean/toroidal valid affine-chart realization; spherical valid + spherical realization; Level 5 Geometric Predicate Satisfaction / Delaunay + Optimality.} + \item \AuthorTodo{Describe valid realization in the active ambient + model.} + \item \AuthorTodo{Compare Euclidean/toroidal affine-chart realizations and + spherical realizations.} + \item \AuthorTodo{Keep positive geometric orientation distinct from Level 2 + stored coherence and Level 3 intrinsic orientability.} + \item \AuthorTodo{Explain why realization validity is a precondition for + geometric predicates.} + \item \AuthorTodo{Introduce two realized \(d\)-simplices with vertices + \(a_0,\ldots,a_d\) and \(b_0,\ldots,b_d\), vertex labels + \(\ell_i\) and \(m_j\), and shared-label set \(S\), then explain the exact + shared-face intersection program in + Equation~\ref{eq:shared-face-intersection-lp}.} + \begin{equation} + \label{eq:shared-face-intersection-lp} + \begin{aligned} + z^\star + ={}& \underset{\alpha_i,\beta_j \geq 0}{\operatorname{maximize}} + && \sum_{\ell_i \notin S} \alpha_i + + \sum_{m_j \notin S} \beta_j \\ + & \text{\rm subject to} + && \sum_{i=0}^{d} \alpha_i a_i + = \sum_{j=0}^{d} \beta_j b_j, \\ + &&& \sum_{i=0}^{d} \alpha_i = 1, + \qquad \sum_{j=0}^{d} \beta_j = 1 . + \end{aligned} + \end{equation} + \item \AuthorTodo{Explain the three exact outcomes: infeasibility proves the + simplices disjoint; \(z^\star=0\) proves every feasible intersection point + is confined to the shared face; and \(z^\star>0\) supplies barycentric + weight on non-shared labels for a typed intersection witness.} + \item \AuthorTodo{Explain how revised-simplex basis navigation replaces + exhaustive active-set enumeration of the intersection polytope on the + common path and removes the bottleneck exposed by the 4D and 5D Level 4 + checks.} + \item \AuthorTodo{Describe the filtered-exact hierarchy: bounding-box, + separating-facet, orientation, and shared-face normal tests reject or + certify easy pairs; floating-point simplex phases propose axes and bases; + proved floating-point error bounds or exact rational primal/dual checks + certify accepted results; and active-set enumeration remains the + conservative fallback.} + \item \AuthorTodo{Describe how exact finite-\texttt{f64} systems use the + runtime-dispatched fraction-free Bareiss solver from \texttt{la-stack}, + while general rational systems retain the \texttt{BigRational} fallback.} + \item \AuthorTodo{Treat the broader independent randomized and degenerate + 2D--5D agreement campaign and representative before/after benchmarks as + v0.8.1 work tracked by issue \#482.} + \item \AuthorTodo{Do not present the bounded v0.8.0 4D and 5D slow-test probes + as performance evidence. Coordinate any Level 5 all-violations performance + claims with the separate v0.8.1 work in issue \#483.} +\end{itemize} + +\subsection{Level 5: Geometric Predicates} + +\begin{itemize} + \item \AuthorTodo{Describe Delaunay as the first implemented predicate + family.} + \item \AuthorTodo{Explain how Euclidean, toroidal, and spherical Delaunay + predicates differ.} + \item \AuthorTodo{Leave room for regular, weighted, constrained, Gabriel, + alpha, and future predicate families.} +\end{itemize} + +\section{Implementation Architecture} + +\begin{center} + \begin{minipage}{\textwidth} + \captionof{table}{Public validation API by owning layer.} + \label{tab:validation-api} + \small + \begin{tabular}{@{}cp{0.88\textwidth}@{}} + \toprule + Level & Canonical public surface \\ + \midrule + 1 & \texttt{Vertex::is\_valid} / \texttt{vertex\_report}; + \texttt{Simplex::is\_valid} / \texttt{simplex\_report} \\ + 2 & \texttt{Tds::is\_valid} / \texttt{structure\_report}; + \texttt{Tds::validate} certifies Levels 1--2 \\ + 3 & \texttt{Triangulation::is\_valid\_topology} / + \texttt{topology\_report} / \texttt{orientation\_witness}; + \texttt{Triangulation::validate} certifies Levels 1--3 \\ + 4 & \texttt{Triangulation::is\_valid\_realization} / + \texttt{realization\_report}; \texttt{validate\_realization} certifies + Levels 1--4 \\ + 5 & \texttt{DelaunayTriangulation::is\_valid\_delaunay} / + \texttt{delaunay\_report}; \texttt{DelaunayTriangulation::validate} + certifies Levels 1--5 \\ + \bottomrule + \end{tabular} + \end{minipage} +\end{center} + +\begin{itemize} + \item \AuthorTodo{Relate each public builder terminal and private draft to + the proof-bearing owner it publishes.} + \item \AuthorTodo{Distinguish builder options, draft promotion state, + workspace mutation state, and owner-level validation methods in the API + map.} + \item \AuthorTodo{Map the five validation levels onto the Rust API surface.} + \item \AuthorTodo{Describe the role of fast-fail checks, diagnostics, + reports, and cumulative validation.} + \item \AuthorTodo{Explain construction-time validation policy choices such + as \texttt{ExplicitOnly} and \texttt{OnSuspicion}.} + \item \AuthorTodo{Describe how spherical topology fits as a + coordinate/metric backend rather than a new simplex dimension.} +\end{itemize} + +\section{Diagnostics and Reproducible Figures} + +\begin{figure}[p] + \centering + \includegraphics[width=0.88\linewidth] + {figures/validation_level_1_element_validity.png} + \caption{Level 1 Element Validity (\texttt{Tds}, cumulative Levels 1--2). + \AuthorTodo{Describe the validation witnesses shown in this panel.}} + \label{fig:validation-level-1} + \Description{Level 1 Element Validity belongs to the cumulative Levels 1--2 + proof owned by Tds. \AuthorTodo{Describe the validation witnesses shown in + this panel.}} +\end{figure} + +\begin{figure}[p] + \centering + \includegraphics[width=0.88\linewidth] + {figures/validation_level_2_combinatorial_consistency.png} + \caption{Level 2 Combinatorial Consistency (\texttt{Tds}, cumulative Levels + 1--2). \AuthorTodo{Describe the validation witnesses shown in this panel.}} + \label{fig:validation-level-2} + \Description{Level 2 Combinatorial Consistency belongs to the cumulative + Levels 1--2 proof owned by Tds. \AuthorTodo{Describe the validation + witnesses shown in this panel.}} +\end{figure} + +\begin{figure}[p] + \centering + \includegraphics[width=0.88\linewidth] + {figures/validation_level_3_intrinsic_pl_topology.png} + \caption{Level 3 Intrinsic PL Topology (\texttt{Triangulation}, cumulative + Levels 1--4). \AuthorTodo{Describe the validation witnesses shown in this + panel.}} + \label{fig:validation-level-3} + \Description{Level 3 Intrinsic PL Topology belongs to the cumulative Levels + 1--4 proof owned by Triangulation. \AuthorTodo{Describe the validation + witnesses shown in this panel.}} +\end{figure} + +\begin{figure}[p] + \centering + \includegraphics[width=0.88\linewidth] + {figures/validation_level_4_valid_realization.png} + \caption{Level 4 Valid Realization (\texttt{Triangulation}, cumulative Levels + 1--4). \AuthorTodo{Describe the validation witnesses shown in this panel.}} + \label{fig:validation-level-4} + \Description{Level 4 Valid Realization belongs to the cumulative Levels 1--4 + proof owned by Triangulation. \AuthorTodo{Describe the validation witnesses + shown in this panel.}} +\end{figure} + +\clearpage +\begin{figure}[htbp] + \centering + \includegraphics[width=0.52\linewidth] + {figures/validation_level_5_geometric_predicates.png} + \caption{Level 5 Geometric Predicate Satisfaction + (\texttt{DelaunayTriangulation}, cumulative Levels 1--5). + \AuthorTodo{Describe the validation witness shown in this panel.}} + \label{fig:validation-level-5} + \Description{Level 5 Geometric Predicate Satisfaction belongs to the + cumulative Levels 1--5 proof owned by DelaunayTriangulation. + \AuthorTodo{Describe the validation witness shown in this panel.}} +\end{figure} + +\begin{itemize} + \item \AuthorTodo{Explain how the validation notebook generates paper + figures.} + \item \AuthorTodo{Describe representative diagnostics without duplicating API + documentation.} + \item \AuthorTodo{Connect figure generation to the reproducibility story.} +\end{itemize} + +\section{Related Work} + +\begin{itemize} + \item \AuthorTodo{Place PL topology references and Pachner/Lickorish + results.} + \item \AuthorTodo{Place Euclidean robust-predicate and Delaunay references.} + \item \AuthorTodo{Place spherical Delaunay and Riemannian-manifold + references.} + \item \AuthorTodo{Clarify which claims are architectural observations rather + than literature claims.} +\end{itemize} + +\section{Discussion and Future Work} + +\begin{itemize} + \item \AuthorTodo{Discuss extensibility to additional realization models and + predicate families.} + \item \AuthorTodo{Discuss whether the Draft/Builder/Workspace vocabulary + generalizes to regular, weighted, constrained, and non-Delaunay + triangulation workflows.} + \item \AuthorTodo{Discuss limitations of the current implementation.} + \item \AuthorTodo{Identify open validation and benchmarking questions.} +\end{itemize} + +\section{Conclusion} + +\begin{itemize} + \item \AuthorTodo{Write the conclusion in your own words.} +\end{itemize} + +\begin{acks} + The author thanks Steven Carlip for discussions and guidance over + the years on Causal Dynamical Triangulation, which motivated this work, + and for encouragement and questions on this library, which + motivated this paper. +\end{acks} + +% Keep the reference list available in outline drafts so citation keys remain +% build-tested even before their final in-text placement is written +% by the author. +\nocite{*} +\bibliographystyle{ACM-Reference-Format} +\bibliography{validation} + +\end{document} diff --git a/docs/BUILDING.md b/docs/BUILDING.md new file mode 100644 index 0000000..05f5899 --- /dev/null +++ b/docs/BUILDING.md @@ -0,0 +1,135 @@ +# Building papers + +All commands run through the root Justfile and the single root Python +environment and lockfile. The Delaunay validation manuscript is the initial +reproducible pilot. All nine available standalone TeX sources can also be built. +Stored PDF-only papers remain reference documents because their source is not +present here. + +## Prerequisites + +Complete the [root setup](../README.md#quickstart). Paper tools are a separate +opt-in configuration in `tooling/papers.toml`, sharing the root Rust and Python +selectors. That configuration pins Tectonic and tex-fmt. Install ChkTeX using a +TeX distribution or system package manager. + +- macOS: Xcode Command Line Tools and + `brew install freetype graphite2 icu4c libpng pkgconf zlib`. Existing + MacTeX/BasicTeX tools are discovered at `/Library/TeX/texbin`. +- Linux: a native C/C++ build toolchain, pkg-config, and development packages for + fontconfig, FreeType, Graphite2/HarfBuzz, ICU, libpng, OpenSSL, and zlib. +- Windows MSVC: Visual Studio C++ Build Tools, a Windows SDK, Git for Windows + with POSIX `sh` on PATH, and the corresponding vcpkg libraries. Set + `TECTONIC_DEP_BACKEND=vcpkg`, `VCPKG_ROOT`, and `VCPKGRS_TRIPLET`. + +CI typesetting uses macOS. Linux and Windows native paper builds are not +currently CI acceptance targets. + +```sh +just paper-setup +just paper-artifact-check +``` + +Setup discovers installed native libraries through the shared tooling before +installing the declared Cargo tools. Tectonic may download its TeX bundle on +the first build; that is a typesetting dependency, not scientific input. Figure +inputs are always the checked local snapshots; builds never fetch them or run +scientific experiments. + +## Commands + +| Command | Effect | +| --- | --- | +| `just paper-artifact-check` | Run paper checks and compare the result with the retained reviewer PDF | +| `just paper-build` | Verify pinned figures, compile into `target/papers/delaunay-validation/`, normalize metadata, and reject unresolved references | +| `just paper-build-all` | Lint and compile every standalone TeX source and clean each generated build directory | +| `just paper-build-selected SOURCE...` | Lint and compile selected root-relative TeX sources and clean their output even on failure | +| `just paper-check` | Check TeX formatting/lint, compile, and check required PDF text and structure | +| `just paper-clean` | Remove only generated paper build output | +| `just paper-inputs-check` | Verify the pinned commit metadata, complete figure inventory, and SHA-256 hashes | +| `just paper-pdf-check` | Check the existing generated PDF without compiling | +| `just paper-refresh` | Run checks and deliberately replace the tracked reviewer PDF | +| `just paper-setup` | Install optional typesetting tools using the root environment | +| `just paper-tex-fmt` | Format the active TeX source | +| `just paper-tex-fmt-check` | Check active TeX formatting without edits | +| `just paper-tex-lint` | Lint the active TeX source with ChkTeX | + +The source's explicit date supplies `SOURCE_DATE_EPOCH`. Shared PDF normalization +retains the original stable identity `papers/validation.tex` across the migration. +It normalizes volatile XMP identifiers and timestamps and PDF trailer IDs. +`paper-artifact-check` checks per-page text and geometry against the retained +reviewer copy. Inspect rendering separately before any deliberate refresh. + +## Changed-paper CI + +The Papers workflow runs on PRs and pushes to `main`. Selection uses exact Git +event revisions and the shared safe file inventory. A change anywhere within a +paper directory rebuilds that paper's standalone source variants. Changes to +explicit shared bibliographies also rebuild their consumers. Changes to the +paper toolchain, build scripts, or root Justfile rebuild all standalone TeX sources. + +Contributor merge requirements are documented in +[CONTRIBUTING](../CONTRIBUTING.md#merge-requirements). + +Manual workflow dispatch builds all available sources. PDF-only directories +have no source to compile. No scientific notebook is executed. The pilot keeps +its shared explicit date, normalization, and reviewer comparison. Legacy sources +with empty dates, `\\today`, or no date retain that author-owned source and use +the source commit timestamp for `SOURCE_DATE_EPOCH` during compile checks. + +Selected legacy sources are checked with the installed ChkTeX using the shared +process runner. Findings are advisory and do not rewrite manuscript prose or +block builds. The pilot retains its existing ChkTeX suppressions and check. +Missing ChkTeX, unreadable inputs, and other operational failures still fail. +All selected builds report overfull/underfull horizontal and vertical boxes as +advisory layout diagnostics, including any available log from a failed compile. +Full diagnostics appear in the build log; GitHub Actions also receives a job +summary with counts and bounded details before generated logs are deleted. +Unresolved references/citations, duplicate labels, and bibliography errors +remain build failures. + +All compiler writes go under `target/papers/`. The changed-paper command removes +each generated directory through a `finally` block, and the workflow runs +`just paper-clean` under `if: always()` as a final cleanup. Generated PDFs, logs, +and auxiliary files are not uploaded or committed. The granular pilot commands +retain local output temporarily for visual inspection; run `just paper-clean` +afterward. + +## Updating pinned inputs + +The [manuscript notes](../delaunay-validation/README.md) link to the exact +scientific source revision and provenance manifest. The copied figure files are +immutable build inputs from Delaunay; its notebook, renderer, scientific +contracts, and documentation assets remain canonical in that repository. + +To update them deliberately: + +1. Choose and record a full Delaunay commit SHA, its Cargo version, and the + associated release tag and tag commit. Note when the revision is after a + release; never describe an unreleased revision as that release's evidence. +2. Verify the chosen revision and scientific figures in Delaunay using that + repository's own validation procedure. Do not run experiments from Papers. +3. Copy only the six required `docs/assets/validation/*.png` Git blobs from that + revision into this manuscript's `figures/`. Update `inputs.toml` with each + exact upstream path and SHA-256 digest and the source revision. Retain + Delaunay's license and attribution. Review the changed images and metadata. +4. Run `just ci` and `just paper-artifact-check`. Inspect any changed text, + geometry, references, and rendering. A deliberate manuscript revision may + correctly fail comparison with the older reviewer copy; resolve the + discrepancy before requesting a refresh. +5. When the reviewer refresh is authorized, run `just paper-refresh`, inspect + that PDF, and rerun `just paper-artifact-check`. Commit source, input + provenance, figure snapshots, and approved reviewer changes together. + +No command automatically selects a newer software revision or updates hashes. +Initial manuscript/BibTeX/reviewer hashes in the manifest record migration +provenance; only the scientific figure hashes are immutable build constraints. + +## Delaunay migration order + +First verify this local build and the manual Papers CI build. Only then update +Delaunay's active manuscript links and remove its superseded paper sources, +paper-only tools, recipes, tests, and CI. Preserve its root Python environment, +scientific notebooks, canonical figures, historical v0.8.0 artifact guide, +immutable release records, and version-specific links. Historical evidence +continues to belong to the repository and revision that produced it. diff --git a/docs/SECURING.md b/docs/SECURING.md new file mode 100644 index 0000000..d2c0de0 --- /dev/null +++ b/docs/SECURING.md @@ -0,0 +1,132 @@ +# Securing Papers + +Papers follows Delaunay's GitHub security pattern with checks appropriate to a +manuscript repository. The maintainer owns live GitHub settings; committed +policy files document the expected configuration and validate workflow changes. + +## Repository controls + +- Enable secret scanning, secret push protection, Dependabot alerts/security + updates, and private vulnerability reporting. +- Set the default Actions token permissions to read and disable Actions-created + pull request approvals. Jobs elevate only the permissions they need. +- Permit only the explicit action patterns in + [actions-selected.json](../.github/settings/actions-selected.json), with verified + publishers and GitHub-owned actions not broadly allowed. Require full commit SHA pins. +- Apply [main-ruleset.json](../.github/settings/main-ruleset.json) to the default + branch. It requires a PR, one approval, resolved review threads, current + required checks, and blocks deletion and force pushes. It also requires + CODEOWNER approval for the paths assigned in + [CODEOWNERS](../.github/CODEOWNERS). +- Allow GitHub native auto-merge using + [repository.json](../.github/settings/repository.json). Maintainers opt in + each ready PR; all required checks and reviews still gate the merge. +- Retain the repository-administrator bypass used by Delaunay. Ordinary + development still uses PRs and waits for checks and review. + +## Human review of control files + +The hosted `require_code_owner_review` rule and the CODEOWNERS file on `main` +require `@acgetchell` to approve changes to either root CodeRabbit configuration +filename and to `.github/**`. This includes CODEOWNERS itself and the committed +settings snapshots. GitHub uses the base branch's ownership file, so changing +or deleting the ownership mapping in a PR does not remove its required review. +The hosted rule is managed by a repository administrator, independently of +PR-controlled CodeRabbit approval settings. + +Paper files have no CODEOWNER entry. Their existing one-approval requirement +can still be satisfied by CodeRabbit, subject to its low merge-risk policy and +all required checks. No blanket human approval is required for ordinary papers. + +PR #3 introduces the ownership map, so path-specific enforcement begins after +it is merged into `main`. The hosted requirement is enabled before that merge; +it cannot assign an owner while the base branch has no CODEOWNERS file. +`@acgetchell` is currently the only human collaborator. GitHub does not permit +self-approval, so maintainer-authored control changes, including this bootstrap +PR, require deliberate manual review and use of the existing administrator +bypass, or an additional trusted human code owner. Automation must not use +that bypass. See [GitHub's CODEOWNERS documentation](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners). + +## Required checks + +| Check | Provider | +| --- | --- | +| Changed paper builds | GitHub Actions | +| CodeRabbit | CodeRabbit GitHub App | +| GitHub Actions Security Analysis | GitHub Actions | +| Gitleaks secret scan | GitHub Actions | +| OSV dependency scan | GitHub Actions | +| Tooling validation | GitHub Actions | + +The ruleset binds checks to their provider application IDs. Paper build +selection runs for every PR so the stable aggregate check succeeds for a +change with no affected TeX. A selection failure cannot become a successful +skipped build. When sources are selected, their LaTeX builds must succeed. +Changes to shared paper tooling, including the root Justfile, rebuild all +standalone sources. This required check applies to native auto-merge as well as +manual merging. + +## Security workflows + +Gitleaks and OSV run on PRs, `main` pushes, weekly schedules, and manual dispatch +through `research-repo-tools`. Gitleaks scans full reachable history and current +inputs; OSV scans the root `uv.lock`. Validated JSON/SARIF security reports are +retained for seven days, including on findings. These are security reports, not +LaTeX build artifacts. + +The zizmor workflow uses the shared authenticated, required-online command and +uploads SARIF to code scanning. CodeQL covers Actions and Python; no Rust crate +or notebook workload is run in this repository. Workflow checking also enforces +the selected-actions policy through the shared allowlist command. + +CodeRabbit automatically reviews PRs and subsequent pushes, including drafts. +Its `reviews.auto_approvals.enabled` setting requests changes for blocking +findings and approves after required threads are resolved, the latest commit +is reviewed, its pre-merge checks pass, and merge risk is at most `low`. +PRs changing `.github/**` are excluded from automatic approval and require +human review. The security-risk cap is not configured because the current +Essentials plan does not provide the required assessment; configuring it would +withhold approvals. See CodeRabbit's +[approval risk limits](https://docs.coderabbit.ai/pr-reviews/approval-risk-limits). +`reviews.auto_approvals.enabled` is the current name for the +`request_changes_workflow` setting used in the other research repositories. +`review_progress: false` retains the `CodeRabbit` commit status required by the +ruleset. A successful commit status reports review completion; the separate +approving review satisfies the required approval. +Its instructions preserve author-owned scientific prose and focus TeX feedback +on correctness and build plumbing. Review does not publish papers or refresh +their reviewer PDFs. [Blog publishing](https://github.com/acgetchell/Papers/issues/2) +has a separate scope and approval path. + +## Applying settings + +Enable native auto-merge with the committed repository setting: + +```sh +gh api --method PATCH repos/acgetchell/Papers \ + --input .github/settings/repository.json +``` + +Enabling this repository setting does not arm every PR. Maintainers enable +auto-merge separately on each ready PR in GitHub or with +`gh pr merge NUMBER --repo acgetchell/Papers --auto --merge`. Drafts remain +unmergeable. No workflow grants itself approval or bypasses the ruleset. + +After reviewing a policy change, repository administrators can apply the action +allowlist with the GitHub CLI: + +```sh +gh api --method PUT repos/acgetchell/Papers/actions/permissions \ + -F enabled=true -f allowed_actions=selected -F sha_pinning_required=true +gh api --method PUT repos/acgetchell/Papers/actions/permissions/selected-actions \ + --input .github/settings/actions-selected.json +gh api --method PUT repos/acgetchell/Papers/actions/permissions/workflow \ + -f default_workflow_permissions=read -F can_approve_pull_request_reviews=false +``` + +For the ruleset, read `gh api repos/acgetchell/Papers/rulesets`, then update the +existing `main` ruleset by its returned ID using the committed JSON. Use creation +only when it does not already exist; never create duplicate rulesets. Re-read +settings after applying them and verify that required names match real check +runs. Keep these controls separate from workflow YAML permissions and +`SECURITY.md`'s vulnerability-reporting policy. diff --git a/README b/docs/legacy-catalog.txt similarity index 100% rename from README rename to docs/legacy-catalog.txt diff --git a/EfficientCDT/.gitignore b/efficient-cdt/.gitignore similarity index 100% rename from EfficientCDT/.gitignore rename to efficient-cdt/.gitignore diff --git a/EfficientCDT/3D-states.pdf b/efficient-cdt/3D-states.pdf similarity index 100% rename from EfficientCDT/3D-states.pdf rename to efficient-cdt/3D-states.pdf diff --git a/EfficientCDT/3Dmoves.pdf b/efficient-cdt/3Dmoves.pdf similarity index 100% rename from EfficientCDT/3Dmoves.pdf rename to efficient-cdt/3Dmoves.pdf diff --git a/EfficientCDT/DT1.pdf b/efficient-cdt/DT1.pdf similarity index 100% rename from EfficientCDT/DT1.pdf rename to efficient-cdt/DT1.pdf diff --git a/EfficientCDT/EfficientCDT.bib b/efficient-cdt/EfficientCDT.bib similarity index 100% rename from EfficientCDT/EfficientCDT.bib rename to efficient-cdt/EfficientCDT.bib diff --git a/EfficientCDT/EfficientCDT.pdf b/efficient-cdt/EfficientCDT.pdf similarity index 100% rename from EfficientCDT/EfficientCDT.pdf rename to efficient-cdt/EfficientCDT.pdf diff --git a/EfficientCDT/EfficientCDT.tex b/efficient-cdt/EfficientCDT.tex similarity index 100% rename from EfficientCDT/EfficientCDT.tex rename to efficient-cdt/EfficientCDT.tex diff --git a/EfficientCDT/NDT.pdf b/efficient-cdt/NDT.pdf similarity index 100% rename from EfficientCDT/NDT.pdf rename to efficient-cdt/NDT.pdf diff --git a/EfficientCDT/Parallel_Transport.pdf b/efficient-cdt/Parallel_Transport.pdf similarity index 100% rename from EfficientCDT/Parallel_Transport.pdf rename to efficient-cdt/Parallel_Transport.pdf diff --git a/EfficientCDT/eM-CDT.pdf b/efficient-cdt/eM-CDT.pdf similarity index 100% rename from EfficientCDT/eM-CDT.pdf rename to efficient-cdt/eM-CDT.pdf diff --git a/EfficientCDT/here_to_help.pdf b/efficient-cdt/here_to_help.pdf similarity index 100% rename from EfficientCDT/here_to_help.pdf rename to efficient-cdt/here_to_help.pdf diff --git a/EfficientCDT/repres.pdf b/efficient-cdt/repres.pdf similarity index 100% rename from EfficientCDT/repres.pdf rename to efficient-cdt/repres.pdf diff --git a/Higgs.pdf b/higgs/Higgs.pdf similarity index 100% rename from Higgs.pdf rename to higgs/Higgs.pdf diff --git a/justfile b/justfile new file mode 100644 index 0000000..68d5b51 --- /dev/null +++ b/justfile @@ -0,0 +1,189 @@ +set positional-arguments + +rrt := "uv run --locked --no-sync --no-python-downloads research-repo-tools" +managed := rrt + " toolchain run --" +paper_rrt := rrt + " --root . --config tooling/papers.toml" +paper_managed := paper_rrt + " toolchain run --" +paper_source := "delaunay-validation/validation.tex" + +# Generate the changelog from authorized commits with the shared tooling. +changelog: + {{ managed }} research-repo-tools changelog generate + +# Check active tooling, documentation, workflow policy, and pinned inputs. +check: lock-check justfile-check python-check toml-check markdown-check shell-check workflow-check workflow-allowlist-check paper-inputs-check typos-check + +# Final tooling validation; paper compilation is a separate manual gate. +ci: check test + +# Show the available commands when invoked without a recipe. +[default] +[private] +default: help + +# Format active tooling and documentation explicitly. +fix: + {{ rrt }} python fix + just --fmt --unstable + {{ managed }} taplo fmt pyproject.toml rust-toolchain.toml tooling/papers.toml delaunay-validation/inputs.toml typos.toml + {{ managed }} rumdl fmt AGENTS.md CONTRIBUTING.md README.md SECURITY.md docs/BUILDING.md docs/SECURING.md delaunay-validation/README.md + uv run --locked --no-sync shfmt -w scripts/*.sh + +# List recipes and parameters in lexicographic order. +help: + @just --justfile {{ quote(justfile()) }} --alias-style right --list + +# Validate Just syntax and formatting without writing files. +justfile-check: + just --fmt --check --unstable + +# Verify that the committed lock agrees with the root manifest. +lock-check: + uv lock --check --offline + +# Check active Markdown; legacy manuscripts are outside this scope. +markdown-check: + {{ managed }} rumdl check AGENTS.md CONTRIBUTING.md README.md SECURITY.md docs/BUILDING.md docs/SECURING.md delaunay-validation/README.md + +# Build and compare with the retained reviewer PDF without refreshing it. +paper-artifact-check: paper-check + {{ paper_rrt }} papers check --paper validation --reference delaunay-validation/validation.pdf + +# Build the pilot manuscript from its checked local scientific inputs. +paper-build: paper-inputs-check + {{ paper_rrt }} toolchain check + bash scripts/build-paper.sh + +# Compile selected standalone manuscripts and clean their generated output. +paper-build-all: + uv run --locked --no-sync --no-python-downloads python scripts/build_changed_papers.py build --all + +# Compile selected standalone manuscripts and clean their generated output. +paper-build-selected *sources: + uv run --locked --no-sync --no-python-downloads python scripts/build_changed_papers.py build "$@" + +# Check TeX, compile, and validate required PDF content without tracked writes. +paper-check: paper-tex-fmt-check paper-tex-lint paper-build && paper-pdf-check + +# Remove only generated paper build output. +paper-clean: + rm -rf target/papers + +# Check the pinned scientific input inventory and SHA-256 hashes. +paper-inputs-check: + uv run --locked --no-sync --no-python-downloads python scripts/check_paper_inputs.py + +# Check the existing generated PDF without compiling it. +paper-pdf-check: + {{ paper_rrt }} papers check --paper validation + +# Deliberately refresh the tracked reviewer PDF after all paper checks pass. +paper-refresh: paper-check + {{ paper_rrt }} papers normalize --paper validation --output delaunay-validation/validation.pdf + +# Install optional TeX tools after provisioning documented native prerequisites. +paper-setup: setup + #!/usr/bin/env bash + set -euo pipefail + export PATH="/Library/TeX/texbin:$PATH" + uv sync --locked --managed-python --group dev --group papers + native_environment="$({{ paper_rrt }} tectonic discover --format shell)" + eval "$native_environment" + {{ paper_rrt }} validation require chktex + {{ paper_rrt }} toolchain sync + +# Format only the configured active manuscript. +paper-tex-fmt: + {{ paper_managed }} tex-fmt {{ paper_source }} + +# Check active manuscript formatting without edits. +paper-tex-fmt-check: + {{ paper_managed }} tex-fmt --check {{ paper_source }} + +# Lint active TeX using the existing system ChkTeX installation. +paper-tex-lint: + #!/usr/bin/env bash + set -euo pipefail + export PATH="/Library/TeX/texbin:$PATH" + {{ paper_rrt }} validation require chktex + # Match the source repository: 24 conflicts with tex-fmt's figure labels. + chktex -q -n 1 -n 8 -n 24 -n 46 {{ paper_source }} + +# Check the complete Python inventory with inherited Ruff and ty versions. +python-check: + {{ rrt }} python check + +# Scan dependencies and reachable Git history using the shared managed scanners. +security: security-osv security-secrets + +# Scan the root lockfile with the managed shared OSV command. +security-osv: + {{ rrt }} security osv uv.lock + +# Scan reachable Git history and current inputs with managed Gitleaks. +security-secrets *args: + {{ rrt }} security secrets "$@" + +# Audit workflow security with explicit offline or required-online settings. +security-workflows *args: + {{ rrt }} zizmor check "$@" + +# Install the declared base tools and synchronize the root environment. +setup: + uv run --locked --managed-python --only-group tooling research-repo-tools setup + +# Check shell syntax, formatting, and ShellCheck diagnostics. +shell-check: + bash -n scripts/build-paper.sh scripts/ci-paper-setup.sh scripts/ci-paper-warmup.sh + uv run --locked --no-sync shfmt -d scripts/*.sh + uv run --locked --no-sync shellcheck scripts/*.sh + +# Preview a shared-package upgrade and its inherited Python mirrors. +shared-python-plan version: + uv run --no-config --no-project --isolated --managed-python --script tooling/python-bootstrap.py "$1" --dry-run + +# Deliberately adopt a published shared-package release and its Python baseline. +shared-python-update version: + uv run --no-config --no-project --isolated --managed-python --script tooling/python-bootstrap.py "$1" --apply + +# Discover existing native TeX libraries through the shared implementation. +tectonic +args: + {{ paper_rrt }} tectonic "$@" + +# Run manuscript policy and integration tests in the root environment. +test: + uv run --locked --no-sync --no-python-downloads --group papers pytest tests/papers + +# Check active TOML declarations with managed Taplo. +toml-check: + {{ managed }} taplo fmt --check pyproject.toml rust-toolchain.toml tooling/papers.toml delaunay-validation/inputs.toml typos.toml + +# Check all declared base tool versions without installation. +tools-check: + {{ rrt }} toolchain check + +# Export verified managed tool paths for GitHub Actions. +tools-export: + {{ rrt }} toolchain export + +# Check spelling in active tooling and guidance, excluding stored manuscripts. +typos-check: + {{ managed }} typos AGENTS.md CONTRIBUTING.md README.md SECURITY.md docs/BUILDING.md docs/SECURING.md delaunay-validation/README.md scripts tests + +# Deliberately update Python declarations and the shared root lockfile. +update-python-dependencies: + {{ rrt }} deps update-python --all-projects + +# Deliberately upgrade declared native tools and their pins. +update-tools: + {{ rrt }} toolchain upgrade + +# Require every external action to match the committed selected-actions policy. +workflow-allowlist-check: + {{ rrt }} actions allowlist --policy .github/settings/actions-selected.json .github/workflows + +# Validate workflow syntax, YAML policy, and pinned-action security. +workflow-check: + uv run --locked --no-sync actionlint + uv run --locked --no-sync yamllint .github .coderabbit.yaml .yamllint.yml + {{ rrt }} zizmor check --offline diff --git a/LIGO.pdf b/ligo/LIGO.pdf similarity index 100% rename from LIGO.pdf rename to ligo/LIGO.pdf diff --git a/local-global-flatness.pdf b/local-global-flatness/local-global-flatness.pdf similarity index 100% rename from local-global-flatness.pdf rename to local-global-flatness/local-global-flatness.pdf diff --git a/local-global-flatness.tex b/local-global-flatness/local-global-flatness.tex similarity index 99% rename from local-global-flatness.tex rename to local-global-flatness/local-global-flatness.tex index 1794e2e..099a2de 100644 --- a/local-global-flatness.tex +++ b/local-global-flatness/local-global-flatness.tex @@ -2,7 +2,7 @@ % \usepackage{times} \usepackage{mathptmx} \usepackage[T1]{fontenc} -\usepackage[latin9]{inputenc} +\usepackage[utf8]{inputenc} \usepackage{calc} \usepackage{units} \usepackage{amsmath} diff --git a/Initialization.png b/newtonian-derivation-cdt/Initialization.png similarity index 100% rename from Initialization.png rename to newtonian-derivation-cdt/Initialization.png diff --git a/newtonian-derivation-cdt-v2.bib b/newtonian-derivation-cdt/newtonian-derivation-cdt-v2.bib similarity index 100% rename from newtonian-derivation-cdt-v2.bib rename to newtonian-derivation-cdt/newtonian-derivation-cdt-v2.bib diff --git a/newtonian-derivation-cdt-v2.pdf b/newtonian-derivation-cdt/newtonian-derivation-cdt-v2.pdf similarity index 100% rename from newtonian-derivation-cdt-v2.pdf rename to newtonian-derivation-cdt/newtonian-derivation-cdt-v2.pdf diff --git a/newtonian-derivation-cdt-v2.tex b/newtonian-derivation-cdt/newtonian-derivation-cdt-v2.tex similarity index 99% rename from newtonian-derivation-cdt-v2.tex rename to newtonian-derivation-cdt/newtonian-derivation-cdt-v2.tex index c33d456..440c4e3 100644 --- a/newtonian-derivation-cdt-v2.tex +++ b/newtonian-derivation-cdt/newtonian-derivation-cdt-v2.tex @@ -2,7 +2,7 @@ \documentclass{article} \usepackage{mathptmx} \usepackage[T1]{fontenc} -\usepackage[latin9]{inputenc} +\usepackage[utf8]{inputenc} \usepackage{microtype} \usepackage{calc} \usepackage{siunitx} diff --git a/newtonian-derivation-cdt-v2.tex.bak b/newtonian-derivation-cdt/newtonian-derivation-cdt-v2.tex.bak similarity index 100% rename from newtonian-derivation-cdt-v2.tex.bak rename to newtonian-derivation-cdt/newtonian-derivation-cdt-v2.tex.bak diff --git a/newtonian-derivation-cdt.pdf b/newtonian-derivation-cdt/newtonian-derivation-cdt.pdf similarity index 100% rename from newtonian-derivation-cdt.pdf rename to newtonian-derivation-cdt/newtonian-derivation-cdt.pdf diff --git a/newtonian-derivation-cdt.tex b/newtonian-derivation-cdt/newtonian-derivation-cdt.tex similarity index 99% rename from newtonian-derivation-cdt.tex rename to newtonian-derivation-cdt/newtonian-derivation-cdt.tex index dd3d8f0..7f380d4 100644 --- a/newtonian-derivation-cdt.tex +++ b/newtonian-derivation-cdt/newtonian-derivation-cdt.tex @@ -2,7 +2,7 @@ % \usepackage{times} \usepackage{mathptmx} \usepackage[T1]{fontenc} -\usepackage[latin9]{inputenc} +\usepackage[utf8]{inputenc} \usepackage{calc} \usepackage{units} \usepackage{amsmath} @@ -380,7 +380,7 @@ \section{Summary} \end{itemize} \bibliographystyle{ieeetr} -\bibliography{cdt-newtonian-limit-biblio} +\bibliography{newtonian-derivation-cdt-v2} \end{document} diff --git a/orals-backup.tex b/newtonian-derivation-cdt/orals-backup.tex similarity index 99% rename from orals-backup.tex rename to newtonian-derivation-cdt/orals-backup.tex index c65e55c..338e450 100644 --- a/orals-backup.tex +++ b/newtonian-derivation-cdt/orals-backup.tex @@ -2,7 +2,7 @@ % \usepackage{times} \usepackage{mathptmx} \usepackage[T1]{fontenc} -\usepackage[latin9]{inputenc} +\usepackage[utf8]{inputenc} \usepackage{calc} \usepackage{units} \usepackage{amsmath} @@ -507,7 +507,7 @@ \section{Summary} \end{itemize} \bibliographystyle{ieeetr} -\bibliography{cdt-newtonian-limit-biblio} +\bibliography{newtonian-derivation-cdt-v2} \end{document} diff --git a/oaup-wormholes.pdf b/orions-arm-wormholes/oaup-wormholes.pdf similarity index 100% rename from oaup-wormholes.pdf rename to orions-arm-wormholes/oaup-wormholes.pdf diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..f9a82a0 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,71 @@ +[project] +name = "research-papers" +version = "0.1.0" +description = "Active manuscripts and reproducible research paper builds" +# Checked mirror of the pinned research-repo-tools distribution's Python floor. +requires-python = ">=3.15" + +[dependency-groups] +tooling = ["research-repo-tools[python-tools]==0.2.3"] +dev = [ + { include-group = "tooling" }, + "actionlint-py==1.7.12.25", + "shellcheck-py==0.11.0.1", + "shfmt-py==4.2.0", + "yamllint==1.38.0", + "zizmor==1.31.1", +] +papers = ["research-repo-tools[papers,python-tools]==0.2.3"] + +[tool.uv] +package = false +required-version = "==0.13.5" + +[tool.research-repo-tools] +schema = 1 + +[tool.research-repo-tools.changelog] +owner = "acgetchell" +repository = "Papers" + +[tool.research-repo-tools.toolchain] +inherit-python = true +inherit-python-tools = true + +[tool.research-repo-tools.toolchain.binaries] +gitleaks = "8.30.1" +osv-scanner = "2.7.0" +rumdl = "0.3.0" + +[tool.research-repo-tools.toolchain.cargo] +git-cliff = "2.14.2" +taplo-cli = "0.10.0" +typos-cli = "1.51.1" + +[tool.research-repo-tools.zizmor] +persona = "regular" + +[tool.pytest.ini_options] +testpaths = ["tests/papers"] +addopts = ["--import-mode=importlib", "--strict-markers", "--strict-config"] + +[tool.ruff] +# Checked development mirror of research-repo-tools, maintained by adoption. +line-length = 160 + +[tool.ruff.lint] +select = ["E4", "E7", "E9", "F", "I", "ANN", "B", "UP"] + +[tool.ruff.lint.per-file-ignores] +# Keep the published Python 3.8-compatible bootstrap byte-for-byte upstream. +"tooling/python-bootstrap.py" = ["ANN001", "ANN201"] + +[tool.rumdl] +line-length = 160 + +[tool.rumdl.MD013] +line-length = 160 + +[tool.uv.dependency-groups] +papers = { requires-python = ">=3.15" } +tooling = { requires-python = ">=3.15" } diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..0b8307a --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "1.99.1" +profile = "minimal" diff --git a/scripts/build-paper.sh b/scripts/build-paper.sh new file mode 100644 index 0000000..6cae5dc --- /dev/null +++ b/scripts/build-paper.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# Compile only the pilot manuscript; scientific inputs are already local. +set -euo pipefail + +repo_root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)" +cd "$repo_root" + +rrt() { + uv run --locked --no-sync --no-python-downloads research-repo-tools \ + --root . --config tooling/papers.toml "$@" +} + +source_path="delaunay-validation/validation.tex" +build_dir="target/papers/delaunay-validation" +rm -rf "$build_dir" +mkdir -p "$build_dir" +source_date_epoch="$(rrt papers source-date --paper validation)" +export SOURCE_DATE_EPOCH="$source_date_epoch" +rrt toolchain run -- tectonic --untrusted --keep-intermediates --keep-logs \ + --outdir "$build_dir" "$source_path" + +test -s "$build_dir/validation.log" + +if grep -Eiq 'LaTeX Warning: (Citation|Reference).*undefined|There were undefined (references|citations)|There were multiply-defined labels' \ + "$build_dir/validation.log"; then + echo "Unresolved citations, references, or duplicate labels in the paper build." >&2 + exit 1 +fi + +rrt papers normalize --paper validation diff --git a/scripts/build_changed_papers.py b/scripts/build_changed_papers.py new file mode 100644 index 0000000..f4c7267 --- /dev/null +++ b/scripts/build_changed_papers.py @@ -0,0 +1,252 @@ +"""Select affected manuscripts and compile them with the shared pinned toolchain.""" + +import argparse +import html +import json +import os +import re +import shutil +import subprocess +import sys +from pathlib import Path + +from research_repo_tools.paper_dates import read_source_date +from research_repo_tools.paper_pdf import check_pdf +from research_repo_tools.process import ExecutableNotFoundError, format_exception_diagnostics, run_command, run_command_live, run_git_bytes +from research_repo_tools.selection import select_files + +ROOT = Path(__file__).resolve().parents[1] +BUILD_INPUTS = frozenset( + { + ".github/actions/setup-just/action.yml", + ".github/workflows/papers.yml", + ".python-version", + "justfile", + "pyproject.toml", + "rust-toolchain.toml", + "scripts/build-paper.sh", + "scripts/build_changed_papers.py", + "scripts/check_paper_inputs.py", + "scripts/ci-paper-setup.sh", + "scripts/ci-paper-warmup.sh", + "tooling/papers.toml", + "uv.lock", + } +) +UNRESOLVED = re.compile( + r"LaTeX Warning: (?:Citation|Reference).*undefined|There were undefined (?:references|citations)|There were multiply-defined labels", + re.IGNORECASE, +) +LAYOUT = re.compile(r"(?m)^(?:Over|Under)full \\[hv]box[^\n]*(?:\n(?!(?:Over|Under)full \\[hv]box)[^\n]+)*") + + +def report_advisories(source: str, category: str, diagnostics: list[str]) -> None: + """Keep full diagnostics in logs and bounded, escaped details in CI summaries.""" + status = f"{category}: {len(diagnostics)} advisory diagnostic(s)" + print(f"{source!r}: {status}") + details = "\n\n".join(diagnostics) + for line in details.splitlines(): + # Tool output must not become a GitHub Actions workflow command. + print(f" {line}") + summary = os.environ.get("GITHUB_STEP_SUMMARY") + if summary: + excerpt = "\n".join(details.splitlines()[:100])[:8000] + if excerpt != details: + excerpt += "\n[Summary truncated; full diagnostics are in the build log.]" + with Path(summary).open("a", encoding="utf-8") as stream: + stream.write(f"

{html.escape(source)}: {html.escape(category)}

\n\n{status}\n\n") + if excerpt: + stream.write(f"
{html.escape(excerpt)}
\n\n") + + +def lint_legacy_source(root: Path, source: str) -> None: + """Report legacy ChkTeX findings without hiding operational failures.""" + environment = {**os.environ, "PATH": os.pathsep.join(("/Library/TeX/texbin", os.environ.get("PATH", "")))} + result = run_command( + "chktex", + ["-q", "-f", "%f:%l:%c: %k %n: %m\n", Path(source).name], + cwd=(root / source).parent, + env=environment, + errors="replace", + timeout=60, + check=False, + ) + report_advisories(source, "ChkTeX", result.stdout.splitlines()) + # ChkTeX documents 2/3 as manuscript warnings/errors; legacy findings are + # advisory. Exit 1, signals, and unexpected statuses are tool failures. + if result.returncode not in (0, 2, 3): + result.check_returncode() + # ChkTeX can exit zero when it could not open an input; those messages go + # to stderr rather than its formatted manuscript diagnostics on stdout. + if result.stderr.strip(): + raise ValueError(f"ChkTeX could not fully check {source}: {result.stderr.strip()}") + + +def manuscript_sources(root: Path) -> tuple[str, ...]: + """Use the shared safe inventory; fragments are inputs rather than documents.""" + return tuple( + name + for name in select_files(root, include=("*.tex",), exclude=("target/**", ".venv/**")) + if re.search(r"(?m)^\s*\\documentclass(?:\[[^]]*\])?\{", (root / name).read_text(encoding="utf-8")) + ) + + +def bibliography_inputs(root: Path, source: str) -> set[str]: + """Resolve the repository's existing explicit BibTeX references.""" + inputs: set[str] = set() + path = root / source + for group in re.findall(r"\\bibliography\{([^}]+)\}", path.read_text(encoding="utf-8")): + for name in group.split(","): + bibliography = path.parent / name.strip() + if bibliography.suffix != ".bib": + bibliography = bibliography.with_suffix(".bib") + resolved = bibliography.resolve() + if not resolved.is_relative_to(root.resolve()): + raise ValueError(f"Bibliography is outside the repository: {source}") + inputs.add(resolved.relative_to(root.resolve()).as_posix()) + return inputs + + +def affected_sources(root: Path, changed: set[str]) -> tuple[str, ...]: + """Select paper families and consumers of shared bibliographies.""" + sources = manuscript_sources(root) + if changed & BUILD_INPUTS: + return sources + return tuple( + source for source in sources if any(name.startswith(Path(source).parts[0] + "/") for name in changed) or changed & bibliography_inputs(root, source) + ) + + +def changed_sources(root: Path, event_name: str, event: dict[str, object]) -> tuple[str, ...]: + """Select from GitHub's event revisions without interpolating them into a shell.""" + if event_name == "workflow_dispatch": + return manuscript_sources(root) + if event_name == "pull_request": + pull_request = event["pull_request"] + if not isinstance(pull_request, dict): + raise ValueError("Missing pull request revisions") + base, head = pull_request["base"]["sha"], pull_request["head"]["sha"] + operator = "..." + elif event_name == "push": + base, head = event["before"], event["after"] + operator = ".." + else: + raise ValueError(f"Unsupported paper-build event: {event_name}") + if not all(isinstance(value, str) and re.fullmatch(r"[0-9a-f]{40}", value) for value in (base, head)): + raise ValueError("Build revisions must be full Git commit SHAs") + if base == "0" * 40: + return manuscript_sources(root) + result = run_git_bytes(["--no-pager", "diff", "--name-only", "--no-renames", "-z", f"{base}{operator}{head}", "--"], cwd=root) + changed = {os.fsdecode(name) for name in result.stdout.split(b"\0") if name} + return affected_sources(root, changed) + + +def source_epoch(root: Path, source: str) -> int: + """Use explicit shared dates, or the recorded source commit for legacy TeX.""" + try: + return read_source_date(root / source).source_date_epoch + except ValueError: + # Older records use empty dates, no date, or \\today. Preserve that source. + dates = re.findall(r"(?m)^\s*\\date\{([^}]*)\}", (root / source).read_text(encoding="utf-8")) + if len(dates) > 1 or any(value.strip() not in ("", r"\today") for value in dates): + raise + result = run_git_bytes(["--no-pager", "log", "-1", "--format=%ct", "--", source], cwd=root).stdout.strip() + if not result: + result = run_git_bytes(["--no-pager", "log", "-1", "--format=%ct", "HEAD"], cwd=root).stdout.strip() + return int(result) + + +def build_source(root: Path, source: str) -> None: + """Compile a known manuscript and remove its generated outputs on every exit.""" + if source not in manuscript_sources(root): + raise ValueError(f"Unknown standalone manuscript: {source}") + pilot = source == "delaunay-validation/validation.tex" + output = root / "target/papers" / ("delaunay-validation" if pilot else "changed/" + str(Path(source).with_suffix(""))) + if output.is_symlink() or output.is_junction() or any(parent.is_symlink() or parent.is_junction() for parent in output.parents if parent != root.parent): + raise ValueError("Paper output must not contain a symlink") + try: + shutil.rmtree(output, ignore_errors=True) + if pilot: + run_command_live("just", ["paper-artifact-check"], cwd=root, timeout=900) + return + lint_legacy_source(root, source) + output.mkdir(parents=True) + environment = {**os.environ, "SOURCE_DATE_EPOCH": str(source_epoch(root, source))} + run_command_live( + "uv", + [ + "run", + "--locked", + "--no-sync", + "--no-python-downloads", + "research-repo-tools", + "--root", + str(root), + "--config", + str(root / "tooling/papers.toml"), + "toolchain", + "run", + "--", + "tectonic", + "--untrusted", + "--keep-logs", + "--outdir", + str(output), + source, + ], + cwd=root, + env=environment, + timeout=900, + ) + log = output / (Path(source).stem + ".log") + diagnostics = log.read_text(encoding="utf-8", errors="replace") + bibliography_log = output / (Path(source).stem + ".blg") + bibliography_diagnostics = bibliography_log.read_text(encoding="utf-8", errors="replace") if bibliography_log.exists() else "" + bibliography_failed = re.search(r"There (?:was|were) \d+ error message|I (?:was expecting|couldn't open)", bibliography_diagnostics) + if UNRESOLVED.search(diagnostics) or bibliography_failed: + for line in diagnostics.splitlines(): + if "Warning:" in line or "undefined" in line: + print(line, file=sys.stderr) + if bibliography_diagnostics: + print(bibliography_diagnostics, file=sys.stderr) + raise ValueError(f"Bibliography errors, unresolved references, or duplicate labels in {source}") + inspection = check_pdf(output / (Path(source).stem + ".pdf")) + print(f"Built {source}: {inspection.page_count} pages; removing generated output.") + finally: + try: + log = output / (Path(source).stem + ".log") + if log.is_file(): + report_advisories(source, "LaTeX layout", LAYOUT.findall(log.read_text(encoding="utf-8", errors="replace"))) + finally: + if output.exists(): + shutil.rmtree(output) + + +def main() -> int: + parser = argparse.ArgumentParser(description=__doc__) + commands = parser.add_subparsers(dest="command", required=True) + commands.add_parser("changed", help="print affected source paths as a JSON list") + build = commands.add_parser("build", help="compile selected sources, cleaning output even after failure") + build.add_argument("--all", action="store_true", help="build every standalone TeX manuscript") + build.add_argument("sources", nargs="*") + args = parser.parse_args() + try: + if args.command == "changed": + event = json.loads(Path(os.environ["GITHUB_EVENT_PATH"]).read_text(encoding="utf-8")) + print(json.dumps(changed_sources(ROOT, os.environ["GITHUB_EVENT_NAME"], event))) + else: + sources = list(manuscript_sources(ROOT)) if args.all else args.sources or json.loads(os.environ.get("PAPER_SOURCES_JSON", "[]")) + if not isinstance(sources, list) or any(not isinstance(source, str) for source in sources): + raise ValueError("Selected paper sources must be a JSON list of paths") + if not sources: + raise ValueError("No paper sources were selected") + for source in sources: + build_source(ROOT, source) + except (ExecutableNotFoundError, OSError, ValueError, KeyError, TypeError, subprocess.SubprocessError) as error: + print(format_exception_diagnostics(error), file=sys.stderr) + return 1 + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/scripts/check_paper_inputs.py b/scripts/check_paper_inputs.py new file mode 100644 index 0000000..3330784 --- /dev/null +++ b/scripts/check_paper_inputs.py @@ -0,0 +1,63 @@ +"""Verify the Delaunay pilot's frozen figure inputs without fetching or rendering.""" + +import hashlib +import re +import sys +import tomllib +from pathlib import Path, PurePosixPath + +PAPER = Path(__file__).resolve().parents[1] / "delaunay-validation" +FIGURES = frozenset( + { + "validation_hierarchy.png", + "validation_level_1_element_validity.png", + "validation_level_2_combinatorial_consistency.png", + "validation_level_3_intrinsic_pl_topology.png", + "validation_level_4_valid_realization.png", + "validation_level_5_geometric_predicates.png", + } +) + + +def check_inputs(paper: Path) -> None: + """Reject missing, altered, unrecorded, or incorrectly referenced figures.""" + manifest = tomllib.loads((paper / "inputs.toml").read_text(encoding="utf-8")) + source = manifest["source"] + if manifest["schema"] != 1 or source["repository"] != "https://github.com/acgetchell/delaunay": + raise ValueError("Expected the Delaunay pilot provenance schema") + if not re.fullmatch(r"[0-9a-f]{40}", source["commit"]): + raise ValueError("Scientific source must name a full Git commit SHA") + recorded: set[str] = set() + for entry in manifest["figures"]: + name = PurePosixPath(entry["path"]).name + if name not in FIGURES or entry["path"] != f"figures/{name}" or name in recorded: + raise ValueError(f"Invalid or duplicate figure path: {entry['path']}") + if entry["upstream"] != f"docs/assets/validation/{name}": + raise ValueError(f"Unexpected canonical source path: {entry['upstream']}") + path = paper / "figures" / name + if path.is_symlink() or not path.is_file(): + raise ValueError(f"Missing regular figure input: {name}") + if not re.fullmatch(r"[0-9a-f]{64}", entry["sha256"]) or hashlib.sha256(path.read_bytes()).hexdigest() != entry["sha256"]: + raise ValueError(f"Figure SHA-256 mismatch: {name}") + recorded.add(name) + if recorded != FIGURES or {path.name for path in (paper / "figures").iterdir()} != FIGURES: + raise ValueError("Figure inventory must contain exactly the six recorded Delaunay inputs") + tex = (paper / "validation.tex").read_text(encoding="utf-8") + references = re.findall(r"\\includegraphics(?:\[[^]]*\])?\s*\{([^}]+)\}", tex) + if set(references) != {f"figures/{name}" for name in FIGURES}: + raise ValueError("TeX must reference the six local pinned figures") + + +def main() -> int: + """Report an input error without changing the checkout.""" + try: + check_inputs(PAPER) + except (OSError, ValueError, KeyError, TypeError) as error: + print(f"Paper input check failed: {error}", file=sys.stderr) + return 1 + print("Verified six pinned Delaunay figure inputs; no downloads or experiments.") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/scripts/ci-paper-setup.sh b/scripts/ci-paper-setup.sh new file mode 100644 index 0000000..55b9959 --- /dev/null +++ b/scripts/ci-paper-setup.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# Native prerequisites belong only to the manually dispatched paper build. +set -euo pipefail + +brew install freetype graphite2 icu4c libpng pkgconf zlib +export PATH="/Library/TeX/texbin:$PATH" +echo "/Library/TeX/texbin" >>"$GITHUB_PATH" +if ! command -v chktex >/dev/null; then + if ! command -v tlmgr >/dev/null; then + brew install --cask basictex + fi + texlive_repository="https://ctan.math.illinois.edu/systems/texlive/tlnet" + tlmgr_path="$(command -v tlmgr)" + sudo "$tlmgr_path" --repository "$texlive_repository" update --self + sudo "$tlmgr_path" --repository "$texlive_repository" install chktex +fi +just paper-setup diff --git a/scripts/ci-paper-warmup.sh b/scripts/ci-paper-warmup.sh new file mode 100644 index 0000000..bf16fa6 --- /dev/null +++ b/scripts/ci-paper-warmup.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# Retry only typesetting-bundle acquisition, never scientific input generation. +set -euo pipefail + +warmup_dir="$RUNNER_TEMP/tectonic-warmup" +mkdir -p "$warmup_dir" +printf '%s\n' '\documentclass{article}' '\begin{document}' \ + 'Tectonic bundle cache warmup.' '\end{document}' >"$warmup_dir/warmup.tex" + +for attempt in 1 2 3 4; do + if uv run --locked --no-sync research-repo-tools --root . --config tooling/papers.toml \ + toolchain run -- tectonic --outdir "$warmup_dir" "$warmup_dir/warmup.tex"; then + exit 0 + fi + if [[ "$attempt" -eq 4 ]]; then + echo "::error::Unable to warm Tectonic's bundle cache after $attempt attempts." + exit 1 + fi + sleep "$((attempt * 15))" +done diff --git a/Exported.bib b/shared/bibliography/Exported.bib similarity index 100% rename from Exported.bib rename to shared/bibliography/Exported.bib diff --git a/kp.bst b/shared/bibliography/kp.bst similarity index 100% rename from kp.bst rename to shared/bibliography/kp.bst diff --git a/tests/papers/test_changed_papers.py b/tests/papers/test_changed_papers.py new file mode 100644 index 0000000..2287b75 --- /dev/null +++ b/tests/papers/test_changed_papers.py @@ -0,0 +1,241 @@ +"""Regression evidence for changed-paper selection and failed-build cleanup.""" + +import importlib.util +import subprocess +import sys +from pathlib import Path +from types import SimpleNamespace + +import pytest + +ROOT = Path(__file__).resolve().parents[2] +spec = importlib.util.spec_from_file_location("changed_papers", ROOT / "scripts/build_changed_papers.py") +assert spec is not None and spec.loader is not None +papers = importlib.util.module_from_spec(spec) +spec.loader.exec_module(papers) + + +def test_shared_bibliography_selects_each_consumer() -> None: + selected = set(papers.affected_sources(ROOT, {"newtonian-derivation-cdt/newtonian-derivation-cdt-v2.bib"})) + assert selected == { + "newtonian-derivation-cdt/newtonian-derivation-cdt.tex", + "newtonian-derivation-cdt/newtonian-derivation-cdt-v2.tex", + "newtonian-derivation-cdt/orals-backup.tex", + "weyl-metric-calculations/weyl-metric-calculations.tex", + } + + +def test_figure_change_selects_its_paper() -> None: + assert papers.affected_sources(ROOT, {"efficient-cdt/Parallel_Transport.pdf"}) == ("efficient-cdt/EfficientCDT.tex",) + + +def test_documentation_only_change_selects_no_papers() -> None: + assert papers.affected_sources(ROOT, {"CONTRIBUTING.md", "SECURITY.md"}) == () + + +@pytest.mark.parametrize("changed_input", ["justfile", "tooling/papers.toml"]) +def test_build_tooling_change_selects_all_standalone_sources(changed_input: str) -> None: + selected = papers.affected_sources(ROOT, {changed_input}) + assert set(selected) == set(papers.manuscript_sources(ROOT)) + assert len(selected) == 9 + + +def test_manual_dispatch_selects_all_sources() -> None: + assert papers.changed_sources(ROOT, "workflow_dispatch", {}) == papers.manuscript_sources(ROOT) + + +def test_untrusted_revision_cannot_be_passed_to_git() -> None: + with pytest.raises(ValueError, match="full Git commit SHAs"): + papers.changed_sources(ROOT, "push", {"before": "--output=/tmp/attack", "after": "a" * 40}) + + +def test_invalid_explicit_date_does_not_fall_back_to_legacy_timestamp(tmp_path: Path) -> None: + (tmp_path / "paper.tex").write_bytes(b"\\documentclass{article}\n\\date{February 30, 2026}\n") + with pytest.raises(ValueError, match="invalid paper calendar date"): + papers.source_epoch(tmp_path, "paper.tex") + + +@pytest.mark.parametrize( + ("selection", "expected"), + [ + (None, "No paper sources were selected"), + ("[]", "No paper sources were selected"), + ("{}", "Selected paper sources must be a JSON list of paths"), + ("null", "Selected paper sources must be a JSON list of paths"), + ('"paper.tex"', "Selected paper sources must be a JSON list of paths"), + ('["paper.tex", 1]', "Selected paper sources must be a JSON list of paths"), + ], +) +def test_build_rejects_invalid_selection_before_compilation( + selection: str | None, expected: str, monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str] +) -> None: + monkeypatch.setattr(sys, "argv", ["build_changed_papers.py", "build"]) + if selection is None: + monkeypatch.delenv("PAPER_SOURCES_JSON", raising=False) + else: + monkeypatch.setenv("PAPER_SOURCES_JSON", selection) + monkeypatch.setattr(papers, "build_source", lambda root, source: pytest.fail("Rejected selections must not start compilation")) + + assert papers.main() == 1 + captured = capsys.readouterr() + assert captured.out == "" + assert captured.err == expected + "\n" + + +def test_build_all_rejects_empty_inventory(monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]) -> None: + monkeypatch.setattr(sys, "argv", ["build_changed_papers.py", "build", "--all"]) + monkeypatch.setattr(papers, "manuscript_sources", lambda root: ()) + monkeypatch.setattr(papers, "build_source", lambda root, source: pytest.fail("An empty inventory must not start compilation")) + + assert papers.main() == 1 + captured = capsys.readouterr() + assert captured.out == "" + assert captured.err == "No paper sources were selected\n" + + +def test_build_accepts_nonempty_selection(monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]) -> None: + selected: list[str] = [] + monkeypatch.setattr(sys, "argv", ["build_changed_papers.py", "build"]) + monkeypatch.setenv("PAPER_SOURCES_JSON", '["paper.tex"]') + monkeypatch.setattr(papers, "build_source", lambda root, source: selected.append(source)) + + assert papers.main() == 0 + assert selected == ["paper.tex"] + captured = capsys.readouterr() + assert captured.out == captured.err == "" + + +def test_failed_typesetting_cleans_output_and_preserves_source(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None: + source = tmp_path / "legacy/paper.tex" + source.parent.mkdir() + payload = b"\\documentclass{article}\n\\date{July 6, 2026}\n\\begin{document}Test\\end{document}\n" + source.write_bytes(payload) + monkeypatch.setattr(papers, "manuscript_sources", lambda root: ("legacy/paper.tex",)) + monkeypatch.setattr(papers, "run_command", lambda *args, **kwargs: subprocess.CompletedProcess(args, 0, "", "")) + summary = tmp_path / "summary.md" + monkeypatch.setenv("GITHUB_STEP_SUMMARY", str(summary)) + + def fail_compiler(binary: str, arguments: list[str], *, cwd: Path, env: dict[str, str], timeout: int) -> int: + output = Path(arguments[arguments.index("--outdir") + 1]) + (output / "paper.aux").write_bytes(b"incomplete build") + (output / "paper.log").write_text("Overfull \\hbox (3pt too wide) at lines 4--5\n", encoding="utf-8") + raise subprocess.CalledProcessError(1, [binary, *arguments]) + + monkeypatch.setattr(papers, "run_command_live", fail_compiler) + with pytest.raises(subprocess.CalledProcessError): + papers.build_source(tmp_path, "legacy/paper.tex") + assert source.read_bytes() == payload + assert not any(path.is_file() for path in (tmp_path / "target/papers").rglob("*")) + assert "Overfull \\hbox (3pt too wide) at lines 4--5" in summary.read_text(encoding="utf-8") + + +@pytest.mark.parametrize("lint_exit", [0, 2, 3]) +def test_legacy_findings_and_layout_warnings_are_advisory_and_cleaned( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str], lint_exit: int +) -> None: + source = tmp_path / "legacy/paper.tex" + source.parent.mkdir() + payload = b"\\documentclass{article}\n\\date{July 6, 2026}\n" + source.write_bytes(payload) + monkeypatch.setattr(papers, "manuscript_sources", lambda root: ("legacy/paper.tex",)) + summary = tmp_path / "summary.md" + monkeypatch.setenv("GITHUB_STEP_SUMMARY", str(summary)) + + def lint(binary: str, arguments: list[str], **kwargs: object) -> subprocess.CompletedProcess[str]: + assert binary == "chktex" + assert arguments[-1] == source.name + assert kwargs["cwd"] == source.parent + return subprocess.CompletedProcess([binary, *arguments], lint_exit, "paper.tex:2:1: Warning 13: bad spacing\n::error::