Skip to content

context-forge: pin analysis branch + commit in artifacts, and use it to scope refresh - #18

Merged
davcs86 merged 2 commits into
mainfrom
claude/context-forge-branch-commit-pnm198
Aug 28, 2026
Merged

davcs86 merged 2 commits into
mainfrom
claude/context-forge-branch-commit-pnm198

Conversation

@davcs86

@davcs86 davcs86 commented Aug 28, 2026

Copy link
Copy Markdown
Owner

What & why

Both context-forge skills previously stamped only an ISO date on the artifacts they generate, so a reader couldn't tell which repo state the rules/findings reflected. This PR records the git branch and commit hash the analysis ran against, and then puts that stored commit to work: context-constitution refresh uses it to scope reruns to the diff from the exact state last analyzed.

Changes

Store the provenance ref (constitution + scrubber)

  • context-constitution captures branch (git rev-parse --abbrev-ref HEAD) + short commit (git rev-parse --short HEAD) once at scan time (scan-protocol step 5), reused across every target in a monorepo, and stamps it into the context-constitution.md and context-constitution-findings.md headers on write. Detached-HEAD and non-git cases degrade to detached HEAD / unknown.
  • context-scrubber captures and stamps the same branch + commit into the context-scrubber-findings.md header at report time (audit-protocol step 4).
  • The three header templates gained the branch/commit placeholders.

Use the stored SHA to sharpen refresh's diff baseline

  • refresh-protocol now derives the diff floor as git merge-base R_head R_write — the older of the commit the file's header records (R_head) and the last commit that wrote the constitution (R_write). Resolving/verifying R_head first and taking the older of the two means a purely cosmetic edit to the constitution can't shove the baseline past real code changes.
  • Fully backward-compatible fallbacks: when R_head is missing, unknown, or unresolvable in the checkout (shallow clone, rebase, GC, force-push), it falls back to R_write — the prior behavior. Manual-edit-as-forge still holds; the staleness check remains the correctness net and the SHA only tightens the new-pattern hunt.
  • A refresh write restamps the header to the current HEAD.
  • Allowed Bash(git merge-base *) in the constitution skill (git rev-parse --verify was already covered).

Docs & versioning

  • Documented the pinned-commit behavior and the sharper refresh baseline in the plugin README.
  • Bumped all three plugin manifests 0.7.0 → 0.8.0 (byte-identical).

Validation

validate_manifests.py (+ --self-test) and plugins/context-forge/scripts/validate.py (+ --self-test) all pass locally — the same commands CI runs.

Notes

No behavioral change to the safety model: nothing new is written before a gate, scan/check modes still write nothing, and no allowed-tools surface beyond the added git merge-base (a read-only ancestry query).

🤖 Generated with Claude Code


Generated by Claude Code

claude added 2 commits August 28, 2026 03:15
Record the git branch and commit hash the analysis ran against in the
provenance header of every context-forge output, so a reader knows exactly
which repo state the rules/findings reflect and refresh reruns from a known
point.

- context-constitution: capture branch + short SHA once at scan time
  (scan-protocol step 5, via the already-allowed `git rev-parse`), stamp it
  into the constitution and findings-log headers on write, and refresh that
  line to the current ref on merge/refresh (metadata, not a CF-4 overwrite).
- context-scrubber: capture and stamp branch + short SHA into the
  scrubber-findings header at report time.
- Update the three header templates with the new provenance placeholders.
- Document the pinned-commit behavior in the plugin README; bump all three
  plugin manifests to 0.8.0 (byte-identical).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UemJKwSwi6rVj3tD5VEqGJ
Feed the analyzed commit now stored in each constitution's header into
`refresh`'s diff floor, so reruns are scoped from the exact state last
analyzed instead of a baseline a cosmetic edit could have shoved forward.

- refresh-protocol: derive the floor as `git merge-base R_head R_write` —
  the older of the commit the file's header records (R_head) and the last
  commit that wrote the constitution (R_write). Resolve/verify R_head first
  and fall back to R_write when it is missing, `unknown`, or unresolvable
  (shallow clone, rebase, GC, force-push), keeping older constitutions and
  manual-edit-as-forge working unchanged. Staleness check remains the
  correctness net; the SHA only tightens the new-pattern hunt.
- Rework the baseline guardrail to describe the augmenting merge-base floor
  (provenance in the artifact, never a side-channel state file).
- Allow `Bash(git merge-base *)` in the skill; document the sharper baseline
  in the plugin README.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UemJKwSwi6rVj3tD5VEqGJ
@davcs86
davcs86 merged commit 118f017 into main Aug 28, 2026
2 checks passed
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.

2 participants