scar-cli 0.29.0__tar.gz → 0.30.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. scar_cli-0.30.0/.release-please-manifest.json +3 -0
  2. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/0001-git-grep-ere-pitfalls.landmine.md +1 -1
  3. {scar_cli-0.29.0 → scar_cli-0.30.0}/CHANGELOG.md +26 -0
  4. {scar_cli-0.29.0 → scar_cli-0.30.0}/PKG-INFO +1 -1
  5. {scar_cli-0.29.0 → scar_cli-0.30.0}/plugin/plugin.json +1 -1
  6. {scar_cli-0.29.0 → scar_cli-0.30.0}/plugin/skills/scar-authoring/SKILL.md +11 -1
  7. {scar_cli-0.29.0 → scar_cli-0.30.0}/pyproject.toml +1 -1
  8. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/cli.py +24 -9
  9. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/lint.py +145 -40
  10. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/mcp.py +2 -2
  11. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/model.py +56 -3
  12. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/presence.py +29 -0
  13. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/record.py +11 -0
  14. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/skills/scar-authoring/SKILL.md +11 -1
  15. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/store.py +39 -11
  16. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/presence_fakes.py +13 -1
  17. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_cli.py +98 -0
  18. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_lint.py +210 -0
  19. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_lint_downgrade.py +102 -6
  20. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_mcp.py +8 -0
  21. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_model.py +43 -0
  22. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_presence.py +20 -0
  23. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_promote_batch.py +8 -5
  24. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_record.py +29 -1
  25. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_skill.py +17 -0
  26. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_store.py +18 -8
  27. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_verify.py +20 -7
  28. {scar_cli-0.29.0 → scar_cli-0.30.0}/uv.lock +1 -1
  29. scar_cli-0.29.0/.release-please-manifest.json +0 -3
  30. {scar_cli-0.29.0 → scar_cli-0.30.0}/.claude-plugin/marketplace.json +0 -0
  31. {scar_cli-0.29.0 → scar_cli-0.30.0}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
  32. {scar_cli-0.29.0 → scar_cli-0.30.0}/.github/ISSUE_TEMPLATE/config.yml +0 -0
  33. {scar_cli-0.29.0 → scar_cli-0.30.0}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
  34. {scar_cli-0.29.0 → scar_cli-0.30.0}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
  35. {scar_cli-0.29.0 → scar_cli-0.30.0}/.github/workflows/ci.yml +0 -0
  36. {scar_cli-0.29.0 → scar_cli-0.30.0}/.github/workflows/docs.yml +0 -0
  37. {scar_cli-0.29.0 → scar_cli-0.30.0}/.github/workflows/pr-validation.yml +0 -0
  38. {scar_cli-0.29.0 → scar_cli-0.30.0}/.github/workflows/release.yml +0 -0
  39. {scar_cli-0.29.0 → scar_cli-0.30.0}/.github/workflows/scar-review-queue.yml +0 -0
  40. {scar_cli-0.29.0 → scar_cli-0.30.0}/.gitignore +0 -0
  41. {scar_cli-0.29.0 → scar_cli-0.30.0}/.pre-commit-config.yaml +0 -0
  42. {scar_cli-0.29.0 → scar_cli-0.30.0}/.pre-commit-hooks.yaml +0 -0
  43. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/0002-agent-direct-hook-install.deadend.md +0 -0
  44. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/0003-installer-binds-to-active-venv-scar.landmine.md +0 -0
  45. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/0004-promote-roundtrip-drops-expires-evidence.landmine.md +0 -0
  46. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/0005-history-rewrite-orphans-commit-evidence.landmine.md +0 -0
  47. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/0006-yaml-pattern-anchor-over-escaping.landmine.md +0 -0
  48. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/0007-release-please-config-change-skips-open-pr.landmine.md +0 -0
  49. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/0008-rich-output-nontty-must-bypass-rich.landmine.md +0 -0
  50. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/0009-anchor-survival-harness-measures-symbol-not-path-anchors.deadend.md +0 -0
  51. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/0010-git-returncode-128-vs-empty-tracked-set.landmine.md +0 -0
  52. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/0011-lint-compile-check-lets-redos-anchors-hang-hotpath.landmine.md +0 -0
  53. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/0012-firing-log-readers-need-blanket-guards.landmine.md +0 -0
  54. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/0013-docusaurus-future-v4-requires-faster-dep.landmine.md +0 -0
  55. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/0014-inject-flag-dest-collides-with-subcommand-dispatch.landmine.md +0 -0
  56. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/0015-zero-checkruns-means-approval-gate-not-workflow-bug.deadend.md +0 -0
  57. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/0016-hook-ownership-must-be-kind-scoped.landmine.md +0 -0
  58. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/0017-codex-pretool-context-can-replay-apply-patch.landmine.md +0 -0
  59. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/0018-cli-subparsers-register-through-_add-wrapper.landmine.md +0 -0
  60. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/0019-token-in-scar-body-cannot-prove-hook-delivery.deadend.md +0 -0
  61. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/0020-one-directional-health-check-leaves-flattering-direction-unwatched.landmine.md +0 -0
  62. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/0021-posttool-fix-in-hooks-does-not-reach-codex-or-cascade.landmine.md +0 -0
  63. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/0022-codex-hook-delivery-needs-user-file-and-trust.landmine.md +0 -0
  64. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/0023-cascade-block-exit-collides-with-argparse.fence.md +0 -0
  65. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/0024-host-detection-must-not-read-the-process-home.deadend.md +0 -0
  66. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/0025-one-plugin-hook-manifest-two-hosts-two-root-variables.landmine.md +0 -0
  67. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/0026-path-anchor-breadth-drives-the-review-due-threshold.landmine.md +0 -0
  68. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/0027-slug-and-display-cleaning-are-different-jobs.landmine.md +0 -0
  69. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/0028-violation-evidence-must-not-persist-raw-edits.fence.md +0 -0
  70. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/0029-compliance-pools-by-repo-and-id.landmine.md +0 -0
  71. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/0030-presence-signer-input-canonical-subset.landmine.md +0 -0
  72. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/README.md +0 -0
  73. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/candidates/.gitkeep +0 -0
  74. {scar_cli-0.29.0 → scar_cli-0.30.0}/.scars/template.md +0 -0
  75. {scar_cli-0.29.0 → scar_cli-0.30.0}/AGENTS.md +0 -0
  76. {scar_cli-0.29.0 → scar_cli-0.30.0}/CONTRIBUTING.md +0 -0
  77. {scar_cli-0.29.0 → scar_cli-0.30.0}/IDEA.md +0 -0
  78. {scar_cli-0.29.0 → scar_cli-0.30.0}/LICENSE +0 -0
  79. {scar_cli-0.29.0 → scar_cli-0.30.0}/README.md +0 -0
  80. {scar_cli-0.29.0 → scar_cli-0.30.0}/ROADMAP.md +0 -0
  81. {scar_cli-0.29.0 → scar_cli-0.30.0}/SCAR-FORMAT.md +0 -0
  82. {scar_cli-0.29.0 → scar_cli-0.30.0}/SPEC.md +0 -0
  83. {scar_cli-0.29.0 → scar_cli-0.30.0}/STRESS-TEST.md +0 -0
  84. {scar_cli-0.29.0 → scar_cli-0.30.0}/action.yml +0 -0
  85. {scar_cli-0.29.0 → scar_cli-0.30.0}/codecov.yml +0 -0
  86. {scar_cli-0.29.0 → scar_cli-0.30.0}/experiments/anchor-survival/PROTOCOL.md +0 -0
  87. {scar_cli-0.29.0 → scar_cli-0.30.0}/experiments/anchor-survival/RESULTS.md +0 -0
  88. {scar_cli-0.29.0 → scar_cli-0.30.0}/experiments/anchor-survival/long_replay.py +0 -0
  89. {scar_cli-0.29.0 → scar_cli-0.30.0}/experiments/anchor-survival/replay.py +0 -0
  90. {scar_cli-0.29.0 → scar_cli-0.30.0}/experiments/anchor-survival/replay_shipped.py +0 -0
  91. {scar_cli-0.29.0 → scar_cli-0.30.0}/experiments/anchor-survival/test_replay_shipped.py +0 -0
  92. {scar_cli-0.29.0 → scar_cli-0.30.0}/experiments/auto-authorship/FINDINGS.md +0 -0
  93. {scar_cli-0.29.0 → scar_cli-0.30.0}/experiments/auto-authorship/PROTOCOL.md +0 -0
  94. {scar_cli-0.29.0 → scar_cli-0.30.0}/experiments/fence-honor/.gitignore +0 -0
  95. {scar_cli-0.29.0 → scar_cli-0.30.0}/experiments/fence-honor/PROTOCOL.md +0 -0
  96. {scar_cli-0.29.0 → scar_cli-0.30.0}/experiments/fence-honor/RESULTS.md +0 -0
  97. {scar_cli-0.29.0 → scar_cli-0.30.0}/experiments/fence-honor/fixture/.scars/0001-vendor-retry-window.fence.md +0 -0
  98. {scar_cli-0.29.0 → scar_cli-0.30.0}/experiments/fence-honor/fixture/.scars/0002-evicting-session-store.deadend.md +0 -0
  99. {scar_cli-0.29.0 → scar_cli-0.30.0}/experiments/fence-honor/fixture/.scars/0003-export-column-order.landmine.md +0 -0
  100. {scar_cli-0.29.0 → scar_cli-0.30.0}/experiments/fence-honor/fixture/README.md +0 -0
  101. {scar_cli-0.29.0 → scar_cli-0.30.0}/experiments/fence-honor/fixture/payments/retry.py +0 -0
  102. {scar_cli-0.29.0 → scar_cli-0.30.0}/experiments/fence-honor/fixture/reports/export.py +0 -0
  103. {scar_cli-0.29.0 → scar_cli-0.30.0}/experiments/fence-honor/fixture/services/sessions.py +0 -0
  104. {scar_cli-0.29.0 → scar_cli-0.30.0}/experiments/fence-honor/grade.py +0 -0
  105. {scar_cli-0.29.0 → scar_cli-0.30.0}/experiments/harvest/PROTOCOL.md +0 -0
  106. {scar_cli-0.29.0 → scar_cli-0.30.0}/experiments/harvest/harvest.py +0 -0
  107. {scar_cli-0.29.0 → scar_cli-0.30.0}/hook/scar-hooks.py +0 -0
  108. {scar_cli-0.29.0 → scar_cli-0.30.0}/plugin/hooks/run.sh +0 -0
  109. {scar_cli-0.29.0 → scar_cli-0.30.0}/plugin/skills/scar-authoring/assets/template.md +0 -0
  110. {scar_cli-0.29.0 → scar_cli-0.30.0}/release-please-config.json +0 -0
  111. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/__init__.py +0 -0
  112. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/agent.py +0 -0
  113. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/cascade.py +0 -0
  114. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/clock.py +0 -0
  115. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/codex.py +0 -0
  116. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/config.py +0 -0
  117. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/draftcheck.py +0 -0
  118. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/evidence.py +0 -0
  119. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/firing_log.py +0 -0
  120. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/gc.py +0 -0
  121. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/harvest.py +0 -0
  122. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/hooks.py +0 -0
  123. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/hosts.py +0 -0
  124. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/installer.py +0 -0
  125. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/match.py +0 -0
  126. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/orphan.py +0 -0
  127. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/output.py +0 -0
  128. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/reanchor.py +0 -0
  129. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/renames.py +0 -0
  130. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/render.py +0 -0
  131. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/review.py +0 -0
  132. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/signedpromote.py +0 -0
  133. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/skills/scar-authoring/assets/template.md +0 -0
  134. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/symbols.py +0 -0
  135. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/verify.py +0 -0
  136. {scar_cli-0.29.0 → scar_cli-0.30.0}/src/scar/violation_evidence.py +0 -0
  137. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/conformance_fetch.py +0 -0
  138. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/conformance_support.py +0 -0
  139. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/conftest.py +0 -0
  140. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/fixtures/conformance/promote.json +0 -0
  141. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/fixtures/conformance/regenerate.py +0 -0
  142. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_action_yml.py +0 -0
  143. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_anchor_kind.py +0 -0
  144. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_block_capability.py +0 -0
  145. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_cascade.py +0 -0
  146. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_clock.py +0 -0
  147. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_codex.py +0 -0
  148. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_compliance_stats.py +0 -0
  149. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_conformance_round_trip.py +0 -0
  150. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_context_size.py +0 -0
  151. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_docs.py +0 -0
  152. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_draftcheck.py +0 -0
  153. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_evidence.py +0 -0
  154. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_firing_log.py +0 -0
  155. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_gc.py +0 -0
  156. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_git_hook.py +0 -0
  157. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_harvest.py +0 -0
  158. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_hooks.py +0 -0
  159. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_hosts.py +0 -0
  160. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_installer.py +0 -0
  161. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_json_contract.py +0 -0
  162. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_lifecycle.py +0 -0
  163. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_match.py +0 -0
  164. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_matched_by.py +0 -0
  165. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_orphan.py +0 -0
  166. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_output.py +0 -0
  167. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_plugin.py +0 -0
  168. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_precommit_hooks.py +0 -0
  169. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_presence_adapters.py +0 -0
  170. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_presence_signer.py +0 -0
  171. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_promote_signed.py +0 -0
  172. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_reanchor.py +0 -0
  173. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_renames.py +0 -0
  174. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_render.py +0 -0
  175. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_review.py +0 -0
  176. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_review_queue.py +0 -0
  177. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_sweep.py +0 -0
  178. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_symbols.py +0 -0
  179. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_verdict_observability.py +0 -0
  180. {scar_cli-0.29.0 → scar_cli-0.30.0}/tests/test_violation_evidence.py +0 -0
  181. {scar_cli-0.29.0 → scar_cli-0.30.0}/website/.gitignore +0 -0
  182. {scar_cli-0.29.0 → scar_cli-0.30.0}/website/docs/agents.md +0 -0
  183. {scar_cli-0.29.0 → scar_cli-0.30.0}/website/docs/concepts.md +0 -0
  184. {scar_cli-0.29.0 → scar_cli-0.30.0}/website/docs/index.md +0 -0
  185. {scar_cli-0.29.0 → scar_cli-0.30.0}/website/docs/methodology.md +0 -0
  186. {scar_cli-0.29.0 → scar_cli-0.30.0}/website/docs/quickstart.md +0 -0
  187. {scar_cli-0.29.0 → scar_cli-0.30.0}/website/docusaurus.config.ts +0 -0
  188. {scar_cli-0.29.0 → scar_cli-0.30.0}/website/package-lock.json +0 -0
  189. {scar_cli-0.29.0 → scar_cli-0.30.0}/website/package.json +0 -0
  190. {scar_cli-0.29.0 → scar_cli-0.30.0}/website/scripts/sync-changelog.mjs +0 -0
  191. {scar_cli-0.29.0 → scar_cli-0.30.0}/website/sidebars.ts +0 -0
  192. {scar_cli-0.29.0 → scar_cli-0.30.0}/website/src/css/custom.css +0 -0
  193. {scar_cli-0.29.0 → scar_cli-0.30.0}/website/static/img/favicon.svg +0 -0
  194. {scar_cli-0.29.0 → scar_cli-0.30.0}/website/static/img/social-card.png +0 -0
  195. {scar_cli-0.29.0 → scar_cli-0.30.0}/website/static/llms.txt +0 -0
  196. {scar_cli-0.29.0 → scar_cli-0.30.0}/website/tsconfig.json +0 -0
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "0.30.0"
3
+ }
@@ -10,7 +10,7 @@ anchors:
10
10
  - path: experiments/anchor-survival/
