Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# The two standard copies are byte-identical files: standards/core.md is shared
# between five owner repositories and scripts/core-drift.ts is copied from the
# standards directory. `just core-drift` compares core.md by hash, and formatting
# either file would break that comparison.
# The verbatim copies are byte-identical files: standards/core.md and
# hooks/core.yml are shared between five owner repositories and
# scripts/core-drift.ts is copied from the standards directory. `just core-drift`
# compares both shared files by hash, and formatting one would break it.
standards/core.md
hooks/core.yml
scripts/core-drift.ts
80 changes: 80 additions & 0 deletions hooks/core.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# hooks/core.yml — byte-identical in the five owner .github repositories.
# Loaded by each repository's lefthook.yml through `remotes` at a pinned tag.
# Dispatcher only: every job calls a `just` recipe from the contract in
# standards/core.md C7.8. Repository jobs use their own names and never
# redefine a job named here.
min_version: 2.2.2
assert_lefthook_installed: true
glob_matcher: doublestar
skip_lfs: true

pre-commit:
parallel: true
jobs:
- name: core-fmt
glob: "**/*.{ts,tsx,js,jsx,mjs,cjs,mts,cts,json,jsonc,yml,yaml,md,toml,css,html}"
run: just fmt {staged_files}
stage_fixed: true
fail_text: "Formatting could not be applied; run `just fmt` and read the error."

- name: core-lint
glob: "**/*.{ts,tsx,js,jsx,mjs,cjs,mts,cts}"
run: just lint {staged_files}
fail_text: "Lint failed on staged files; fix the findings and stage again."

- name: core-secrets
run: just secrets-staged
fail_text: "A staged secret was found. Remove it; if it was ever pushed, rotate it."

- name: core-forbidden-files
run: just forbidden-files {staged_files}
fail_text: "A forbidden or oversized file is staged (env file, key, kubeconfig, >5 MB)."

- name: core-whitespace
run: git diff --cached --check
fail_text: "Staged whitespace errors or conflict markers; fix them and stage again."

- name: core-workflows
glob: ".github/workflows/*.{yml,yaml}"
run: just workflows {staged_files}
fail_text: "actionlint or zizmor rejected a workflow."

- name: core-shell
glob: "**/*.{sh,bash}"
run: just shellcheck {staged_files}
fail_text: "shellcheck findings in staged shell scripts."

- name: core-agent-files
glob:
- "AGENTS.md"
- ".agents/**"
- ".claude/**"
run: just agent-files
fail_text: "Agent files are inconsistent (C8.3); run `just agent-files`."

commit-msg:
jobs:
- name: core-conventional
run: just commit-msg {1}

pre-push:
piped: true
jobs:
- name: core-policy
use_stdin: true
run: just hook-pre-push
fail_text: "Push refused. main changes only through a pull request (C2.1), or the pushed range failed the secret scan."

- name: core-fast-check
run: just pre-push-check
fail_text: "Fast pre-push checks failed; run `just check` for the full set."

post-checkout:
jobs:
- name: core-deps-refresh
run: just deps-refresh

post-merge:
jobs:
- name: core-deps-refresh
run: just deps-refresh
12 changes: 12 additions & 0 deletions hooks/owner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# hooks/owner.yml — deathpie owner hook jobs. Loaded with hooks/core.yml via remotes.
# Every job calls a `just` recipe listed in standards/owner.md. Repository jobs
# never reuse an `owner-*` name.
pre-commit:
jobs:
- name: owner-privacy-identity
run: just privacy-identity
fail_text: "The author or committer email is not the owner's GitHub no-reply address."

- name: owner-privacy-staged
run: just privacy-staged
fail_text: "A staged blob contains private material. Remove it and stage again."
30 changes: 17 additions & 13 deletions scripts/core-drift.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bun
// Compares standards/core.md across the five owner .github repositories.
// Compares standards/core.md and hooks/core.yml across the five owner .github repositories.
// Runs locally only: it needs gh logged in as both deathpie and simpsonm09,
// because no single token can read every owner (homelab's .github is private).
// gh runs from the temp directory so the per-owner gh wrapper picks the token
Expand All @@ -18,19 +18,23 @@ function run(cmd: string[]): string {
return p.stdout.toString();
}

