Skip to content

ci: component-aware pre-commit hook for the monorepo - #959

Merged
AnthonyRonning merged 2 commits into
masterfrom
ci/monorepo-precommit-hook
Sep 17, 2026
Merged

AnthonyRonning merged 2 commits into
masterfrom
ci/monorepo-precommit-hook

Conversation

@AnthonyRonning

@AnthonyRonning AnthonyRonning commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Replaces the Research-only .githooks/pre-commit with a monorepo-aware hook:

  • .githooks/pre-commit classifies staged paths with the new scripts/ci/hook_change_detection.py and runs each affected component's own .githooks/pre-commit inside that component's Nix flake (root .#ci for Research, updates and repo checks; the apps/maple-agent, sdk, proxy and services/opensecret?submodules=1 flakes for the rest). Without Nix it runs the same commands from PATH and warns that results may differ.
  • Per component it mirrors the credential-free lint/test lanes of the workflows:
    • apps/maple-research: bun run format:check|lint|typecheck|test; src-tauri cargo fmt --check + cargo test --locked --all-targets (CI runs no Clippy there, and -D warnings fails on the vendored patches/ crates).
    • apps/maple-agent: cargo fmt, one workspace Clippy pass, workspace tests. MAPLE_HOOK_FULL=1 runs the full just ci.
    • sdk: Rust fmt/clippy/cargo test --lib/doc; TypeScript prettier, build, top-level unit tests.
    • proxy: fmt, clippy, test, doc, cargo machete (same as proxy-rust.yml).
    • services/opensecret: fmt, clippy, test with OPENSECRET_DEV_POSTGRES/ENV/CONTAINERS=0; refuses with instructions when the submodules are not checked out.
    • services/updates: prettier, tsc, bun test.
    • repo: actionlint on staged workflows and the scripts/ci unit tests.
  • Integration suites, cargo-deny, bun audit, nix flake check, wrangler dry-run and packaging stay in CI. Shared crates (proxy, Rust SDK) do not fan out to their consumers.
  • The orchestrator unsets git's hook environment (GIT_INDEX_FILE, GIT_DIR, ...) before running component checks and guards against re-entry, so nested git commands in the scripts/ci tests operate on their own fixture repositories, never on the committing checkout.
  • Knobs: MAPLE_HOOK_SKIP=1, MAPLE_HOOK_FULL=1, MAPLE_HOOK_NO_NIX=1, MAPLE_HOOK_ONLY=a,b.

Also in this PR:

  • Deletes the dead sdk/setup-hooks.sh and the legacy SDK hook (it grepped ^rust/ and could never have run from the monorepo root).
  • Marks the new component .githooks/ directories inert in the three CI classifiers, with tests, and wires test_hook_change_detection.py into the flake change-detection check.
  • test_opensecret_workflows.py compares resolved paths so it passes on macOS (/tmp vs /private/tmp).
  • Documents the hook in AGENTS.md (new "Pre-commit hook" section), README, the Research/OpenSecret/Agent guides and the affected skills; setup-hooks.sh prints the new summary.

Verification

Each component was run through the real hook in its Nix shell on macOS:

Component Result
repo, updates, sdk_ts, sdk_rust, proxy, opensecret, research_frontend, research_rust pass
nix build .#checks.<system>.change-detection pass
maple-agent (just ci) pass, after the fixture fix below

The PR commit itself was made through the hook (repo checks ran under git's real hook environment). Docs-only staged sets select nothing; the no-Nix fallback reports the missing tool clearly.

Agent test fix

apps/maple-agent test targets did not compile on master: ExternalAgentHost takes runtime: AgentRuntimeHandle since the account scope moved into the handle, but the Codex integration test still set the removed account_scope field. The second commit fixes the fixture; just ci (the full Linux matrix) passes locally on macOS. The hook caught this on the first local run, which is the point of the PR.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Maple development preview: https://74d06e16.maple-ca8.pages.dev

Commit: 7ce063cc10c72d2276106daf0e605b8e20cf7dce

Uses development API, billing, flags and PCR configuration. Cloudflare Access applies.

AnthonyRonning and others added 2 commits September 17, 2026 02:42
Replace the Research-only pre-commit hook with an orchestrator that
classifies staged paths (scripts/ci/hook_change_detection.py) and runs each
affected component's own .githooks/pre-commit inside that component's Nix
flake, so local checks use the same pinned tools as CI. Without Nix the
same commands run from PATH with a warning.

Per component the hook mirrors the credential-free lint/test lanes of the
workflows: Research prettier/eslint/tsc/bun test and src-tauri fmt/tests;
Agent fmt, workspace clippy and tests (MAPLE_HOOK_FULL=1 runs `just ci`);
SDK Rust fmt/clippy/--lib tests/doc and TypeScript prettier/build/unit
tests; proxy fmt/clippy/test/doc/machete; OpenSecret fmt/clippy/test with
the dev-shell hooks disabled; updates prettier/tsc/test; actionlint and
the scripts/ci unit tests for repository inputs. Integration suites,
cargo-deny, nix flake check and packaging stay in CI. Shared crates do
not fan out to their consumers. Git's hook environment (GIT_INDEX_FILE,
GIT_DIR, ...) is unset before the checks run so nested git commands in
tests never touch the committing checkout.

Also: delete the dead sdk/setup-hooks.sh and legacy SDK hook, mark the new
component hook directories inert in the CI classifiers, wire the new
classifier tests into the flake check, compare resolved paths in
test_opensecret_workflows so it passes on macOS, and document the hook in
AGENTS.md, the component guides and skills.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
ExternalAgentHost takes a `runtime: AgentRuntimeHandle` since the account
scope moved into the handle, but the Codex integration test still set the
removed `account_scope` field, so the maple-agent test target no longer
compiled on any platform.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@AnthonyRonning
AnthonyRonning force-pushed the ci/monorepo-precommit-hook branch from f29561a to 7ce063c Compare September 17, 2026 02:42
@AnthonyRonning
AnthonyRonning merged commit 5efc18d into master Sep 17, 2026
35 checks passed
@AnthonyRonning
AnthonyRonning deleted the ci/monorepo-precommit-hook branch September 17, 2026 03:32

This branch was successfully deployed

1 active deployment
pages-pr-959 — 7ce063cc Deployed Sep 17, 2026 by github-actions[bot]
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.

1 participant