DecodeMarketing commited on
Commit
2509f31
Β·
unverified Β·
1 Parent(s): 975d390

[ai-standards][slice-3] agent contracts and audit traceability (shrunk) (#10)

Browse files

Adds the residual agent-contract documentation + standards-sync manifest.
Most of the original slice-3 scope was absorbed by the colleague's earlier
hardening commits (1878a50..c7599a7), which already installed the executable
agent surface (.claude/settings.json, .claude/hooks/, .claude/skills/deslop+tdd,
.githooks/, scripts/setup+language-gate+reviewer-hash). What remains here is
documentation + the standards-sync ledger.

Artifacts:
- .claude/manifests/standards-sync.yaml β€” applied decode-ai-standards ref
(81c3f17), slice ledger (slice 1 PR #7 / slice 2 PR #9 merged on main;
PR #8 dev-mistake noted; slice 2b workflow hardening deferred; this slice
in progress). Operational rule: re-run audit when manifest is older than
30 days or upstream lands audit-affecting commits.
- .claude/skills/check_decode_ai_standards_updates/SKILL.md β€” freshness-check
skill matching the existing .claude/skills/<name>/SKILL.md shape. Read-only:
reads the manifest, fetches upstream HEAD, reports if a refresh is warranted.
Does NOT modify the manifest automatically.
- docs/guides/ci-failure-triage.md β€” per-workflow failure modes (gate.yml
language-gate / override-audit / ci-fail-incident, main.yml HF deploy,
check-file-size.yml LFS warning, repo_validate.yml) plus recovery steps.
Includes HF Space `runtime.stage` poll command for post-deploy verification.
- docs/guides/ai-enablement-limits.md β€” codifies the six intentional limits
(destructive git, secret writes, deploy-critical surface, no-commit-without-
reviewer, no-AI-attribution, root-artifact policy). Pairs with the
executable enforcement in .claude/hooks/ and .githooks/.
- docs/reference/agent-guide.md β€” single starting page for an AI contributor;
names each authoritative file by path; gives a fresh-agent reading order.
- docs/INDEX.md β€” links the three new docs under existing ## reference and
## guides sections; replaces the previously-planned stub with a note that
all planned docs have landed and slice 2b (workflow hardening) is the only
remaining remediation work, which will not add new docs.

Out of scope (deferred):
- Slice 2b β€” SHA-pin actions/checkout and add explicit `permissions:` blocks
on main.yml, gate.yml, check-file-size.yml. Touches the HF deploy pipeline,
so reserved for its own focused PR with full A/B/C verification.

No changes to app code (app.py, helper.py, tab1.py-tab8.py), requirements.txt,
runtime.txt, .streamlit/, .devcontainer/, existing workflows, existing
.githooks/, existing .claude/ files, CLAUDE.md, or .gitignore. HF Spaces
deploy is a no-op for this slice β€” no runtime file touched.

Refs decode-ai-standards@81c3f17.

.claude/manifests/standards-sync.yaml ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # decode-ai-standards sync manifest.
2
+ #
3
+ # Records which version of the org standards repo this repo has been aligned
4
+ # to. Updated whenever a fresh audit + remediation is run.
5
+ #
6
+ # Source repo:
7
+ # https://github.com/implicitdiagnosticsandsolutions/decode-ai-standards
8
+ #
9
+ # Operational rule:
10
+ # - Re-run the readiness checklist whenever this manifest is older than 30
11
+ # days OR a new audit-affecting commit lands on the standards repo.
12
+ # - Use the `check_decode_ai_standards_updates` skill under
13
+ # `.claude/skills/check_decode_ai_standards_updates/SKILL.md` to compare
14
+ # this manifest against the standards repo's current HEAD.
15
+ # - Bump `applied_ref` ONLY after the corresponding audit refresh has
16
+ # produced a new `audit-result.yaml` in the work folder and any new
17
+ # remediation has been merged.
18
+
19
+ manifest_version: 1
20
+ standards_repo: implicitdiagnosticsandsolutions/decode-ai-standards
21
+ applied_ref: "81c3f17"
22
+ applied_at: "2026-05-21"
23
+ applied_to_branch: main
24
+
25
+ alignment_style: wrapping
26
+ # This repo had the DECODE Claude Code hardening gates pre-installed via
27
+ # commits 1878a50..c7599a7 before the formal audit ran. The audit + slice
28
+ # work documented and supplemented that existing surface; it did not start
29
+ # from a greenfield baseline. See docs/progress/slice-integration-overview.md
30
+ # for the slice timeline.
31
+
32
+ slices:
33
+ - id: slice-1
34
+ name: orientation_and_deploy_boundary_slice
35
+ pr: 7
36
+ merge_commit: 7a5c442
37
+ merged_at: "2026-05-21T13:29:43Z"
38
+ status: merged
39
+
40
+ - id: slice-2
41
+ name: structure_and_dependency_slice
42
+ pr: 9
43
+ merge_commit: 975d390
44
+ merged_at: "2026-05-21T15:36:00Z"
45
+ status: merged
46
+ notes: |
47
+ PR #8 was opened against the repo default branch (dev) by mistake and
48
+ landed on dev. PR #9 re-targeted the same commit at main. Both PRs
49
+ are in the GitHub history; only PR #9 is on the production branch.
50
+
51
+ - id: slice-3
52
+ name: agent_contract_slice_shrunk
53
+ pr: null
54
+ merge_commit: null
55
+ merged_at: null
56
+ status: in_progress
57
+ notes: |
58
+ Shrunken because the DECODE hardening commits (1878a50..c7599a7) had
59
+ already installed the executable agent surface (.claude/settings.json,
60
+ .claude/hooks/, .claude/skills/{deslop,tdd}, .githooks/, scripts/).
61
+ Slice 3 covers only the residual documentation + this standards-sync
62
+ manifest + the freshness-check skill.
63
+
64
+ - id: slice-2b
65
+ name: workflow_hardening_slice
66
+ pr: null
67
+ merge_commit: null
68
+ merged_at: null
69
+ status: deferred
70
+ notes: |
71
+ SHA-pin actions/checkout and add `permissions:` blocks on main.yml,
72
+ gate.yml, check-file-size.yml. Touches the HF deploy pipeline, so
73
+ reserved for a dedicated focused PR.
74
+
75
+ work_folder: "C:\\Users\\JulianeMatussek\\decode-ai-standards-work\\icat_app"
76
+ # Audit artifacts (audit-result.yaml, delta-summary.md, remediation-plan.md,
77
+ # slice-integration-overview.md, standards-learning-note.md) live in the
78
+ # work folder, not in this repo, so the public HF Space does not ship them.
.claude/skills/check_decode_ai_standards_updates/SKILL.md ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ name: check_decode_ai_standards_updates
3
+ description: Compare this repo's applied decode-ai-standards ref against the upstream standards repo HEAD. Use when verifying whether a fresh audit refresh is warranted or when the standards-sync manifest is older than 30 days.
4
+ allowed-tools: Read, Bash, WebFetch
5
+ ---
6
+
7
+ # Check decode-ai-standards updates
8
+
9
+ Quick freshness check: is this repo still aligned with the current
10
+ `decode-ai-standards` ref, or has the upstream standards repo moved?
11
+
12
+ ## When to run
13
+
14
+ - The `applied_at` date in `.claude/manifests/standards-sync.yaml` is older
15
+ than 30 days.
16
+ - Someone in the team mentions a new standards update on Slack or in a PR.
17
+ - Before opening a new remediation slice (so the slice references the most
18
+ current standards ref).
19
+
20
+ ## How to run
21
+
22
+ 1. Read `.claude/manifests/standards-sync.yaml` to get the current
23
+ `applied_ref` (e.g. `81c3f17`) and `applied_at` date.
24
+
25
+ 2. Fetch the upstream standards repo HEAD:
26
+
27
+ ```bash
28
+ gh api repos/implicitdiagnosticsandsolutions/decode-ai-standards/commits/main \
29
+ --jq '{sha: .sha[0:7], date: .commit.committer.date, message: .commit.message | split("\n")[0]}'
30
+ ```
31
+
32
+ 3. Compare the upstream SHA against the manifest's `applied_ref`:
33
+
34
+ - **Same SHA** β†’ no action; report "aligned with `<sha>`, applied `<date>`".
35
+ - **Different SHA** β†’ list the commits between the two refs:
36
+
37
+ ```bash
38
+ gh api 'repos/implicitdiagnosticsandsolutions/decode-ai-standards/compare/<applied_ref>...main' \
39
+ --jq '.commits[] | {sha: .sha[0:7], message: .commit.message | split("\n")[0]}'
40
+ ```
41
+
42
+ Inspect the messages. If any commit touches the audit checklist
43
+ (`checklist/ai-readiness-checklist.md`), the playbook
44
+ (`playbook/ai-repository-enhancement-playbook.md`), or the standard
45
+ (`docs/ai-centric-repository-guidelines.md`), report:
46
+
47
+ > **Audit refresh recommended.** Standards repo moved from `<old>` to
48
+ > `<new>` with N audit-affecting commits. Re-run the audit against
49
+ > current `main` HEAD and write a `delta-summary.md` in the work folder.
50
+
51
+ - If only non-audit-affecting commits landed (typos, README tweaks),
52
+ bump `applied_ref` in the manifest without re-running the full audit.
53
+
54
+ ## What this skill does NOT do
55
+
56
+ - Does not modify any file in the repo.
57
+ - Does not bump `applied_ref` automatically. The bump is a human decision
58
+ tied to an actual audit refresh.
59
+ - Does not pull or check out the upstream repo locally.
60
+
61
+ ## See also
62
+
63
+ - `.claude/manifests/standards-sync.yaml` β€” the manifest this skill reads.
64
+ - `docs/progress/slice-integration-overview.md` β€” slice traceability.
docs/INDEX.md CHANGED
@@ -12,12 +12,15 @@ This tree is for **human + AI contributors**. Operational base rules live in `/C
12
  ## reference
13
 
14
  - [`reference/command-registry.md`](reference/command-registry.md) β€” every discoverable command, what it does, where it runs (local / pre-commit / CI).
 
15
 
16
  ## guides
17
 
18
  - [`guides/review-workflow.md`](guides/review-workflow.md) β€” findings-first reviewer contract, `.decode-reviewer-clean` marker, override semantics.
19
  - [`guides/protected-boundary-policy.md`](guides/protected-boundary-policy.md) β€” push-to-main = HF Space deploy; rules around touching the deploy boundary.
20
  - [`guides/git-and-pr-rules.md`](guides/git-and-pr-rules.md) β€” observed branch state, default flow, PR target.
 
 
21
 
22
  ## policies
23
 
@@ -34,8 +37,6 @@ This tree is for **human + AI contributors**. Operational base rules live in `/C
34
 
35
  ## not yet present (planned)
36
 
37
- - `guides/ci-failure-triage.md` β€” slice 3.
38
- - `guides/ai-enablement-limits.md` β€” slice 3.
39
- - `reference/agent-guide.md` β€” slice 3.
40
 
41
  When you add a new doc, link it from this index. If you remove a doc, remove the link too β€” broken links here are a bug.
 
12
  ## reference
13
 
14
  - [`reference/command-registry.md`](reference/command-registry.md) β€” every discoverable command, what it does, where it runs (local / pre-commit / CI).
15
+ - [`reference/agent-guide.md`](reference/agent-guide.md) β€” single starting page for an AI agent: identity, do's, don'ts, reading order.
16
 
17
  ## guides
18
 
19
  - [`guides/review-workflow.md`](guides/review-workflow.md) β€” findings-first reviewer contract, `.decode-reviewer-clean` marker, override semantics.
20
  - [`guides/protected-boundary-policy.md`](guides/protected-boundary-policy.md) β€” push-to-main = HF Space deploy; rules around touching the deploy boundary.
21
  - [`guides/git-and-pr-rules.md`](guides/git-and-pr-rules.md) β€” observed branch state, default flow, PR target.
22
+ - [`guides/ci-failure-triage.md`](guides/ci-failure-triage.md) β€” per-workflow failure modes (gate.yml, main.yml, check-file-size.yml, repo_validate.yml) and recovery steps.
23
+ - [`guides/ai-enablement-limits.md`](guides/ai-enablement-limits.md) β€” where AI agents are intentionally constrained; pairs with `.claude/hooks/` and `.githooks/`.
24
 
25
  ## policies
26
 
 
37
 
38
  ## not yet present (planned)
39
 
40
+ (All previously-planned docs have landed. The next remediation work is the deferred slice 2b β€” workflow SHA pinning + `permissions:` blocks. That slice will not add new docs to this index; it will edit existing CI workflow files.)
 
 
41
 
42
  When you add a new doc, link it from this index. If you remove a doc, remove the link too β€” broken links here are a bug.
docs/guides/ai-enablement-limits.md ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AI enablement limits
2
+
3
+ Where AI agents working in this repo are intentionally constrained.
4
+
5
+ This is the human-readable counterpart to the executable enforcement that
6
+ lives in `.claude/hooks/`, `.githooks/`, and `CLAUDE.md`. The hooks block;
7
+ this document explains *why* and *what to do when blocked*.
8
+
9
+ ## What is intentionally limited
10
+
11
+ ### 1. Destructive git operations
12
+
13
+ Blocked by `.claude/hooks/block-dangerous-git.sh`:
14
+
15
+ - `git push --force` (any variant, including `--force-with-lease`)
16
+ - `git reset --hard`
17
+ - `git clean -f`
18
+ - `git branch -D`
19
+ - Other destructive variants
20
+
21
+ **Why:** Recoverable mistakes cost minutes; an unintended force-push to
22
+ `main` propagates to HF Spaces as a rewritten deploy history and can lose
23
+ work shared by the team. The hook errs on the side of asking the human.
24
+
25
+ **When you genuinely need one:** explain in chat what you need to do and
26
+ why, get explicit user confirmation, and have the user run the command
27
+ themselves in a plain terminal. The agent does not bypass the hook.
28
+
29
+ ### 2. Writes to secret files
30
+
31
+ Blocked by `.claude/hooks/block-env-writes.sh`:
32
+
33
+ - `.env`, `.env.local`, `.env.production`, etc.
34
+ - `credentials*`
35
+ - `*.pem`, `*.key`
36
+ - `id_rsa`, `id_ed25519`, other SSH key patterns
37
+
38
+ **Why:** Secrets must not enter the working tree where they could be
39
+ accidentally committed. `.env.example` (committed; comment-only; no real
40
+ values) is an exception and is allowed.
41
+
42
+ **When you legitimately need to read an env var:** read it from
43
+ `os.environ` at runtime, not from a file the agent writes. For deploy
44
+ secrets, use GitHub Actions secrets and the workflow's environment;
45
+ `HF_TOKEN` follows this pattern (see `SECURITY.md`).
46
+
47
+ ### 3. Modifications to the deploy-critical surface
48
+
49
+ Constrained by social convention (documented in
50
+ `docs/guides/protected-boundary-policy.md`), not by hooks:
51
+
52
+ - `app.py`, `helper.py`, `tab1.py`–`tab8.py` (application code)
53
+ - `requirements.txt`, `runtime.txt` (HF Spaces dependency declaration)
54
+ - `.streamlit/` (Streamlit config)
55
+ - `.devcontainer/` (Codespaces config)
56
+ - `.github/workflows/main.yml` (HF deploy pipeline)
57
+ - `CLAUDE.md` (DECODE base rules)
58
+
59
+ An agent CAN technically edit these files. The convention is to NOT do so
60
+ inside an audit / remediation slice without naming the file in the slice's
61
+ scope. Doing so anyway will be caught at review time and unwound.
62
+
63
+ ### 4. Commits without reviewer subagent approval
64
+
65
+ Enforced by `.githooks/commit-msg` (matched against `.decode-reviewer-clean`
66
+ hash, or by the explicit `[override-reviewer: <reason>]` trailer):
67
+
68
+ The `feature-dev:code-reviewer` subagent must approve any change to
69
+ "substantive files" before commit. The current definition lives in
70
+ `CLAUDE.md`. The marker is gitignored and session-local β€” every change set
71
+ gets a fresh review.
72
+
73
+ **When you legitimately need to override:** add
74
+ `[override-reviewer: <reason>]` to the commit message. The override is
75
+ visible forever in `git log --grep="override-reviewer"` and is audited by
76
+ the `override-audit` CI job. Use sparingly β€” for truly trivial cases like
77
+ fixing a typo in a doc.
78
+
79
+ ### 5. AI attribution in commit messages
80
+
81
+ No `Co-Authored-By: Claude ...`, no "Generated by Claude Code", no robot
82
+ emoji in subject lines.
83
+
84
+ **Why:** DECODE base rule 5. Commits should look like a human wrote them.
85
+ The reviewer marker + override audit already create an unambiguous trail
86
+ of which commits went through the AI workflow; the commit message itself
87
+ stays conventional.
88
+
89
+ **Slip recovery:** if an AI-attribution trailer accidentally landed on a
90
+ merged commit (as happened on PR #7 / commit `7a5c442` during the slice-1
91
+ work), accept it. Do not force-push or revert just to clean it up β€” the
92
+ disruption is larger than the violation. Memory + this doc are how we
93
+ prevent repeats.
94
+
95
+ ### 6. Generated artifacts at the repo root
96
+
97
+ Constrained by `docs/policies/root-artifact-policy.md` (intent) and
98
+ `.gitignore` (partial enforcement):
99
+
100
+ `__pycache__/`, `*.pyc`, `.decode-reviewer-clean`, `.decode-reviewer-findings.md`
101
+ are gitignored. `.ruff_cache/`, `.pytest_cache/`, `.venv/`, `.coverage` are
102
+ tolerated locally but should never appear in `git status` as untracked
103
+ candidates for staging.
104
+
105
+ ## What is intentionally NOT limited
106
+
107
+ The agent IS allowed to:
108
+
109
+ - Read any file in the repo (no read-side restrictions).
110
+ - Author or modify files under `docs/`, `scripts/`, `AGENTS.md`,
111
+ `SECURITY.md`, `.env.example`, `pyproject.toml`, `.python-version`,
112
+ `requirements.lock`, and new files under `.claude/manifests/` or
113
+ `.claude/skills/<new-skill>/`.
114
+ - Run the local validator (`python scripts/repo_validate.py`) without
115
+ asking β€” it's read-only.
116
+ - Run `streamlit run app.py` for local verification β€” it's read-only at
117
+ the file-system level (the app's tempdir use is sandboxed by Streamlit).
118
+ - Open pull requests via `gh pr create` (with `--base main` explicitly).
119
+
120
+ ## Where these limits are codified
121
+
122
+ | Layer | What | File |
123
+ |---|---|---|
124
+ | Executable | hook scripts | `.claude/hooks/block-*.sh`, `.githooks/commit-msg`, `.githooks/pre-commit` |
125
+ | Executable | reviewer subagent contract | `CLAUDE.md` reviewer procedure |
126
+ | Documentary | this file | `docs/guides/ai-enablement-limits.md` |
127
+ | Documentary | deploy-boundary rules | `docs/guides/protected-boundary-policy.md` |
128
+ | Documentary | reviewer workflow | `docs/guides/review-workflow.md` |
129
+ | Documentary | DECODE base rules | `CLAUDE.md` (sections 1–5) |
130
+ | Documentary | this audit's posture | `.claude/manifests/standards-sync.yaml` |
131
+
132
+ When a hook blocks an agent, the agent should consult this document for
133
+ the human-readable rationale before deciding to ask the user for an
134
+ override.
docs/guides/ci-failure-triage.md ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CI failure triage
2
+
3
+ What to do when a CI check goes red on a PR or on a push to `main`.
4
+
5
+ ## The four CI workflows in this repo
6
+
7
+ | Workflow | File | Trigger | What it does |
8
+ |---|---|---|---|
9
+ | **DECODE gate** | `.github/workflows/gate.yml` | PR + push to main | `language-gate` (ruff lint on changed `.py` files) + `override-audit` (records `[override-reviewer:]` use) + `ci-fail-incident` (logs the failure when any job fails) |
10
+ | **Sync to Hugging Face hub** | `.github/workflows/main.yml` | Push to main (+ manual dispatch) | Force-pushes the tree to `https://huggingface.co/spaces/DecodeMarketing/decode_tools` using `HF_TOKEN`. **This is the production deploy.** |
11
+ | **Check file size** | `.github/workflows/check-file-size.yml` | PR + manual dispatch | LFS warning (`ActionsDesk/lfs-warning`) β€” flags large files that should be in LFS rather than git |
12
+ | **repo_validate** | `.github/workflows/repo_validate.yml` | PR + manual dispatch | `python scripts/repo_validate.py` β€” `py_compile` over every `*.py`, parse `requirements.txt`, README HF frontmatter sanity |
13
+
14
+ ## Step 1 β€” Identify which job failed
15
+
16
+ On the PR page, click the red **Details** link next to the failing check.
17
+ For `gate.yml` and the others, look at the job name in the GitHub Actions
18
+ log. Jobs in this repo:
19
+
20
+ - `language-gate` β€” ruff lint
21
+ - `override-audit` β€” checks for `[override-reviewer:]` in commit messages
22
+ - `ci-fail-incident` β€” only runs when another job failed; logs the
23
+ incident. **`ci-fail-incident` failing is normal when its parent failed.**
24
+ - `repo_validate` β€” full-repo py_compile + requirements parse + README
25
+ frontmatter
26
+ - `sync-to-hub` β€” either the LFS warning (on PRs) or the HF deploy (on push
27
+ to main). The job name "sync-to-hub" is shared between the two workflows;
28
+ look at the workflow name in the run header to disambiguate.
29
+
30
+ ## Step 2 β€” Triage by job
31
+
32
+ ### `language-gate` failed (ruff)
33
+
34
+ - Ruff is configured for this repo. Run locally:
35
+ ```bash
36
+ ruff check <changed-files>
37
+ ```
38
+ to reproduce.
39
+ - Fix the lint findings in the same file, commit, re-push.
40
+ - Do NOT add `# noqa` to silence a finding without a real reason.
41
+ - If ruff version changes between local and CI cause a diff, pin ruff in a
42
+ `pyproject.toml` `[tool.ruff]` section in a follow-up slice.
43
+
44
+ ### `repo_validate` failed
45
+
46
+ The script `scripts/repo_validate.py` checks three things and exits non-zero
47
+ on the first failure. Re-run locally:
48
+
49
+ ```bash
50
+ python scripts/repo_validate.py
51
+ ```
52
+
53
+ Failure modes:
54
+
55
+ - **`py_compile` failed** β€” there's a syntax error in some `*.py` file. The
56
+ failing file path is printed. Most common cause is a stale debug `print(`
57
+ or an unclosed bracket.
58
+ - **`requirements` failed to parse** β€” a malformed line in
59
+ `requirements.txt`. PEP 508 syntax; check for stray characters,
60
+ unmatched brackets, or pip-specific syntax that PEP 508 doesn't accept.
61
+ - **`readme_frontmatter` failed** β€” the YAML block at the top of
62
+ `README.md` is missing one of the required HF Space keys
63
+ (`title`, `app_file`, `sdk`, `sdk_version`, `python_version`). Don't
64
+ remove or rename these β€” HF Spaces reads the frontmatter to configure the
65
+ Space.
66
+
67
+ ### `Sync to Hugging Face hub` failed on push to `main`
68
+
69
+ **This is the deploy. The live Space at
70
+ `https://huggingface.co/spaces/DecodeMarketing/decode_tools` is now stale
71
+ or broken until this is fixed.**
72
+
73
+ Most likely causes:
74
+
75
+ - **`HF_TOKEN` expired or revoked.** Rotate the token at
76
+ https://huggingface.co/settings/tokens (scope: write on the
77
+ `DecodeMarketing/decode_tools` Space). Update the secret at
78
+ https://github.com/implicitdiagnosticsandsolutions/icat_app/settings/secrets/actions
79
+ β†’ `HF_TOKEN`. Then re-run the failed workflow via the Actions tab.
80
+ - **Force-push rejected by HF.** HF's git server occasionally rate-limits.
81
+ Re-run the workflow.
82
+ - **Network blip on `actions/checkout`.** Re-run the workflow.
83
+
84
+ Do NOT revert the merge commit to "unblock" the deploy. The deploy will
85
+ succeed on the next push to `main` once the underlying issue (token,
86
+ network) is fixed.
87
+
88
+ ### `Check file size` failed
89
+
90
+ `ActionsDesk/lfs-warning` flags files above the configured threshold. Move
91
+ the offending file into git LFS, or β€” better β€” keep large user-uploaded
92
+ assets out of the repo entirely. They belong in the Streamlit tempdir, not
93
+ in git.
94
+
95
+ ### `override-audit` failed
96
+
97
+ This job records every commit that used `[override-reviewer: <reason>]`.
98
+ It "fails" only if the override is malformed (e.g. no reason after the
99
+ colon). Fix the commit message in a follow-up commit.
100
+
101
+ ## Step 3 β€” If the same job keeps failing for unrelated reasons
102
+
103
+ - Open an issue with the workflow name, the failing job, the commit SHA,
104
+ and the link to the failed run.
105
+ - Re-running blindly is fine for transient infra; persistent failures need
106
+ investigation, not retries.
107
+
108
+ ## Step 4 β€” When the deploy is fixed but the Space is still broken
109
+
110
+ - Check the HF Space build logs at
111
+ `https://huggingface.co/spaces/DecodeMarketing/decode_tools/logs/build`.
112
+ - A green `Sync to Hugging Face hub` workflow means GitHub successfully
113
+ pushed to HF; it does NOT guarantee HF rebuilt the Space cleanly. HF
114
+ parses `requirements.txt` and `runtime.txt` independently. A broken
115
+ dependency pin will fail at HF's build step, not at the GitHub workflow.
116
+ - Poll the Space runtime stage:
117
+ ```bash
118
+ curl -sS "https://huggingface.co/api/spaces/DecodeMarketing/decode_tools" \
119
+ | python -c "import sys,json; d=json.load(sys.stdin); print(d['runtime']['stage'])"
120
+ ```
121
+ Expected states: `BUILDING` β†’ `RUNNING_APP_STARTING` β†’ `RUNNING`. If you
122
+ see `BUILD_ERROR` or `RUNTIME_ERROR`, read the HF build logs.
123
+
124
+ ## See also
125
+
126
+ - `docs/guides/protected-boundary-policy.md` β€” the rules around touching
127
+ the deploy boundary in the first place.
128
+ - `docs/guides/review-workflow.md` β€” the reviewer subagent procedure.
docs/reference/agent-guide.md ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Agent guide
2
+
3
+ What an AI agent contributing to `icat_app` needs to read first.
4
+
5
+ This is the single starting page for an agent. Each section names the
6
+ authoritative file; this guide does not duplicate content β€” it points.
7
+
8
+ ## 1. Identity + base rules
9
+
10
+ - `CLAUDE.md` β€” DECODE base rules (reviewer-required, verify-before-claim,
11
+ patch-source-not-artifact, stage-files-explicitly, no-AI-attribution).
12
+ - `AGENTS.md` β€” the thin entrypoint for any AI workflow (points back to
13
+ `CLAUDE.md` + this file).
14
+
15
+ ## 2. What this repo IS
16
+
17
+ - `docs/architecture/repository-erd.md` β€” runtime topology (`app.py` β†’ 8
18
+ tabs β†’ `helper.py`), deploy pipe to Hugging Face Spaces.
19
+ - `docs/architecture/active-surface.md` β€” which helpers each tab consumes.
20
+ - `README.md` β€” public landing card (the HF Spaces frontmatter at the top
21
+ is consumed by the Space; do not edit the keys).
22
+
23
+ ## 3. Naming + structure rules
24
+
25
+ - `docs/policies/naming-conventions.md` β€” `tab<N>.py` rule, helper naming,
26
+ what we do NOT do (no `src/` layout, no per-tab subdirs).
27
+ - `docs/policies/root-artifact-policy.md` β€” what is allowed at root, what
28
+ is gitignored, what is tolerated locally.
29
+
30
+ ## 4. Where to NOT go
31
+
32
+ - `docs/guides/ai-enablement-limits.md` β€” destructive ops, secret writes,
33
+ AI-attribution, the deploy-critical file list.
34
+ - `docs/guides/protected-boundary-policy.md` β€” `main` = HF deploy on every
35
+ push; rules around touching `main.yml` and the runtime files.
36
+
37
+ ## 5. How to actually do work
38
+
39
+ - `docs/runbooks/local-setup.md` β€” clone β†’ install β†’ run β†’ verify.
40
+ - `docs/guides/git-and-pr-rules.md` β€” branch model, default flow
41
+ (`feature/<scope>` β†’ PR β†’ `main`), PR target, the observed `dev` branch
42
+ that is NOT the production branch despite being the repo default.
43
+ - `docs/guides/review-workflow.md` β€” reviewer subagent contract,
44
+ `.decode-reviewer-clean` marker semantics, override syntax.
45
+ - `.github/pull_request_template.md` β€” the deploy-boundary checklist that
46
+ appears on every new PR.
47
+
48
+ ## 6. When CI fails
49
+
50
+ - `docs/guides/ci-failure-triage.md` β€” per-workflow failure modes and
51
+ recovery steps. Read before re-running anything.
52
+
53
+ ## 7. Verification
54
+
55
+ - `scripts/repo_validate.py` β€” local pre-push proof. Same script also
56
+ runs on every PR via `.github/workflows/repo_validate.yml`.
57
+
58
+ ## 8. Audit + standards alignment
59
+
60
+ - `.claude/manifests/standards-sync.yaml` β€” the applied
61
+ `decode-ai-standards` ref and slice ledger.
62
+ - `.claude/skills/check_decode_ai_standards_updates/SKILL.md` β€” the
63
+ freshness-check skill that compares the manifest against upstream.
64
+ - `docs/progress/slice-integration-overview.md` β€” slice timeline.
65
+
66
+ ## 9. Hooks + skills surface
67
+
68
+ - `.claude/settings.json` β€” allowed/blocked tool patterns, hook wiring.
69
+ - `.claude/hooks/` β€” runtime block-*.sh scripts.
70
+ - `.claude/skills/{deslop,tdd,check_decode_ai_standards_updates}/SKILL.md`
71
+ β€” repo-local skills.
72
+ - `.githooks/pre-commit`, `.githooks/commit-msg` β€” git-side enforcement.
73
+ Wired via `core.hooksPath` by `scripts/setup.sh`.
74
+
75
+ ## Reading order for a fresh agent
76
+
77
+ If you have time for only one pass, read in this order:
78
+
79
+ 1. `CLAUDE.md` (base rules, reviewer procedure, hard rules 1–5)
80
+ 2. `docs/guides/ai-enablement-limits.md` (what you cannot do and why)
81
+ 3. `docs/guides/protected-boundary-policy.md` (the deploy story)
82
+ 4. `docs/architecture/repository-erd.md` (what the code is)
83
+ 5. `docs/runbooks/local-setup.md` (only if you intend to run it locally)
84
+
85
+ If you have time for two passes, also read:
86
+
87
+ 6. `docs/guides/review-workflow.md`
88
+ 7. `docs/policies/naming-conventions.md`
89
+ 8. `docs/policies/root-artifact-policy.md`
90
+
91
+ The rest is referential β€” pull in on demand, not preemptively.