const local = sha(readFileSync("standards/core.md", "utf8"));
const files = ["standards/core.md", "hooks/core.yml"];
let drift = false;
for (const owner of owners) {
let hash: string;
try {
const body = run(["gh", "api", "-H", "Accept: application/vnd.github.raw", `repos/${owner}/.github/contents/standards/core.md`]);
hash = sha(body);
} catch (error) {
hash = `unreadable (${(error as Error).message.split("\n")[0]})`;
for (const file of files) {
const local = sha(readFileSync(file, "utf8"));
console.log(file);
for (const owner of owners) {
let hash: string;
try {
const body = run(["gh", "api", "-H", "Accept: application/vnd.github.raw", `repos/${owner}/.github/contents/${file}`]);
hash = sha(body);
} catch (error) {
hash = `unreadable (${(error as Error).message.split("\n")[0]})`;
}
const same = hash === local;
if (!same) drift = true;
console.log(` ${same ? "ok " : "DRIFT"} ${owner.padEnd(22)} ${hash}`);
}
const same = hash === local;
if (!same) drift = true;
console.log(`${same ? "ok " : "DRIFT"} ${owner.padEnd(22)} ${hash}`);
console.log(` local ${local}`);
}
console.log(`local ${local}`);
process.exit(drift ? 1 : 0);
40 changes: 39 additions & 1 deletion standards/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ This file is byte-identical in every owner's `.github` repository:
`deathpie/.github`, `simpsonm09/.github`, `sakuragaoka-homelab/.github`,
`awepeeps/.github` and `simpsonm09-projects/.github`, at `standards/core.md`.
Change it in one pull request per owner, with the same content, or not at all.
`just core-drift` in any of those repositories compares the five copies.
`just core-drift` in any of those repositories compares the five copies of
this file and of `hooks/core.yml`.

Each owner adds `standards/owner.md`. An owner standard may tighten any rule
here. It may loosen only a rule marked **(profile)**, and it says how.
Expand Down Expand Up @@ -129,6 +130,43 @@ without a reason or a date is drift.
standard toolchain behind the same recipe names.
- C7.7 `.editorconfig` is present. `.gitattributes` contains
`* text=auto eol=lf`.
- C7.8 Git hooks run through Lefthook, pinned in `mise.toml` as
`"aqua:evilmartians/lefthook"`. Each owner's `.github` repository holds
`hooks/core.yml` (byte-identical across owners) and `hooks/owner.yml`
(owner jobs named `owner-*`), released as an annotated tag `hooks-v<N>`.
A repository's `lefthook.yml` loads both through `remotes` at that tag and
adds its own jobs under names that never start with `core-` or `owner-`.
`just hooks` removes a local `core.hooksPath` only when it equals
`.githooks`, refuses any other value or a global one, runs
`lefthook install`, and then asserts that `lefthook dump` contains the
`core-*` and `owner-*` jobs, because a failed remote fetch only warns.
`lefthook-local.yml` is git-ignored.
- C7.9 CI has a `hooks` job: `lefthook install`, the same `lefthook dump`
assertion, then `lefthook validate` (which does not fetch remotes on its
own).
- C7.10 The hook recipe contract. Every repository defines these recipes; a
recipe with nothing to do exits 0. Variadic recipes need
`set positional-arguments`.

| Recipe | Hook | Does |
| --- | --- | --- |
| `fmt *files` | pre-commit | formats the given files (all when none); fixes are re-staged |
| `lint *files` | pre-commit | lints the given files, check only |
| `secrets-staged` | pre-commit | `gitleaks git --staged --redact` |
| `forbidden-files *files` | pre-commit | rejects `.env*` except `*.example`, `*.pem`, `*.key`, `id_*`, kubeconfig, files over 5 MB |
| `workflows *files` | pre-commit | `actionlint` and `zizmor` |
| `shellcheck *files` | pre-commit | `shellcheck` |
| `agent-files` | pre-commit | C8.3 |
| `commit-msg file` | commit-msg | warns when the subject is not a Conventional Commit; never fails |
| `hook-pre-push` | pre-push | reads the pushed ref lines from stdin, refuses `refs/heads/main`, scans the exact pushed range with gitleaks plus the owner's scans |
| `pre-push-check` | pre-push | fast subset: type check and the tests the diff can reach |
| `deps-refresh` | post-checkout, post-merge | `bun install` when `bun.lock` changed, `mise install` when `mise.toml` changed |

Budgets: pre-commit under 3 seconds and pre-push under 30 seconds on a
typical change.
- C7.11 Agents never skip hooks: no `LEFTHOOK=0`, no `--no-verify`, no
`lefthook-local.yml`. Hooks are advisory for humans; rulesets, the
direct-push guard and CI are the enforcement.

## C8. Agent instructions and skills

Expand Down
Loading