-
Notifications
You must be signed in to change notification settings - Fork 1
stabilize: snapshot-pinning scaffolding (Amara action #2 — completes Stabilize stage) #223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,125 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Session snapshots — Claude state pins | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Durable record of Claude session state at session-open or at | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| per-decision pin-time. Addresses Amara's 4th-ferry concern | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (PR #221) that "Claude is not a single stable operator unless | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| the actual snapshot, system-prompt bundle, and loaded memory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| surfaces are all pinned and recorded." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ## Why this file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Across Claude model versions (3.5 → 3.7 → 4 → 4.x), the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| system-prompt bundle + knowledge cutoff + memory-retention | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| language shift materially. When a future session, external | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| reviewer, or tuning pipeline asks *"what did Kenji actually | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| know when this decision was made?"* this file answers. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+4
to
+15
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| per-decision pin-time. Addresses Amara's 4th-ferry concern | |
| (PR #221) that "Claude is not a single stable operator unless | |
| the actual snapshot, system-prompt bundle, and loaded memory | |
| surfaces are all pinned and recorded." | |
| ## Why this file | |
| Across Claude model versions (3.5 → 3.7 → 4 → 4.x), the | |
| system-prompt bundle + knowledge cutoff + memory-retention | |
| language shift materially. When a future session, external | |
| reviewer, or tuning pipeline asks *"what did Kenji actually | |
| know when this decision was made?"* this file answers. | |
| per-decision pin-time. Addresses the external AI maintainer's | |
| 4th-ferry concern (PR #221) that "Claude is not a single | |
| stable operator unless the actual snapshot, system-prompt | |
| bundle, and loaded memory surfaces are all pinned and | |
| recorded." | |
| ## Why this file | |
| Across Claude model versions (3.5 → 3.7 → 4 → 4.x), the | |
| system-prompt bundle + knowledge cutoff + memory-retention | |
| language shift materially. When a future session, external | |
| reviewer, or tuning pipeline asks *"what did the architect | |
| actually know when this decision was made?"* this file | |
| answers. |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,118 @@ | ||||||||||||||||||||||||||||||||||||||||||||||
| #!/usr/bin/env bash | ||||||||||||||||||||||||||||||||||||||||||||||
| # tools/hygiene/capture-tick-snapshot.sh | ||||||||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||||||||
| # Captures a snapshot pin of factory state at tick-open / | ||||||||||||||||||||||||||||||||||||||||||||||
| # tick-close time. Prints a YAML fragment that can be pasted | ||||||||||||||||||||||||||||||||||||||||||||||
| # into: | ||||||||||||||||||||||||||||||||||||||||||||||
| # - docs/hygiene-history/session-snapshots.md (session-level) | ||||||||||||||||||||||||||||||||||||||||||||||
| # - docs/decision-proxy-evidence/DP-NNN.yaml `model` block | ||||||||||||||||||||||||||||||||||||||||||||||
| # (decision-level) | ||||||||||||||||||||||||||||||||||||||||||||||
| # - a tick-history row's `notes` column (tick-level) | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+4
to
+10
|
||||||||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||||||||
| # Addresses Amara's 4th-ferry (PR #221 absorb) snapshot-pinning | ||||||||||||||||||||||||||||||||||||||||||||||
| # concern: "Claude is not a single stable operator unless the | ||||||||||||||||||||||||||||||||||||||||||||||
| # actual snapshot, system-prompt bundle, and loaded memory | ||||||||||||||||||||||||||||||||||||||||||||||
| # surfaces are all pinned and recorded". The pin is the | ||||||||||||||||||||||||||||||||||||||||||||||
| # mechanism that makes Claude's behavior reproducible after | ||||||||||||||||||||||||||||||||||||||||||||||
| # prompt / model updates ship. | ||||||||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||||||||
| # What the snapshot captures (mechanically accessible): | ||||||||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||||||||
| # - Claude Code CLI version (`claude --version`) | ||||||||||||||||||||||||||||||||||||||||||||||
| # - CLAUDE.md content SHA (in-repo + per-user home if present) | ||||||||||||||||||||||||||||||||||||||||||||||
| # - AGENTS.md content SHA | ||||||||||||||||||||||||||||||||||||||||||||||
| # - memory/MEMORY.md content SHA + byte count | ||||||||||||||||||||||||||||||||||||||||||||||
| # - Current git HEAD SHA + branch + repo name | ||||||||||||||||||||||||||||||||||||||||||||||
| # - Date UTC | ||||||||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||||||||
| # What the snapshot does NOT capture (agent must fill in): | ||||||||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||||||||
| # - Claude model snapshot (e.g., claude-opus-4-7) — known to | ||||||||||||||||||||||||||||||||||||||||||||||
| # the agent from session context, not exposed by CLI | ||||||||||||||||||||||||||||||||||||||||||||||
| # - Prompt bundle hash — not currently computable from | ||||||||||||||||||||||||||||||||||||||||||||||
| # session; placeholder null until a tool that reconstructs | ||||||||||||||||||||||||||||||||||||||||||||||
| # the system prompt bundle lands | ||||||||||||||||||||||||||||||||||||||||||||||
| # - Active permission / skill set — session-specific | ||||||||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||||||||
| # Usage: | ||||||||||||||||||||||||||||||||||||||||||||||
| # tools/hygiene/capture-tick-snapshot.sh # print YAML fragment | ||||||||||||||||||||||||||||||||||||||||||||||
| # tools/hygiene/capture-tick-snapshot.sh --json # print JSON | ||||||||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||||||||
| # Part of Amara Stabilize-stage (PR #221 roadmap); FACTORY- | ||||||||||||||||||||||||||||||||||||||||||||||
| # HYGIENE row for cadenced capture is a follow-up after | ||||||||||||||||||||||||||||||||||||||||||||||
| # format stabilizes. | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| format="yaml" | ||||||||||||||||||||||||||||||||||||||||||||||
| if [[ "${1:-}" == "--json" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||
| format="json" | ||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # Helpers — each returns empty string on failure rather than | ||||||||||||||||||||||||||||||||||||||||||||||
| # aborting under `set -euo pipefail`. | ||||||||||||||||||||||||||||||||||||||||||||||
| safe_sha() { | ||||||||||||||||||||||||||||||||||||||||||||||
| if [[ -f "$1" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||
| git hash-object "$1" 2>/dev/null || printf '' | ||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| safe_bytes() { | ||||||||||||||||||||||||||||||||||||||||||||||
| if [[ -f "$1" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||
| wc -c < "$1" 2>/dev/null | tr -d ' ' || printf '' | ||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+56
to
+63
|
||||||||||||||||||||||||||||||||||||||||||||||
| git hash-object "$1" 2>/dev/null || printf '' | |
| fi | |
| } | |
| safe_bytes() { | |
| if [[ -f "$1" ]]; then | |
| wc -c < "$1" 2>/dev/null | tr -d ' ' || printf '' | |
| fi | |
| git hash-object "$1" 2>/dev/null || printf '' | |
| else | |
| printf '' | |
| fi | |
| return 0 | |
| } | |
| safe_bytes() { | |
| if [[ -f "$1" ]]; then | |
| wc -c < "$1" 2>/dev/null | tr -d ' ' || printf '' | |
| else | |
| printf '' | |
| fi | |
| return 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anchor snapshot file paths to repository root
The snapshot fields are read from ./CLAUDE.md, ./AGENTS.md, and memory/MEMORY.md relative to the caller’s current directory, so running this helper from any non-root cwd (for example docs/) silently produces empty hashes/byte counts while still returning success. That creates incomplete pin records that appear valid and weakens the audit/reproducibility goal of this feature; resolve paths from git rev-parse --show-toplevel (or the script directory) before hashing.
Useful? React with 👍 / 👎.
Copilot
AI
Apr 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: repo_full parsing can incorrectly retain the .git suffix for common remotes like git@github.com:owner/repo.git or https://.../owner/repo.git because the capture group includes the .git portion. Consider stripping a trailing .git after extraction (or use git remote get-url origin + explicit suffix removal) so repo is consistently owner/repo.
| repo_full=$(git config --get remote.origin.url 2>/dev/null | sed -E 's|.*[:/]([^/]+/[^/]+)(\.git)?$|\1|' || printf 'unknown') | |
| repo_full=$(git config --get remote.origin.url 2>/dev/null | sed -E 's|.*[:/]([^/]+/[^/]+)(\.git)?$|\1|' | sed -E 's|\.git$||' || printf 'unknown') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1:
PR <this-pr>is a placeholder that will become stale/unresolvable after merge. Replace it with the actual PR number (and ideally a link) so the provenance trail remains auditable.