artifact-hygiene · v0.5.0 · 2026-09-12 · sha256 69d2f4768c65c5d6

artifact-hygiene v0.5.0A

Immutable. This exact content is served forever at /api/v1/blob/69d2f4768c65c5d6.

---
name: artifact-hygiene
description: Run a local-only, read-only advisory audit of publishable working-tree files and unpublished branch history with redaction-safe findings.
allowed-tools: "Bash(~/.agents/skills/artifact-hygiene/scripts/artifact_hygiene.py:*)"
model-tier: standard
model: sonnet
effort: high
version: "0.5.0"
author: "flurdy"
---

# Artifact Hygiene

Run the local-only proof of concept that checks whether repository content is safe to publish. The
helper is the only component allowed to read candidate content. The active model receives normalized,
redacted findings and coverage—not raw candidate content. Claude Code uses the Sonnet alias for this
bounded interpretation; Pi continues to route by `model-tier`.

This skill is advisory and read-only. It never fetches, follows links, calls remote services, validates
credentials, installs hooks, blocks CI, edits files, changes Git state, rewrites history, or creates
tracker or remote state.

## Placement and enforcement

The helper and skill remain together under `~/.agents/skills/` as the portable, client-neutral audit
discovered by Pi, Claude Code, and Codex. The model can render its redacted advisory report; a hook
cannot. Enforcement therefore stays in thin client-specific hooks that call the helper and map its
result to allow or deny, such as the
[Claude Code push gate in ai-tools](https://github.com/flurdy/ai-tools/tree/main/claude/artifact-hygiene-gate),
without copying detectors or report logic.

## Scope

The proof of concept scans:

- the full publishable working tree: tracked regular text files plus staged, unstaged, and
  untracked-not-ignored regular text files; and
- unpublished branch commit messages and per-path patches relative to a locally available
  default-branch ref, without fetching. If no remote-backed base is available, it scans all commits
  reachable from `HEAD` rather than treating the current local branch as published.

History is scanned through bounded per-record stdin calls, not an unrestricted scanner Git walk.
Blob sizes are checked before generating patches; deletions introduce no content. When a large
predecessor becomes a small file, the full new file is scanned conservatively instead of building a
huge deletion patch. Such findings can include unchanged lines. Repository diff attributes cannot hide
text, and paths are treated literally.

It uses an audit-owned Gitleaks configuration and empty ignore file, scrubs scanner configuration from
the environment, ignores inline scanner allow-comments, and never passes a baseline. Repository
scanner configuration cannot suppress the audit. Before any clean result, a private runtime canary
must prove that the selected scanner and audit configuration can detect the pinned secret shape. The
helper also reports known session-share links, Bead references, email addresses, name-like personal data (personal names),
AI attribution trailers or boilerplate, and scanner-suppression controls without exposing matched values.

The `custom-detectors` coverage source proves every built-in non-secret detector still matches its
private canary. Missing detector coverage produces a partial result, never a clean result. Personal-name
detection is advisory and contextual: it detects direct requests to contact a named person or handle, not
capitalized technical phrases. Expected `Co-authored-by:` and `Signed-off-by:` trailers are excluded from
personal-data findings. Bead-reference, personal-data, and AI-attribution detectors scan unpublished history only—commit
messages and added patch lines—rather than re-reporting content already published on the base branch. Bead references and
personal-data matches in dependency lockfiles are ignored, as are email addresses under reserved example domains.
Email addresses in the `owner`, `created_by`, and `assignee` fields of Beads `.beads/issues.jsonl`
records are treated as structural attribution; unrelated fields remain reportable.

The Bead-reference detector matches known prefixes with any 3–8 character base36 suffix and
optional `.N` children, plus a generic digit-bearing shape so a checked-in file can only widen
detection. Known prefixes come from clone-local `artifactHygiene.beadPrefixes` (multi-valued or
comma-separated), `ARTIFACT_HYGIENE_BEAD_PREFIXES`, and the repository's own `.beads/config.yaml`
`issue-prefix` and `.beads/issues.jsonl` IDs; `target.beadPrefixSource` reports which. Plain
hyphenated words such as `dry-run` are not reported. Email matches immediately followed by `:` are
treated as scp-style Git URLs, personal-name matches stop at identifier boundaries, and paths under
an `artifact-hygiene/` directory are exempt from the non-secret detectors because the audit's own
source and fixtures necessarily contain canary shapes; secret scanning still covers them.

A clone may allow Bead references only with local, unshared configuration:

```bash
git config --local artifactHygiene.allowBeadReferences true
# or ARTIFACT_HYGIENE_ALLOW_BEAD_REFERENCES=1 artifact_hygiene.py --pretty
```

The selected override is reported in `target.policy`; a checked-in configuration file cannot disable a
detector.

A clone may allow one exact public-by-design client key using the redacted finding's `allowId`:

```bash
git config --local --add artifactHygiene.allowSecretFingerprints ah1:<fingerprint>
```

The fingerprint is bound to the scanner rule and exact matched value, not its path or line, so replacing
the key produces a new finding. Matching findings remain visible under `suppressed` and in the summary.
Only valid IDs from clone-local Git configuration are honored; repository files, environment variables,
global Git configuration, paths, and scanner rule names cannot grant this allowance. The helper hashes
the scanner match in private process memory and never emits the raw value.

## Oversized blobs

Files over 1,000,000 bytes (including binary files) are not scanned. The helper hashes working-tree
bytes incrementally using Git's raw blob format, without running filters or writing objects. Index
and history entries use their exact Git blob IDs. SHA-1 and SHA-256 repositories are supported.

- A blob reachable anywhere in the locally available remote-backed default base's history is
  `skipped-by-policy` with reason `published-base-history`, including renamed or reintroduced blobs.
  This proves local remote-tracking reachability, not live remote state; the helper never fetches.
- An unpublished blob remains partial (`file-too-large`) and denies publication, with its path,
  blob ID, and required manual override in `sizeDecisions`.
- After independently reviewing the unscanned content, a clone may allow exactly that blob:

  ```bash
  git config --local --add artifactHygiene.allowLargeBlobs <full-blob-id>
  ```

  Only lowercase, full-length IDs matching the repository object format are accepted (multi-valued
  or comma-separated). Changed bytes require another allowance. Only direct clone-local Git
  configuration is honored: checked-in files, Git config includes, environment variables, and global
  configuration cannot grant it. Active allowances appear as `+allow-large-blobs` in `target.policy`;
  applied skips have reason `local-blob-allowance`.

`sizeDecisions` records each skipped or denied source/path/commit/blob combination, the byte size,
reason, and safe remediation. Policy skips keep coverage complete and do not consume the scanned-byte
budget; they do not claim content was inspected. A missing base cannot prove publication. Failed or
bounded-out reachability checks produce `publication-proof-failed`; scanner failures, history-read
failures, file changes, timeouts, and other resource limits still deny, even with a blob allowance.
Reachability uses the existing bounded command output/deadline and 100,000-object cap; size decisions
are capped at 2,000, with overflow reported as partial rather than silently omitted.

GitHub pull requests, Jira, comments, attachments, linked pages, other repositories, full-history
remediation, policy authoring, and enforcement are out of scope.

## Requirements

- Python 3.10 or newer
- Git
- Gitleaks; the proof of concept is locally verified with Gitleaks 8.30.1

A missing or failed scanner produces partial coverage rather than a clean result.

## Run

From the repository to inspect:

```bash
~/.agents/skills/artifact-hygiene/scripts/artifact_hygiene.py --pretty
```

The helper always emits `artifact-hygiene/v1` JSON to stdout and emits no candidate or child-process
text to stderr.

Exit codes:

- `0` — every required local source completed; inspect `verdict` for `clean` or `findings`.
- `2` — coverage is `partial`; never describe this result as clean.
- `3` — the audit failed before it could establish usable coverage.

## Report

Render coverage before findings:

1. State the overall `status` and `verdict` exactly.
2. List each source and its `complete`, `partial`, or `failed` status plus safe error codes.
3. Group findings by severity and category, using only the normalized location, evidence token, and
   remediation supplied by the helper.
4. Report any `suppressed` count and state that clone-local fingerprint allowances were applied; use
   only normalized fields and never attempt to recover the matched value.
5. Render `sizeDecisions`, including every `skipped-by-policy` entry and its reason/blob ID. For
   denied entries, name the file and show the exact clone-local override supplied by the helper;
   never apply it automatically or describe skipped content as scanned.
6. If status is partial or failed, name the unavailable coverage and stop short of publication
   assurance.

Never recover raw evidence by reading a reported file, commit, scanner output, temporary file, or
repository configuration. Remediation is a separate explicitly approved task. This skill never mutates
the audited repository.