Skip to content

docs(manual): doc generator and drift checks, the chapter template, and the setup-environment chapter (#178 PR 2) - #204

Merged
mmcky merged 2 commits into
mainfrom
claude/stoic-newton-u867m9
Sep 28, 2026
Merged

mmcky merged 2 commits into
mainfrom
claude/stoic-newton-u867m9

Conversation

@quantecon-services

Copy link
Copy Markdown
Collaborator

Closes #189. PR 2 of the user manual (#178), built to decisions 3 and 5.

What's in it

scripts/generate-docs.py (Python 3 + PyYAML)

  • Writes three things from each action.yml, between <!-- BEGIN GENERATED: … --> and <!-- END GENERATED --> markers:
    • each chapter's Inputs and Outputs tables;
    • each signpost README, in full, once the action has a chapter;
    • the action table in docs/user/README.md.
  • --check prints the diff and fails. It also fails on broken markers: a missing END, an unknown or duplicated block, or a missing required block.
  • It also fails on a chapter with no action, an action missing from the script's order list, and ${{/< outside backticks in a description.
  • Actions without a chapter are listed, and their row in the index links to the existing README. docs(manual): chapters for the remaining seven actions, and delete QUICK-REFERENCE.md #190 turns that into an error.

--check-examples reads every yaml block under docs/user and every templates/*.yml. It fails when:

  • a block doesn't parse;
  • a quantecon/actions/<x>@… step passes an input its action.yml doesn't declare, or leaves out a required one;
  • a complete workflow (on: + jobs:) has no permissions:, either at the top or on every job;
  • a block has jobs: but no on:. Such a block is neither complete nor a fragment, and would otherwise escape the lint.

With --actionlint, each complete workflow is linted. Doc blocks are passed through -stdin-filename with padding, so actionlint's messages point at the chapter's real path and line.

Harness gate. Three new steps sit beside the template pin-drift check, because a docs-only PR skips every other job:

  • PyYAML is pinned in scripts/requirements.txt and installed into a venv, since the runner's Python is externally managed. A new Dependabot pip entry keeps it current.
  • actionlint 1.7.12 is a release download checked against its SHA-256. No Dependabot ecosystem tracks it, so the workflow comment says to bump it by hand.
  • Checkout in the gate now sets persist-credentials: false, since the gate now runs repo scripts and needs no git credentials.
  • IGNORED gains the generator and its requirements file: no gated job uses them, and the gate's own checks are their test. The self-test samples scripts/generate-docs.py.

Docs

  • docs/user/README.md: the manual's index. It carries the audience and 0.x note (decision 1), the version note (decision 7), and the generated action table.
  • docs/user/actions/setup-environment.md: the first chapter. It absorbs the old README. It covers both modes, requirements, a minimal container example and a standard-runner example (both complete, linted workflows), the delta file, links to the templates, behaviour (cache keys and what fails the job), running on your own host (the GPU AMI), and troubleshooting keyed to the action's messages.
  • setup-environment/README.md: now a generated signpost.
  • docs/dev/CHAPTER-TEMPLATE.md: the chapter template. It holds the rules, what the gate checks, how to run it locally, and a skeleton. It sits in docs/dev so it stays out of the published manual and out of the example checks.

Corrections to setup-environment/action.yml

Decision 5.1 makes the descriptions the single source, so they are rewritten for readers. Checking them against the code found three that were wrong:

  • conda-cache-hit said "always false in container mode". It is actually empty there, because the cache step is skipped. It is also empty on a cache miss, and 'false' only on a restore-keys match; that is what actions/cache v6's restoreImpl.ts does.
  • environment-name said it "must match name in environment.yml". In fact conda env update -n overrides the file's name:.
  • cache-version said "bump to force a rebuild". It doesn't: the restore-keys prefixes don't include it, so a bump still restores the previous environment, and conda env update --prune then adjusts it. The description, the chapter and QUICK-REFERENCE's two "bump cache-version" tips now say this. The chapter gives the real fix: delete the conda- caches.

This PR changes no behaviour. If a bump should give a fresh environment, cache-version would need to go into the restore-keys. That is an action change for its own issue.

Testing

Run locally with PyYAML 6.0.3, actionlint v1.7.12 built from source, and shellcheck 0.11.0:

  • python3 scripts/generate-docs.py --check --check-examples --actionlint … passes: 3 generated files are current, 16 quantecon/actions steps and 6 complete workflows are checked, and actionlint is clean.
  • Negative cases, each run in a scratch copy, all fail with the right file and line:
    • drift after an action.yml edit, and a hand-edited signpost;
    • an unknown input in the chapter, and a missing required input in templates/ci.yml;
    • a workflow without permissions:, and a block with jobs: but no on:;
    • a uses: with no @ref, an action that doesn't exist, and a YAML parse error;
    • an actionlint runner-label finding, and a shellcheck finding reported through actionlint;
    • a missing END marker, an unknown block, and a removed block;
    • <…> outside backticks, a chapter with no action, and an action missing from ORDER.
  • Write mode regenerates, and --check then passes.
  • The gate's IGNORED self-test, re-run locally, still passes. This PR's own non-ignored files are test-actions.yml and setup-environment/action.yml, so the full harness runs.
  • Not reproducible here: the actionlint download itself. Release assets are blocked in my sandbox, so the checksum comes from the aqua checksum records in aquaproj/aqua and suzuki-shunsuke/pinact, which agree. The gate's sha256sum --check is the first real verification against the GitHub release. If it fails, it fails closed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FeKTxWtkzVMyPbqeSgM2Tb


Generated by Claude Code

…nd the setup-environment chapter (#178 PR 2)

Closes #189.

- scripts/generate-docs.py (Python 3 + PyYAML) writes each chapter's
  Inputs and Outputs tables, each signpost README and the action table
  in docs/user/README.md from action.yml, between BEGIN GENERATED /
  END GENERATED markers. --check prints the diff and fails.
- --check-examples reads every yaml block in docs/user and every
  template: each quantecon/actions step passes only declared inputs and
  every required one, each complete workflow sets permissions:, a block
  with jobs: but no on: is refused, and with --actionlint each complete
  workflow must pass actionlint. Doc blocks go to actionlint through
  -stdin-filename, padded, so its messages carry the chapter's path and
  line numbers.
- The harness gate runs both, beside the template pin check: a
  docs-only PR skips every other job. PyYAML is pinned in
  scripts/requirements.txt (new Dependabot pip entry); actionlint 1.7.12
  is a release download checked against its SHA-256. The gate's
  checkout no longer persists credentials, since it now runs repo
  scripts, and the generator and its requirements file join IGNORED.
- docs/user/README.md (the manual's index), the setup-environment
  chapter, and docs/dev/CHAPTER-TEMPLATE.md. setup-environment/README.md
  is now a generated signpost.
- setup-environment's action.yml descriptions are rewritten for the
  manual and corrected: conda-cache-hit is empty, not 'false', in
  container mode and on a miss; environment-name overrides the file's
  name: rather than having to match it; and bumping cache-version does
  not give a fresh environment, because restore-keys still restores the
  previous cache. QUICK-REFERENCE's advice to bump it now says so.
- CONTRIBUTING, README, CHANGELOG, TESTING and PLAN point at the manual
  and the new checks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FeKTxWtkzVMyPbqeSgM2Tb
@mmcky
mmcky requested a balanced review from Copilot September 28, 2026 05:00
quantecon-services pushed a commit that referenced this pull request Sep 28, 2026
…vironment (#205)

cache-version was in the exact cache key but in neither restore-keys
fallback, and the first fallback matched the same environment file
under any version. So a bump restored the previous version's
environment and ran `conda env update` on it, never a fresh build. The
previous commit's harness job shows it: the bumped key missed, fallback
1 restored env-seed's ...-v1 cache, and conda-cache-hit was 'false'.

cache-version now comes before the Python version and the file hash,
and the key has one fallback, which includes it:

  key:      conda-<os>-<name>-<cache-version>-py<python>-<hash>
  fallback: conda-<os>-<name>-<cache-version>-py<python>-

An edit to the environment file still restores the latest environment
of the same version and updates it; a bump, a Python change or a name
change restores nothing. The key format changes, so the first
standard-mode run after the release builds from scratch once. No
current consumer runs setup-environment in standard mode.

- cache-version and conda-cache-hit descriptions, and the chapter's
  generated table, cache-key table and troubleshooting, follow.
- QUICK-REFERENCE's advice to bump cache-version is right again, so
  #204's notes against it are reverted; only its key format changes.
- CHANGELOG: a Fixed entry, and #204's Documentation entry no longer
  describes the old behaviour. TESTING's coverage row and PLAN follow.
- The bjc-smoke comment no longer assumes @v0 shares the key format.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FeKTxWtkzVMyPbqeSgM2Tb

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

It adds a 501-line generator and modifies the required harness gate with an external checksum-pinned actionlint download I cannot verify in this sandbox, so a human should confirm the gate passes before merge.

Review effort: Balanced
Findings: None

What changed in this PR

This is PR 2 of the QuantEcon Actions user manual (#178, closing #189). It introduces the documentation generator and CI drift/example checks, the chapter-writing template, and the first manual chapter (setup-environment). The manual's reference tables and signpost READMEs are generated from each action.yml so they cannot drift (the recurrence of #109), and every example workflow is checked against the real action inputs, for a permissions: block, and with actionlint — all wired into the harness gate job so that even docs-only PRs (which skip every gated job) are still verified.

Changes:

  • New scripts/generate-docs.py (+ pinned PyYAML in scripts/requirements.txt) that generates chapter Inputs/Outputs tables, signpost READMEs and the index action table between BEGIN/END GENERATED markers, and validates YAML examples (inputs, required inputs, permissions:, and optional actionlint).
  • Rewrites setup-environment/action.yml input/output descriptions for readers, correcting three factual errors (conda-cache-hit is empty—not false—in container mode/on a miss; environment-name overrides the file's name:; cache-version bumps do not force a fresh environment).
  • Adds the setup-environment chapter, index, chapter template, gate steps (venv PyYAML + checksum-pinned actionlint 1.7.12, persist-credentials: false), a Dependabot pip entry, and supporting doc/CHANGELOG updates.
File Description
scripts/​generate-docs.py New generator + example/drift/actionlint checker
scripts/​requirements.txt Pins PyYAML for the generator
setup-environment/​action.yml Reader-facing, corrected input/output descriptions
setup-environment/​README.md Reduced to a generated signpost
docs/​user/​README.md New manual index with generated action table
docs/​user/​actions/​setup-environment.md First manual chapter (verified accurate vs. runs:)
docs/​dev/​CHAPTER-TEMPLATE.md Template and rules for authoring chapters
docs/​QUICK-REFERENCE.md Corrects the cache-version guidance, links to chapter
docs/​dev/​README.md, docs/​dev/​TESTING.md, docs/​dev/​PLAN.md Cross-links and status updates
README.md, CONTRIBUTING.md, CHANGELOG.md Point docs workflow at the generated manual
.github/​workflows/​test-actions.yml Gate runs the docs checks; adds actionlint/venv tooling; persist-credentials: false; extends IGNORED
.github/​dependabot.yml New pip ecosystem entry for scripts/

I verified: the three action.yml corrections against the actual composite steps; that build-lectures exposes a builder input and no action used in examples has required inputs; that the committed generated blocks (signpost, tables, index) exactly match the generator's output; that all cross-doc links resolve; and that the generator's node-based key access sidesteps the YAML on:→boolean pitfall. I found no objective defects to comment on.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@mmcky
mmcky merged commit 98881f2 into main Sep 28, 2026
25 checks passed
@mmcky
mmcky deleted the claude/stoic-newton-u867m9 branch September 28, 2026 05:12
quantecon-services pushed a commit that referenced this pull request Sep 28, 2026
…vironment (#205)

cache-version was in the exact cache key but in neither restore-keys
fallback, and the first fallback matched the same environment file
under any version. So a bump restored the previous version's
environment and ran `conda env update` on it, never a fresh build. The
previous commit's harness job shows it: the bumped key missed, fallback
1 restored env-seed's ...-v1 cache, and conda-cache-hit was 'false'.

cache-version now comes before the Python version and the file hash,
and the key has one fallback, which includes it:

  key:      conda-<os>-<name>-<cache-version>-py<python>-<hash>
  fallback: conda-<os>-<name>-<cache-version>-py<python>-

An edit to the environment file still restores the latest environment
of the same version and updates it; a bump, a Python change or a name
change restores nothing. The key format changes, so the first
standard-mode run after the release builds from scratch once. No
current consumer runs setup-environment in standard mode.

- cache-version and conda-cache-hit descriptions, and the chapter's
  generated table, cache-key table and troubleshooting, follow.
- QUICK-REFERENCE's advice to bump cache-version is right again, so
  #204's notes against it are reverted; only its key format changes.
- CHANGELOG: a Fixed entry, and #204's Documentation entry no longer
  describes the old behaviour. TESTING's coverage row and PLAN follow.
- The bjc-smoke comment no longer assumes @v0 shares the key format.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FeKTxWtkzVMyPbqeSgM2Tb
mmcky pushed a commit that referenced this pull request Sep 28, 2026
…vironment (#205) (#206)

* test(setup-environment): a cache-version bump must build a fresh environment (#205)

A new harness job, env-version-bump, runs after env-seed on the same
salted fixture with a salted cache-version, and asserts that
conda-cache-hit is empty: nothing restored. On the current key layout
it fails by design. Fallback 1, conda-<os>-<name>-py<ver>-<hash>-,
omits cache-version, so it restores env-seed's cache and the output is
'false'. The fix follows in the next commit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FeKTxWtkzVMyPbqeSgM2Tb

* fix(setup-environment): bumping cache-version builds a fresh Conda environment (#205)

cache-version was in the exact cache key but in neither restore-keys
fallback, and the first fallback matched the same environment file
under any version. So a bump restored the previous version's
environment and ran `conda env update` on it, never a fresh build. The
previous commit's harness job shows it: the bumped key missed, fallback
1 restored env-seed's ...-v1 cache, and conda-cache-hit was 'false'.

cache-version now comes before the Python version and the file hash,
and the key has one fallback, which includes it:

  key:      conda-<os>-<name>-<cache-version>-py<python>-<hash>
  fallback: conda-<os>-<name>-<cache-version>-py<python>-

An edit to the environment file still restores the latest environment
of the same version and updates it; a bump, a Python change or a name
change restores nothing. The key format changes, so the first
standard-mode run after the release builds from scratch once. No
current consumer runs setup-environment in standard mode.

- cache-version and conda-cache-hit descriptions, and the chapter's
  generated table, cache-key table and troubleshooting, follow.
- QUICK-REFERENCE's advice to bump cache-version is right again, so
  #204's notes against it are reverted; only its key format changes.
- CHANGELOG: a Fixed entry, and #204's Documentation entry no longer
  describes the old behaviour. TESTING's coverage row and PLAN follow.
- The bjc-smoke comment no longer assumes @v0 shares the key format.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FeKTxWtkzVMyPbqeSgM2Tb

---------

Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs(manual): doc generator and drift checks, the chapter template, and the setup-environment chapter

4 participants