11
11
  - path: src/scar/harvest.py
12
12
  - pattern: "git.{0,20}grep"
13
- violation: "git[^#\n]{0,60}grep[^#\n]{0,80}[\x22\x27][^\x22\x27#\n]{0,40}\\b"
13
+ violation: "git[^#\n]{0,60}grep[^#\n]{0,80}[\x22\x27][^\x22\x27#\n]{0,40}[\\]b"
14
14
  evidence:
15
15
  - note: "orphaned receipt — pre-v0.1.0 commit 5c63b14 produced a fake 0% anchor-survival run before diagnosis (gate 0.2); resolves at github.com/Daily-Nerd/Scar/commit/5c63b14 until GC, not in fresh clones (rewritten at the v0.1.0 release)"
16
16
  expires:
@@ -1,5 +1,31 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.30.0](https://github.com/Daily-Nerd/Scar/compare/v0.29.1...v0.30.0) (2026-11-20)
4
+
5
+
6
+ ### Features
7
+
8
+ * **lint:** report a promotion act that no longer matches its record ([#410](https://github.com/Daily-Nerd/Scar/issues/410)) ([d8dc89a](https://github.com/Daily-Nerd/Scar/commit/d8dc89a55de3c0a066f11f88f2d791976c893c93)), closes [#409](https://github.com/Daily-Nerd/Scar/issues/409)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **lint:** say only what the over-escape check proves and offer both respellings ([#408](https://github.com/Daily-Nerd/Scar/issues/408)) ([3d01d66](https://github.com/Daily-Nerd/Scar/commit/3d01d66d353232699ed50aacf98897872ad5472c)), closes [#407](https://github.com/Daily-Nerd/Scar/issues/407)
14
+
15
+ ## [0.29.1](https://github.com/Daily-Nerd/Scar/compare/v0.29.0...v0.29.1) (2026-11-19)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * **harvest:** keep identifiers and code spans verbatim in candidate titles ([#403](https://github.com/Daily-Nerd/Scar/issues/403)) ([657e752](https://github.com/Daily-Nerd/Scar/commit/657e752a52e7955302f9d69b33b0c597cf437438)), closes [#402](https://github.com/Daily-Nerd/Scar/issues/402)
21
+ * **lint:** reject over-escaped regex fields and dead candidate patterns ([#405](https://github.com/Daily-Nerd/Scar/issues/405)) ([fa54514](https://github.com/Daily-Nerd/Scar/commit/fa54514666ff4ec318f0999ac49f7eeed77d2271)), closes [#404](https://github.com/Daily-Nerd/Scar/issues/404)
22
+ * **model:** read authors through one flow-list parser ([#400](https://github.com/Daily-Nerd/Scar/issues/400)) ([2ac838a](https://github.com/Daily-Nerd/Scar/commit/2ac838a134eebc1c801eb412b64d5143fd5b819d))
23
+
24
+
25
+ ### Documentation
26
+
27
+ * **skill:** name the lint error and the [\\] form for a literal backslash ([#406](https://github.com/Daily-Nerd/Scar/issues/406)) ([506dd84](https://github.com/Daily-Nerd/Scar/commit/506dd84f976b80e6438488899a79706cdba730d5)), closes [#404](https://github.com/Daily-Nerd/Scar/issues/404)
28
+
3
29
  ## [0.29.0](https://github.com/Daily-Nerd/Scar/compare/v0.28.0...v0.29.0) (2026-11-18)
4
30
 
5
31
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: scar-cli
3
- Version: 0.29.0
3
+ Version: 0.30.0
4
4
  Summary: SCAR — version control for negative knowledge (deadends, fences, landmines)
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scar",
3
- "version": "0.29.0",
3
+ "version": "0.30.0",
4
4
  "description": "SCAR — version control for negative knowledge (deadends, fences, landmines)",
5
5
  "hooks": {
6
6
  "PreToolUse": [
@@ -92,6 +92,14 @@ must use a `pattern:` regex, know that the value reaches the matcher
92
92
  **verbatim** — this reader is not a YAML parser and nothing un-escapes. Write
93
93
  the regex exactly as it must execute: `\b` stays `\b`, `\(` stays `\(`.
94
94
  Doubling backslashes "for YAML" yields a literal backslash and a dead anchor.
95
+ `scar lint` rejects it as an error. The value matches a literal backslash
96
+ followed by the next character, which lint cannot tell from a slip, so the
97
+ message prints two respellings. The halved form (`\\w` becomes `\w`) is for
98
+ when you meant the escape. The class form, with each doubled pair written as
99
+ `[\\]`, is for when the target text really holds a backslash, such as regex
100
+ source inside a raw string. To guard `r"[\w-]*(?:api|key)"` write
101
+ `\[[\\]w-\]\*\(\?:api`, not `\[\w-\]\*\(\?:api`, which does not match it.
102
+ Lint accepts the class form.
95
103
 
96
104
  The pattern is also matched against all tracked content **including the scar's
97
105
  own body**, so a broken pattern keeps itself alive by self-reference. Run
@@ -128,7 +136,9 @@ the fired→violated compliance metric).
128
136
  - **The regex is RAW.** Surrounding quotes are stripped; nothing else
129
137
  un-escapes. Write it exactly as it must execute — `\b` stays `\b`, `\(`
130
138
  stays `\(`. Doubling backslashes "for YAML" is the over-escape trap that
131
- kills pattern anchors, and it kills violation regexes the same way.
139
+ kills pattern anchors, and it kills violation regexes the same way. The
140
+ same lint error and the same two respellings (halved or `[\\]`) apply
141
+ (see Anti-Over-Escape).
132
142
  - **Prove both cases.** Before finishing, run a synthetic
133
143
  `scar check --diff` twice: once with a diff that MUST fire the violation,
134
144
  once with an innocent diff that must NOT. A tripwire verified only on the
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "scar-cli"
3
- version = "0.29.0"
3
+ version = "0.30.0"
4
4
  description = "SCAR — version control for negative knowledge (deadends, fences, landmines)"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -793,7 +793,7 @@ def _cmd_lint(args) -> int:
793
793
  # and an error would block promotion on a judgment call.
794
794
  if ctx is not None:
795
795
  from .match import _anchor_signal, _pattern_anchor_matches
796
- from .orphan import _path_anchor_live
796
+ from .orphan import _path_anchor_live, _pattern_anchor_live
797
797
 
798
798
  # A violation that can never arm. The matcher arms a violation only
799
799
  # when _anchor_signal is positive on an edited PATH with empty content,
@@ -831,6 +831,21 @@ def _cmd_lint(args) -> int:
831
831
  "warning", f"candidate path anchor '{anchor}' matches "
832
832
  "no tracked file; before promotion, check the path "
833
833
  "(a scar anchored to nothing never fires)")]))
834
+ # The same for a pattern anchor, through the liveness check the
835
+ # orphan scan uses (whole body, candidate's own file excluded so
836
+ # it cannot vouch for itself). An uncompilable regex is already
837
+ # a lint error; do not also call it dead.
838
+ for pattern in parsed.pattern_anchors:
839
+ try:
840
+ re.compile(pattern)
841
+ except re.error:
842
+ continue
843
+ if not _pattern_anchor_live(pattern, ctx, exclude_path=rel):
844
+ findings_by_file.append((rel, [Finding(
845
+ "warning", f"candidate pattern anchor /{pattern}/ "
846
+ "matches no tracked file; before promotion, check the "
847
+ "regex against the code it must catch (a scar anchored "
848
+ "to nothing never fires)")]))
834
849
 
835
850
  # Broad pattern anchors: the path-breadth rule above, applied to the
836
851
  # pattern anchors it ignores. A pattern is matched against the path
@@ -3125,15 +3140,15 @@ def _write_anchors(repo: Path, section: str, c: dict, tracked: set[str]) -> list
3125
3140
 
3126
3141
 
3127
3142
  def _write_title(section: str, c: dict) -> str:
3143
+ """Only a revert subject is free text. Keys, files, components and
3144
+ locations are identifiers and go in unchanged (#402)."""
3128
3145
  if section == "reverts":
3129
- raw = f"Reverted: {c['subject']}"
3130
- elif section == "deleted_components":
3131
- raw = f"Deleted component: {c['component']}"
3132
- elif section == "flapping":
3133
- raw = f"Flapping value {c['key']} in {c['file']}"
3134
- else:
3135
- raw = "Keep-out comment in " + c["location"].split(":", 1)[0]
3136
- return sanitize_signal_text(raw)
3146
+ return "Reverted: " + sanitize_signal_text(c["subject"])
3147
+ if section == "deleted_components":
3148
+ return f"Deleted component: {c['component']}"
3149
+ if section == "flapping":
3150
+ return f"Flapping value {c['key']} in {c['file']}"
3151
+ return "Keep-out comment in " + c["location"].split(":", 1)[0]
3137
3152
 
3138
3153
 
3139
3154
  def _write_evidence(section: str, c: dict) -> str:
@@ -8,9 +8,10 @@ from __future__ import annotations
8
8
  import re
9
9
  from dataclasses import dataclass
10
10
 
11
- from . import clock, symbols
11
+ from . import clock, presence, symbols
12
12
  from .config import Config, signing_problem
13
13
  from .model import SEVERITIES, STATUSES, TYPES, ParseError, Scar, is_valid_url, parse_scar_text
14
+ from .record import record_hash
14
15
 
15
16
 
16
17
  # A valid regex can still be a ReDoS weapon. re.compile accepts it (the syntax
@@ -126,6 +127,119 @@ def _is_redos_prone(pattern: str) -> bool:
126
127
  return False
127
128
 
128
129
 
130
+ # #404: the reader takes regex fields verbatim (no YAML unescaping), so a
131
+ # doubled backslash before a regex escape or metacharacter is a literal
132
+ # backslash followed by that character. It compiles and is not ReDoS-prone.
133
+ # Usually the author meant the escape, but a target that really holds a
134
+ # backslash (regex source in a raw string) is matched by the doubled form, so
135
+ # the check only claims what the spelling proves.
136
+ _OVERESCAPE_NEXT = frozenset("()[]{}.*+?|^$bBsSwWdD")
137
+
138
+
139
+ def _overescape_runs(pattern: str) -> list[tuple[int, int]]:
140
+ """(start, length) of each over-escaped backslash run in *pattern*.
141
+
142
+ A backslash run is read left to right: an odd run ends in a real escape
143
+ (the last backslash binds the next character) and is never flagged; an
144
+ even run is only literal backslashes, so the character after it is
145
+ unescaped. An even run of two or more directly before a character in
146
+ _OVERESCAPE_NEXT is flagged, which covers four backslashes too: they
147
+ mean two literal backslashes and then a live metacharacter, almost never
148
+ intended. A run at the very end of the string, or before an ordinary
149
+ character, is a legitimate literal backslash and is not flagged.
150
+
151
+ Runs inside a character class are skipped, structurally: `[\\\\]` is the
152
+ sanctioned way to say "a literal backslash" and must stay clean, so the
153
+ escape hatch is the class itself, not a string match on its spelling.
154
+ """
155
+ runs: list[tuple[int, int]] = []
156
+ in_class = False
157
+ i, n = 0, len(pattern)
158
+ while i < n:
159
+ c = pattern[i]
160
+ if c == "\\":
161
+ j = i
162
+ while j < n and pattern[j] == "\\":
163
+ j += 1
164
+ length = j - i
165
+ if (not in_class and length % 2 == 0 and j < n
166
+ and pattern[j] in _OVERESCAPE_NEXT):
167
+ runs.append((i, length))
168
+ # Odd run: the last backslash escapes pattern[j], so it can
169
+ # neither open nor close a class. Even run: pattern[j] is live.
170
+ i = j + 1 if length % 2 else j
171
+ continue
172
+ if in_class:
173
+ if c == "]":
174
+ in_class = False
175
+ elif c == "[":
176
+ in_class = True
177
+ # A leading "^" and then "]" are literal members of the class.
178
+ if i + 1 < n and pattern[i + 1] == "^":
179
+ i += 1
180
+ if i + 1 < n and pattern[i + 1] == "]":
181
+ i += 1
182
+ i += 1
183
+ return runs
184
+
185
+
186
+ def _overescape_respellings(pattern: str) -> tuple[str, str] | None:
187
+ """(halved, class form) for an over-escaped *pattern*, or None when clean.
188
+
189
+ Both rewrite only the flagged runs. The halved form is for an author who
190
+ meant the escape. The class form puts each doubled pair in `[\\\\]`, for
191
+ an author who meant a real backslash: it matches the same text as the
192
+ original, and the class is the spelling the rule accepts.
193
+ """
194
+ runs = _overescape_runs(pattern)
195
+ if not runs:
196
+ return None
197
+ halved, classed, last = [], [], 0
198
+ for start, length in runs:
199
+ gap = pattern[last:start]
200
+ halved.append(gap)
201
+ classed.append(gap)
202
+ halved.append("\\" * (length // 2))
203
+ classed.append("[\\\\]" * (length // 2))
204
+ last = start + length
205
+ tail = pattern[last:]
206
+ halved.append(tail)
207
+ classed.append(tail)
208
+ return "".join(halved), "".join(classed)
209
+
210
+
211
+ def _regex_field_findings(label: str, value: str) -> tuple[list[Finding], re.Pattern | None]:
212
+ """The one gate every regex-valued field passes (#404): pattern anchors,
213
+ command anchors, violation and revives_if. Compile, over-escape, ReDoS.
214
+
215
+ Returns the findings and the compiled regex (None when it did not
216
+ compile), so a caller with a field-specific rule can reuse it.
217
+ """
218
+ findings = []
219
+ # Reported even when the regex does not compile: `NewConformance\\(` fails
220
+ # with "missing )", which hides the real cause. Name both.
221
+ respelled = _overescape_respellings(value)
222
+ if respelled is not None:
223
+ halved, classed = respelled
224
+ findings.append(Finding(
225
+ "error", f"over-escaped {label} /{value}/: a doubled backslash "
226
+ "before a regex escape or metacharacter matches a literal "
227
+ "backslash followed by that character, not the regex escape (the "
228
+ "value is read verbatim, nothing un-escapes it). If you meant "
229
+ f"the escape, write /{halved}/. If the text really contains a "
230
+ f"backslash, write /{classed}/"))
231
+ try:
232
+ rx = re.compile(value)
233
+ except re.error as exc:
234
+ findings.append(Finding("error", f"invalid {label} /{value}/: {exc}"))
235
+ return findings, None
236
+ if _is_redos_prone(value):
237
+ findings.append(Finding(
238
+ "error", f"pathological {label} /{value}/: nested quantifier "
239
+ "risks catastrophic backtracking (ReDoS) — simplify the regex"))
240
+ return findings, rx
241
+
242
+
129
243
  # The model extracts `path`/`pattern`/`symbol` anchors; any other anchor key is
130
244
  # silently dropped, so a SPEC-following author who writes `- touch:` or
131
245
  # `- breaks:` gets false protection (the scar never fires on that anchor).
@@ -200,6 +314,9 @@ def downgrade_findings(scars: list[tuple[str, Scar]], cfg: Config,
200
314
  - an act with no org in the config (the org was deleted);
201
315
  - an org, and a scar at or after signed_from with no act (the act was
202
316
  dropped, or the scar was promoted around signing).
317
+ - an act whose inputs_hash is not the hash of the scar's current record
318
+ (#409): the record was changed after signing. Only a mismatch is
319
+ reported; a match proves nothing about the signature.
203
320
  It reads no signature: whether an act is genuine is the checker's job."""
204
321
  out: list[tuple[str, Finding]] = []
205
322
  if cfg.org is None:
@@ -212,6 +329,23 @@ def downgrade_findings(scars: list[tuple[str, Scar]], cfg: Config,
212
329
  problem = signing_problem(cfg, next_id)
213
330
  if problem:
214
331
  out.append((CONFIG_REL, Finding("error", problem)))
332
+ # With no org (returned above) the act is already an error for that cause,
333
+ # so staleness is only judged once an org exists: one cause, one error.
334
+ for rel, scar in scars:
335
+ if not scar.promotion_act or scar.id is None:
336
+ continue
337
+ try:
338
+ signed = presence.act_inputs_hash(scar.promotion_act)
339
+ except presence.MalformedAct as exc:
340
+ out.append((rel, Finding(
341
+ "error", f"scar {scar.id} carries a promotion_act that cannot be read "
342
+ f"({exc.reason}); it cannot be compared with the record")))
343
+ continue
344
+ if signed != record_hash(scar):
345
+ out.append((rel, Finding(
346
+ "error", f"scar {scar.id} changed since it was signed: its promotion_act "
347
+ "was made for a different record (id, type, title, severity, promoted_from, "
348
+ "anchors or body), so it needs a new signature")))
215
349
  if cfg.signed_from is not None:
216
350
  for rel, scar in scars:
217
351
  if (scar.status != "candidate" and scar.id is not None
@@ -297,55 +431,26 @@ def lint_text(text: str, today: str | None = None) -> list[Finding]:
297
431
  "warning", "symbol anchors need the [symbols] extra to resolve — "
298
432
  "install scar-cli[symbols], or keep a path/pattern anchor as backup"))
299
433
  for pat in scar.pattern_anchors:
300
- try:
301
- re.compile(pat)
302
- except re.error as exc:
303
- findings.append(Finding("error", f"invalid pattern anchor /{pat}/: {exc}"))
304
- continue
305
- if _is_redos_prone(pat):
306
- findings.append(Finding(
307
- "error", f"pathological pattern anchor /{pat}/: nested quantifier "
308
- "risks catastrophic backtracking (ReDoS) — simplify the regex"))
434
+ findings.extend(_regex_field_findings("pattern anchor", pat)[0])
309
435
  for cmd in scar.command_anchors:
310
- try:
311
- rx = re.compile(cmd)
312
- except re.error as exc:
313
- findings.append(Finding("error", f"invalid command anchor /{cmd}/: {exc}"))
314
- continue
315
- if rx.search(""):
436
+ cmd_findings, rx = _regex_field_findings("command anchor", cmd)
437
+ findings.extend(cmd_findings)
438
+ if rx is not None and rx.search(""):
316
439
  findings.append(Finding(
317
440
  "error", f"command anchor /{cmd}/ matches the empty string — it "
318
441
  "would fire on every command; anchor a concrete command shape"))
319
- if _is_redos_prone(cmd):
320
- findings.append(Finding(
321
- "error", f"pathological command anchor /{cmd}/: nested quantifier "
322
- "risks catastrophic backtracking (ReDoS) — simplify the regex"))
323
442
  if scar.violation:
324
- try:
325
- re.compile(scar.violation)
326
- except re.error as exc:
327
- findings.append(Finding("error", f"invalid violation /{scar.violation}/: {exc}"))
328
- else:
329
- if _is_redos_prone(scar.violation):
330
- findings.append(Finding(
331
- "error", f"pathological violation /{scar.violation}/: nested quantifier "
332
- "risks catastrophic backtracking (ReDoS) — simplify the regex"))
443
+ findings.extend(_regex_field_findings("violation", scar.violation)[0])
333
444
  # revives_if (#205): compiled and matched against tracked content on every
334
445
  # liveness pass, so it carries the same gates as violation. NOT checked for
335
446
  # liveness: a revival predicate matching nothing is the HEALTHY state (the
336
447
  # hazard has not returned) — the #156 reintroduction-guard distinction.
337
448
  if scar.revives_if:
338
- try:
339
- re.compile(scar.revives_if)
340
- except re.error as exc:
341
- findings.append(Finding(
342
- "error", f"invalid revives_if /{scar.revives_if}/: {exc}"))
343
- else:
344
- if _is_redos_prone(scar.revives_if):
345
- findings.append(Finding(
346
- "error", f"pathological revives_if /{scar.revives_if}/: nested "
347
- "quantifier risks catastrophic backtracking (ReDoS) — simplify "
348
- "the regex"))
449
+ findings.extend(_regex_field_findings("revives_if", scar.revives_if)[0])
450
+ for name in scar.unreadable_fields:
451
+ findings.append(Finding(
452
+ "error", f"{name} is not a well-formed flow list (expected "
453
+ f'[\"a\", \"b\"] on one line): it was read as empty'))
349
454
  if scar.status == "candidate":
350
455
  findings.extend(_candidate_author_findings(scar.authors))
351
456
  # Author identity drift (#182): one handle, two casings = one human
@@ -187,8 +187,8 @@ TOOLS = [
187
187
  "Write a candidate scar to .scars/candidates/ for human promotion. "
188
188
  "Use for negative knowledge: deadend (tried+failed), fence (looks "
189
189
  "wrong but intentional), or landmine (touching A breaks B). Prefer a "
190
- "path: anchor — pattern: regexes over-escape in YAML and silently "
191
- "self-match. Writes only to candidates/ and lints before writing; a "
190
+ "path: anchor; pattern: regexes are read verbatim, and a doubled "
191
+ "backslash in one means a literal backslash. Writes only to candidates/ and lints before writing; a "
192
192
  "human promotes. See the scar-authoring skill (scar agent skill)."
193
193
  ),
194
194
  "inputSchema": {
@@ -38,6 +38,9 @@ class Scar:
38
38
  confidence: float = 0.5
39
39
  created: str = ""
40
40
  authors: list[str] = field(default_factory=list)
41
+ # Names of one-line list fields that were present but not well-formed
42
+ # (filled by the parser, never written by to_text). Lint reports them.
43
+ unreadable_fields: list[str] = field(default_factory=list)
41
44
  # #287: who VOUCHED, distinct from who drafted. Written only by promote,
42
45
  # which overwrites whatever a candidate carried. Empty on every scar
43
46
  # promoted before the field existed, and never inferred from authors:
@@ -190,6 +193,56 @@ def _scalar(front: str, name: str, default: str = "", strip_comment: bool = True
190
193
  return _unquote(_field(front, name, default, strip_comment))
191
194
 
192
195
 
196
+ _FLOW_ITEM_RE = re.compile(r"""\s*(?:"(.*?)"|'(.*?)'|([^,\]"'\[][^,\]]*?))\s*(?=[,\]])""")
197
+
198
+
199
+ def _split_flow_list(raw: str) -> list[str] | None:
200
+ """Items of a one-line YAML flow list, or None when it is not well formed.
201
+ Commas inside a quoted item are data, a quoted item closes at the first
202
+ quote followed by ',' or ']', and a " # comment" after the closing ']'
203
+ is dropped. Nothing is guessed: any other shape is None."""
204
+ s = raw.strip()
205
+ if not s.startswith("["):
206
+ return None
207
+ items: list[str] = []
208
+ i = 1
209
+ while True:
210
+ while s[i:i + 1].isspace():
211
+ i += 1
212
+ if s[i:i + 1] == "]":
213
+ break
214
+ m = _FLOW_ITEM_RE.match(s, i)
215
+ if not m:
216
+ return None
217
+ dq, sq, bare = m.groups()
218
+ item = dq if dq is not None else sq if sq is not None else bare.strip()
219
+ if bare is not None and (not item or re.search(r"\s#", item)):
220
+ return None
221
+ items.append(item)
222
+ i = m.end()
223
+ if s[i] == ",":
224
+ i += 1
225
+ tail = s[i + 1:]
226
+ if tail and not _TRAILING_COMMENT_RE.fullmatch(tail):
227
+ return None
228
+ return items
229
+
230
+
231
+ def _flow_list(front: str, name: str, unreadable: list[str]) -> list[str]:
232
+ """The ONE read path for a one-line flow-list field (the sibling of
233
+ _scalar). Absent is []. Present but malformed is [] too, and the name is
234
+ appended to `unreadable` so lint can say so: never a best guess, never a
235
+ ParseError (that would stop an otherwise good scar from firing)."""
236
+ raw = _field(front, name, strip_comment=False)
237
+ if not raw:
238
+ return []
239
+ items = _split_flow_list(raw)
240
+ if items is None:
241
+ unreadable.append(name)
242
+ return []
243
+ return items
244
+
245
+
193
246
  def _int_or_none(raw: str) -> int | None:
194
247
  """A non-negative int, or None when absent/unparseable. An unparseable
195
248
  value must NOT become 0: 0 means "never escalate", so coercing garbage to
@@ -220,9 +273,8 @@ def parse_scar_text(text: str) -> Scar:
220
273
  except ValueError:
221
274
  scar_id = None
222
275
 
223
- authors_raw = _field(front, "authors")
224
- authors = [_unquote(a.strip())
225
- for a in authors_raw.strip("[]").split(",") if a.strip()] if authors_raw else []
276
+ unreadable: list[str] = []
277
+ authors = _flow_list(front, "authors", unreadable)
226
278
 
227
279
  # Evidence values get the same inline-comment strip as scalar fields (#69,
228
280
  # #144): the template documents evidence lines WITH trailing comments, and
@@ -241,6 +293,7 @@ def parse_scar_text(text: str) -> Scar:
241
293
  confidence=confidence,
242
294
  created=_scalar(front, "created"),
243
295
  authors=authors,
296
+ unreadable_fields=unreadable,
244
297
  promoted_by=_scalar(front, "promoted_by"),
245
298
  promoted_by_source=_scalar(front, "promoted_by_source") or None,
246
299
  promotion_act=_scalar(front, "promotion_act"),
@@ -48,6 +48,10 @@ class PresenceError(Exception):
48
48
  self.reason = reason
49
49
 
50
50
 
51
+ class MalformedAct(PresenceError):
52
+ """A stored act whose payload cannot be read. `reason` says which part."""
53
+
54
+
51
55
  class Unavailable(PresenceError):
52
56
  """No usable answer: the program is missing, crashed, timed out, or said
53
57
  something that is not its documented output. Nothing is assumed."""
@@ -61,6 +65,31 @@ class Cancelled(PresenceError):
61
65
  """The person declined the touch (signer exit 1)."""
62
66
 
63
67
 
68
+ def act_inputs_hash(jws: str) -> str:
69
+ """The `inputs_hash` in a stored act's payload. Decodes only: the
70
+ signature is not looked at, so a result proves nothing about the act being
71
+ genuine (that is the checker's job). Raises MalformedAct when the act is not
72
+ three segments, the payload is not base64url JSON object, or it carries no
73
+ non-empty string `inputs_hash`."""
74
+ parts = jws.split(".") if isinstance(jws, str) else []
75
+ if len(parts) != 3:
76
+ raise MalformedAct("not a compact JWS of three segments")
77
+ segment = parts[1]
78
+ try:
79
+ raw = base64.b64decode(
80
+ segment.replace("-", "+").replace("_", "/") + "=" * (-len(segment) % 4),
81
+ validate=True)
82
+ payload = json.loads(raw.decode("utf-8"))
83
+ except (ValueError, UnicodeDecodeError):
84
+ raise MalformedAct("payload is not base64url-encoded JSON") from None
85
+ if not isinstance(payload, dict):
86
+ raise MalformedAct("payload is not a JSON object")
87
+ value = payload.get("inputs_hash")
88
+ if not isinstance(value, str) or not value:
89
+ raise MalformedAct("payload has no inputs_hash")
90
+ return value
91
+
92
+
64
93
  def _canonical(payload: dict) -> str:
65
94
  # The signer reads its stdin through the canonical subset: no whitespace,
66
95
  # no numbers, no booleans. Sorted keys, compact, ASCII.
@@ -11,6 +11,8 @@ size check here; the signer refuses an oversize record before any confirmation.
11
11
  """
12
12
  from __future__ import annotations
13
13
 
14
+ import base64
15
+ import hashlib
14
16
  import subprocess
15
17
  from pathlib import Path
16
18
 
@@ -58,3 +60,12 @@ def promoted_record(scar: Scar) -> bytes:
58
60
  body = scar.body.replace("\r\n", "\n").replace("\r", "\n").rstrip()
59
61
  lines += ["---", body]
60
62
  return ("\n".join(lines) + "\n").encode("utf-8")
63
+
64
+
65
+ def record_hash(scar: Scar) -> str:
66
+ """The hash string an act stores as `inputs_hash` for this scar's record:
67
+ "u" plus unpadded base64url of 0x12 0x20 (sha256 multihash prefix) and the
68
+ sha256 of promoted_record(). Computed from the file every time, never
69
+ stored, so an act can be compared against the record it sits on."""
70
+ digest = hashlib.sha256(promoted_record(scar)).digest()
71
+ return "u" + base64.urlsafe_b64encode(b"\x12\x20" + digest).decode("ascii").rstrip("=")
@@ -92,6 +92,14 @@ must use a `pattern:` regex, know that the value reaches the matcher
92
92
  **verbatim** — this reader is not a YAML parser and nothing un-escapes. Write
93
93
  the regex exactly as it must execute: `\b` stays `\b`, `\(` stays `\(`.
94
94
  Doubling backslashes "for YAML" yields a literal backslash and a dead anchor.
95
+ `scar lint` rejects it as an error. The value matches a literal backslash
96
+ followed by the next character, which lint cannot tell from a slip, so the
97
+ message prints two respellings. The halved form (`\\w` becomes `\w`) is for
98
+ when you meant the escape. The class form, with each doubled pair written as
99
+ `[\\]`, is for when the target text really holds a backslash, such as regex
100
+ source inside a raw string. To guard `r"[\w-]*(?:api|key)"` write
101
+ `\[[\\]w-\]\*\(\?:api`, not `\[\w-\]\*\(\?:api`, which does not match it.
102
+ Lint accepts the class form.
95
103
 
96
104
  The pattern is also matched against all tracked content **including the scar's
97
105
  own body**, so a broken pattern keeps itself alive by self-reference. Run
@@ -128,7 +136,9 @@ the fired→violated compliance metric).
128
136
  - **The regex is RAW.** Surrounding quotes are stripped; nothing else
129
137
  un-escapes. Write it exactly as it must execute — `\b` stays `\b`, `\(`
130
138
  stays `\(`. Doubling backslashes "for YAML" is the over-escape trap that
131
- kills pattern anchors, and it kills violation regexes the same way.
139
+ kills pattern anchors, and it kills violation regexes the same way. The
140
+ same lint error and the same two respellings (halved or `[\\]`) apply
141
+ (see Anti-Over-Escape).
132
142
  - **Prove both cases.** Before finishing, run a synthetic
133
143
  `scar check --diff` twice: once with a diff that MUST fire the violation,
134
144
  once with an innocent diff that must NOT. A tripwire verified only on the