@chrono-meta/fh-gate 3.27.0 → 3.29.0
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.
- package/.claude-plugin/marketplace.json +4 -4
- package/CHEATSHEET.md +2 -2
- package/CLAUDE.md +6 -3
- package/README.ja.md +2 -4
- package/README.ko.md +2 -4
- package/README.md +19 -19
- package/README.zh.md +2 -4
- package/docs/REFERENCE.md +4 -1
- package/knowledge/shared/harness-core/claude_md_full_reference.md +2 -0
- package/knowledge/shared/harness-core/claude_md_gate_details.md +7 -0
- package/knowledge/shared/harness-core/dispatch_conditional_prohibition.md +12 -0
- package/knowledge/shared/harness-core/fh_module_contract.md +97 -0
- package/knowledge/shared/harness-core/fh_three_layer_canon.md +12 -0
- package/knowledge/shared/harness-core/measurement-integrity-checklist.md +16 -0
- package/knowledge/shared/learnings/subagent_invocations_log.yaml +137 -0
- package/package.json +12 -1
- package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-commons/skills/ko-tech-writer/SKILL.md +84 -4
- package/plugins/fh-commons/skills/ko-tech-writer/fh-module.yaml +19 -0
- package/plugins/fh-commons/skills/ko-tech-writer/fixtures/known_negative.md +73 -1
- package/plugins/fh-commons/skills/ko-tech-writer/fixtures/known_positive.md +39 -1
- package/plugins/fh-commons/skills/ko-tech-writer/fixtures/known_unclosed.md +6 -0
- package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-meta/CHANGELOG.md +32 -0
- package/plugins/fh-meta/skills/auto-decorrelation/SKILL.md +17 -0
- package/plugins/fh-meta/skills/frontier-digest/SKILL.md +14 -10
- package/plugins/fh-meta/skills/frontier-digest/SKILL_detail.md +17 -1
- package/plugins/fh-meta/skills/sim-conductor/SKILL.md +2 -2
- package/plugins/fh-meta/skills/sim-conductor/SKILL_detail.md +3 -3
- package/plugins/fh-meta/skills/steel-quench/SKILL.md +25 -1
- package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
- package/scripts/degrade_direction_scan.sh +43 -0
- package/scripts/dispatch_receipt.py +185 -0
- package/scripts/doc_claim_triad_scan.py +43 -4
- package/scripts/fh-gate.sh +71 -11
- package/scripts/fh_module_check.py +686 -0
- package/scripts/finding_fleet.sh +15 -3
- package/scripts/fixtures/frontier_digest_recall.tsv +5 -0
- package/scripts/ko_tech_writer_calibrate.py +288 -15
- package/scripts/package_coverage_check.sh +5 -0
- package/scripts/probe_live_eval.sh +19 -1
- package/scripts/probe_live_eval_lib.py +174 -5
- package/scripts/resident_cost.py +1 -1
- package/scripts/selfcheck.sh +48 -21
- package/scripts/session_checklist.py +214 -5
- package/scripts/session_close_check.sh +44 -0
- package/scripts/sim_isolated_run.sh +31 -0
- package/scripts/test_claude_md_size_lanes.sh +22 -7
- package/scripts/test_degrade_scan_shell_probes.sh +81 -0
- package/scripts/test_dispatch_receipt_lanes.sh +95 -0
- package/scripts/test_doc_claim_triad_lanes.sh +30 -0
- package/scripts/test_fh_audit_check_lanes.sh +10 -5
- package/scripts/test_fh_gate_regressions.sh +71 -1
- package/scripts/test_fh_module_check_lanes.sh +581 -0
- package/scripts/test_finding_pipeline_lanes.sh +83 -0
- package/scripts/test_frontier_digest_recall.sh +26 -0
- package/scripts/test_frontier_digest_recall_negctl.sh +15 -0
- package/scripts/test_ko_tech_writer_lanes.sh +1 -1
- package/scripts/test_locale_invariance_lanes.sh +19 -0
- package/scripts/test_mutation_probe_lanes.sh +22 -6
- package/scripts/test_probe_live_eval_lanes.sh +116 -0
- package/scripts/test_resident_cost_lanes.sh +1 -1
- package/scripts/test_selfcheck_state_lanes.sh +32 -0
- package/scripts/test_session_checklist_lanes.sh +167 -0
- package/scripts/test_sim_isolated_run_lanes.sh +51 -0
- package/scripts/test_utterance_checklist_hook_lanes.sh +175 -0
- package/scripts/utterance_checklist_hook.py +193 -0
- package/scripts/utterance_checklist_hook.sh +31 -0
- package/templates/PRE-PUBLISH-CHECKLIST.md +10 -0
- package/templates/degrade_direction_scan.sh +43 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: frontier-digest
|
|
3
|
-
description: Collects the latest AI/harness engineering trends from HackerNews and
|
|
3
|
+
description: Collects the latest AI/harness engineering trends from HackerNews, arxiv, launch channels (Launch YC, Product Hunt, Show HN), GeekNews and vendor changelogs, then synthesizes them into actionable insights directly relevant to forge-harness operations. Triggered by "AI trends", "latest trends", "this week's AI updates", "what's on the frontier", "harness trends", "frontier-digest".
|
|
4
4
|
user-invocable: true
|
|
5
5
|
allowed-tools: ["Bash", "WebFetch", "WebSearch", "Write"]
|
|
6
6
|
model: sonnet
|
|
@@ -8,7 +8,7 @@ model: sonnet
|
|
|
8
8
|
|
|
9
9
|
# frontier-digest — FH Frontier Insight Collection & Synthesis
|
|
10
10
|
|
|
11
|
-
> Automatically collects the latest AI/agent/harness engineering trends from HackerNews and
|
|
11
|
+
> Automatically collects the latest AI/agent/harness engineering trends from HackerNews, arxiv, launch channels, GeekNews and vendor changelogs,
|
|
12
12
|
> then compresses and synthesizes them into insights directly relevant to forge-harness skills and structure.
|
|
13
13
|
|
|
14
14
|
## Triggers
|
|
@@ -65,17 +65,21 @@ On **cadence-triggered** runs (7d), ask the operator one line before collecting:
|
|
|
65
65
|
|
|
66
66
|
## Step 1. Data Collection
|
|
67
67
|
|
|
68
|
-
Collect from
|
|
68
|
+
Collect from the sources below (bash/endpoint per source in §Collection-Bash). The backticked `id` is the channel identity the recall lane (`scripts/test_frontier_digest_recall.sh`) checks — keep it when editing a row:
|
|
69
69
|
|
|
70
70
|
| Source | Method | Cap |
|
|
71
71
|
|---|---|---|
|
|
72
|
-
| HackerNews | Algolia API `search_by_date` (date-sorted, never `/search`), score > 30, keyword-relevant | 15 items |
|
|
73
|
-
| arxiv | export API, latest by submittedDate | 6 items |
|
|
74
|
-
| TLDR AI | RSS, title + link | 5 items |
|
|
75
|
-
| The Batch (deeplearning.ai) | HTML scraping, `aria-label` + `/the-batch/issue-N` href (the JSON `slug` shape died 2026-09-11) | 5 items, or `UNMEASURED` |
|
|
76
|
-
| GeekNews (news.hada.io) | Atom feed (`/rss/news` path), title + link, AI/agent/LLM-relevant | 5 items |
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
| HackerNews `hn` | Algolia API `search_by_date` (date-sorted, never `/search`), score > 30, keyword-relevant | 15 items |
|
|
73
|
+
| arxiv `arxiv` | export API, latest by submittedDate | 6 items |
|
|
74
|
+
| TLDR AI `tldr-ai` | RSS, title + link | 5 items |
|
|
75
|
+
| The Batch (deeplearning.ai) `the-batch` | HTML scraping, `aria-label` + `/the-batch/issue-N` href (the JSON `slug` shape died 2026-09-11) | 5 items, or `UNMEASURED` |
|
|
76
|
+
| GeekNews (news.hada.io) `geeknews` | Atom feed (`/rss/news` path), title + link, AI/agent/LLM-relevant | 5 items |
|
|
77
|
+
| Launch YC `launch-yc` | official page `ycombinator.com/launches`, newest launches, AI/agent/dev-tool only | 5 items, or `UNMEASURED` |
|
|
78
|
+
| Product Hunt `product-hunt` | official Atom feeds, categories `artificial-intelligence` and `developer-tools` | 5 items, or `UNMEASURED` |
|
|
79
|
+
| Show HN `show-hn` | Algolia `search_by_date` with `tags=show_hn`, points floor lower than the main HN leg | 8 items, or `UNMEASURED` |
|
|
80
|
+
| Vendor changelogs/blogs `vendor-changelogs` | Anthropic, OpenAI, Google DeepMind/Gemini, Meta AI, Cursor — RSS where one exists, else the official news/changelog page | 1-2 per vendor, new since last digest, or `UNMEASURED` |
|
|
81
|
+
|
|
82
|
+
Report progress: `📡 HN 15 items · arxiv 5 items · TLDR 5 items · Batch 5 items · GeekNews 5 items · LaunchYC n · PH n · ShowHN n · Vendors n collected` (a leg that could not be read is `UNMEASURED`, never `0`)
|
|
79
83
|
|
|
80
84
|
> **Detail**: See `SKILL_detail.md §Collection-Bash` — curl commands per source with parsing notes — read when executing Step 1.
|
|
81
85
|
|
|
@@ -172,7 +172,23 @@ curl -s --max-time 8 "https://news.hada.io/rss/news"
|
|
|
172
172
|
|
|
173
173
|
Korean dev-news aggregator (HN-equivalent), AI-heavy. **The `/rss/news` path serves an Atom feed** (`<feed>`/`<entry>`, NOT RSS `<item>` — verified 2026-06-20: 50 `<entry>` elements, 0 `<item>`). Parse `<entry>` → `<title>` + `<link href>`; keep AI/agent/LLM/harness-relevant items only. `/rss/news` is a *general* dev-news feed, so if 0 AI-relevant items remain after filtering, **drop GeekNews from this run's progress line rather than padding to 5**. Endpoint verified HTTP 200 (2026-06-20); `/rss/new` and `/rss/topics` 404 — use `/rss/news`. Max 5 items.
|
|
174
174
|
|
|
175
|
-
|
|
175
|
+
### Launch channels and vendor feeds (added 2026-10-17; ids match SKILL.md Step 1)
|
|
176
|
+
|
|
177
|
+
Why: the digest missed «Aside» (YC-backed agent browser) because HN/arXiv/GitHub-style legs do not carry
|
|
178
|
+
launch announcements. Official pages/feeds only, no scraping that bypasses a site's terms; endpoints below
|
|
179
|
+
were live-checked once on 2026-10-17 (HTTP status · entries counted by `<entry`/`<item`/`objectID`).
|
|
180
|
+
🟥 **Unreadable-leg rule**: a non-200, a challenge/consent page, a JS-only shell, or an empty parse is
|
|
181
|
+
`UNMEASURED (<reason>)` in the progress line — never `0 items`.
|
|
182
|
+
|
|
183
|
+
- **Launch YC (`launch-yc`)**: `https://www.ycombinator.com/launches` — newest launches; keep AI/agent/dev-tool ones. Cite the launch URL. ⚠️ 2026-10-17: HTTP 200 but a 16 KB JS-rendered shell, 0 entries via curl → read it with WebFetch (rendered) or report `UNMEASURED (js shell)`.
|
|
184
|
+
- **Product Hunt (`product-hunt`)**: official Atom feed `https://www.producthunt.com/feed` (2026-10-17: 200, 50 `<entry>`). ⚠️ the `?category=` parameter returned a byte-near-identical feed, so it is not shown to filter — filter by keyword yourself. Parse `<entry>` title + link.
|
|
185
|
+
- **Show HN (`show-hn`)**: `'https://hn.algolia.com/api/v1/search_by_date?tags=show_hn&query=<KW>&hitsPerPage=8&numericFilters=points%3E10'` (quoted; 2026-10-17: 200, 8 hits for «agent») for the same keywords as the HN leg. Cite the HN item id.
|
|
186
|
+
- **GeekNews (`geeknews`)**: unchanged section above (still wired).
|
|
187
|
+
- **Vendor changelogs/blogs (`vendor-changelogs`)**: Feeds: OpenAI `https://openai.com/news/rss.xml` (200, RSS) · Google DeepMind `https://deepmind.google/blog/rss.xml` (200, RSS). HTML pages, no feed found (200, parse with WebFetch): Anthropic `https://www.anthropic.com/news` · Gemini API changelog `https://ai.google.dev/gemini-api/docs/changelog` · Meta AI `https://ai.meta.com/blog/` · Cursor `https://cursor.com/changelog`. Keep entries newer than the previous digest; cite the entry URL.
|
|
188
|
+
|
|
189
|
+
Recall regression: `scripts/test_frontier_digest_recall.sh` against `scripts/fixtures/frontier_digest_recall.tsv` (structural only: each known item must have a channel in the Step 1 list; the channel assignments are expectations, not announcement evidence — do not cite the lane as measured recall).
|
|
190
|
+
|
|
191
|
+
Report progress: `📡 HN 15 items · arxiv 5 items · TLDR 5 items · Batch 5 items · GeekNews 5 items · LaunchYC n · PH n · ShowHN n · Vendors n collected` (a leg that could not be read is `UNMEASURED`, never `0`)
|
|
176
192
|
|
|
177
193
|
---
|
|
178
194
|
|
|
@@ -52,7 +52,7 @@ Proposal format: `"If it's related to [X], should I simulate with /sim-conductor
|
|
|
52
52
|
/sim-conductor E --target <file> # artifact quality review (post-pipeline)
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
**Frequency limits**: Area A after asset changes or manual trigger · Area B **min 7-day interval** (executor-applied guard: stop a re-run inside 7 days) ·
|
|
55
|
+
**Frequency limits**: Area A after asset changes or manual trigger · Area B **min 7-day interval** (executor-applied guard: stop a re-run inside 7 days) · **event-bound, no periodic cadence** (operator decision 2026-10-19): run Area B before a minor/major release or a public announcement — the moment an outside reader's view pays — unless one already ran since the previous minor release. The trigger lives in `templates/PRE-PUBLISH-CHECKLIST.md §Read it as a reader`; `fh_audit_check.zsh` no longer nags on a 30-day clock · Area C/D/E no limit. Why: per-change 4-axis gates with a cross-family reviewer, the nightly live-eval and the weekly harvest cover what a monthly whole-plugin pass used to; what only Area B sees (whole-set naming gaps, an outsider's first read) matters at publication.
|
|
56
56
|
|
|
57
57
|
---
|
|
58
58
|
|
|
@@ -62,7 +62,7 @@ Auto-detect harness root, sync sim clone if present, set `$REPORT_DIR`.
|
|
|
62
62
|
|
|
63
63
|
> **Detail**: See `SKILL_detail.md §Step0-Bash` — harness root detection, sim clone sync, report dir creation — read when executing Step 0.
|
|
64
64
|
|
|
65
|
-
**Area B frequency check** (the 7-day *minimum* interval
|
|
65
|
+
**Area B frequency check** (the 7-day *minimum* interval): Before running Area B, inspect the latest Area B report in `$REPORT_DIR`; if it is less than 7 days old, stop and report its date. This is an executor-applied procedure, not an automatic shell gate. No report in the selected `$REPORT_DIR` → treat as first run for this check. There is no maximum-interval reminder any more — when to run is decided by the release/announcement event above.
|
|
66
66
|
|
|
67
67
|
---
|
|
68
68
|
|
|
@@ -27,8 +27,8 @@ mkdir -p "$REPORT_DIR"
|
|
|
27
27
|
```bash
|
|
28
28
|
ls "$REPORT_DIR"/sim_*_area_B*.md 2>/dev/null | sort | tail -1
|
|
29
29
|
# Executor: if the latest report is <7 days old, output warning + stop (manual procedure, not shell-enforced).
|
|
30
|
-
#
|
|
31
|
-
#
|
|
30
|
+
# No periodic reminder since 2026-10-19 — Area B is event-bound (before a minor/major release
|
|
31
|
+
# or a public announcement; templates/PRE-PUBLISH-CHECKLIST.md §Read it as a reader).
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
---
|
|
@@ -219,7 +219,7 @@ Claude blind spots (external-only findings):
|
|
|
219
219
|
|
|
220
220
|
Structural methods to reduce self-reference risk in Area B:
|
|
221
221
|
|
|
222
|
-
1. **
|
|
222
|
+
1. **Adversarial attacks at publication**: Area B before a minor/major release or a public announcement (event-bound since 2026-10-19 — no monthly cadence; the executor-applied 7-day check in SKILL.md is the minimum interval) + `challenger` attack in the same run. Route challenger → defense results directly into SKILL.md via steel-quench handoff after Area B ends.
|
|
223
223
|
2. **Direct external user validation**: Non-owner attempts install + invocation → collect reactions. (cascade β validated: first autonomous external run confirmed.)
|
|
224
224
|
3. **steel-quench integration**: After Area B ends, hand off challenger findings to `/steel-quench` for deeper adversarial review + SKILL.md inscription.
|
|
225
225
|
4. **Dual validation principle**: Internal validation (Area B) alone is insufficient — minimized only when combined with external install reaction collection or cross-model validation. **For risk≥medium targets this is no longer advisory: it is the hard Cross-Model Coverage Gate** (SKILL.md Step 0.6) — at least one persona from outside the orchestrator's session context (external CLI → cross-session Claude → else `cross_model_coverage: NONE` withdraws auto-commit). Promoted from advisory to gate by the judge-robustness swarm (2026-06-13): a homogeneous same-session panel shares blind spots, so its clean verdict cannot self-certify.
|
|
@@ -525,7 +525,8 @@ over **unchanged** code:
|
|
|
525
525
|
terminal) or run one more round over the trimmed artifact before declaring Done.
|
|
526
526
|
2. **Record the per-round yield vector** in the Axis-2 marker — `axis2-rounds: 4A / 3A+1B / 2A /
|
|
527
527
|
0A+3B / 1A+2B`. It is what makes the stop decision auditable afterwards, and a flat or rising
|
|
528
|
-
vector is criterion 4's
|
|
528
|
+
vector is the input to criterion 4's reduce-the-design branch (its premise-attack branch fires on
|
|
529
|
+
shared assumptions, whatever the vector).
|
|
529
530
|
|
|
530
531
|
**PIN THE TARGET — mandatory on every dispatched Wave, and the reason criterion 1 can be trusted
|
|
531
532
|
at all.** The dispatch prompt carries a measured fingerprint and orders the agent to report
|
|
@@ -584,6 +585,29 @@ over **unchanged** code:
|
|
|
584
585
|
stays flat is not telling you to review harder; it is telling you that each round's repairs are
|
|
585
586
|
manufacturing the next round's findings. Cut the scope that is generating them (see the
|
|
586
587
|
Added-Scope Gate in `.claude/rules/fh_4axis_gate.md`) and re-audit the smaller artifact.
|
|
588
|
+
**Attack the premise before the third repair — when two rounds' A-or-higher findings share one assumption,
|
|
589
|
+
whether or not the yield falls.**
|
|
590
|
+
When two rounds' A-or-higher findings are different instances of one assumption — «this list can
|
|
591
|
+
be completed», «this string shape covers every caller» — another instance-level repair is likely
|
|
592
|
+
to repeat the failure. Before choosing the next repair, write the shared premise down in one line,
|
|
593
|
+
test it directly (one counter-example settles it), and if it falls, change the design rather than
|
|
594
|
+
the list: flip a blocklist to an allowlist, move the check to where the input is already typed, or
|
|
595
|
+
drop the exemption. **Which cure**: flipping to «unknown goes to a person» is right on an
|
|
596
|
+
irreversible surface, or where the expected rate of person-routed prompts fits a review budget you
|
|
597
|
+
can name — it moves the cost
|
|
598
|
+
into over-blocking, and an over-block that fires often trains the bypass. Elsewhere prefer moving the
|
|
599
|
+
check to typed input or dropping the exemption. If you flip, say what the over-block costs (which
|
|
600
|
+
common inputs now reach a person). Two more flips on 2026-10-19 were gate surfaces and list their
|
|
601
|
+
accepted over-blocks in the PR body (FoD #80 delete outside the working folder: `echo rm …`,
|
|
602
|
+
`git rm`, `rm x # /path` · #81 writes to the user settings file: `jq … > tmp && mv`, quoted `>`,
|
|
603
|
+
`cat … 2>/dev/null`). Measured 2026-10-19, same day, two surfaces: FoD gate read-side exemptions
|
|
604
|
+
(5 A in one cross-family round — `_getframe`, NFKC fullwidth names, `PYTHONPATH`, …) and the
|
|
605
|
+
cartridge admission checker (R1 4 A, R2 1 A) both rested on «a blocklist of shell/tool strings can
|
|
606
|
+
be completed»; the exemptions were dropped and the checker flipped to an allowlist, so an unknown
|
|
607
|
+
string now lands on the human instead of on a missing list entry. That flip is not convergence —
|
|
608
|
+
the checker shipped NOT-CONVERGED at the round cap, and said so
|
|
609
|
+
([[feedback_static_shell_string_check_does_not_converge]]).
|
|
610
|
+
Prior art: the «attack the premise» principle in pstack (`cursor/plugins`).
|
|
587
611
|
5. Full Wave results → recommend persisting to `tracks/_meta/steel_quench_YYYY_MM_DD_{slug}.md`
|
|
588
612
|
|
|
589
613
|
> **Why this replaced "zero new S-grade → terminate" (measured 2026-08-02, PR #231).** A single
|
|
@@ -588,6 +588,49 @@ for f in "${FILES[@]}"; do
|
|
|
588
588
|
| grep -vE '^[0-9]+:[[:space:]]*#' \
|
|
589
589
|
| grep -vE '#[[:space:]]*noqa[:[:space:]]*degrade')
|
|
590
590
|
fi
|
|
591
|
+
|
|
592
|
+
# S7 — `set -e` under a declared exit contract that has its OWN error code, with no ERR trap.
|
|
593
|
+
# Under `set -e` a command that fails where nobody expected it ends the script with THAT
|
|
594
|
+
# command's status — usually 1. If the contract reserves a separate code for "the tool itself
|
|
595
|
+
# broke" (10 HARNESS_ERROR and the like), the low codes are verdicts, so a crash leaks out as
|
|
596
|
+
# one of them. Measured 2026-10-20 on fh-gate.sh: a failing `mktemp` exited 1 = PENDING
|
|
597
|
+
# ("proceed with awareness"); reported from outside, fixed in #927. The cure is an ERR trap
|
|
598
|
+
# that exits the error code, plus an exit-time check that 0..N only leave through the verdict
|
|
599
|
+
# sites (`set -u` and a failing EXIT-trap function end with 1 WITHOUT firing ERR).
|
|
600
|
+
# SCOPE, so this stays quiet: all three must hold — `set -…e…` · a comment header naming exit
|
|
601
|
+
# codes · a contract line naming an error code (harness/internal/tool error). A contract of
|
|
602
|
+
# just "0 = pass, 1 = fail" is excluded: there an unexpected 1 already points the safe way.
|
|
603
|
+
# Census 2026-10-20 over this repo's tracked shell: 1 file matched the shape (fh-gate.sh).
|
|
604
|
+
# FILE-level probe: it reports the `set -e` line once.
|
|
605
|
+
# Round-1 cross-family review (codex) widened three things: `set -o errexit` and `cmd; set -e`
|
|
606
|
+
# activate it; an `EXIT_*ERROR=10`-style constant counts as a contract; and a trap only counts
|
|
607
|
+
# when it EXITS — `trap cleanup ERR` (no exit) and a commented-out trap do not protect anything.
|
|
608
|
+
# A grep that ERRORS (rc>1) is reported as S7-UNMEASURED, never read as "no hit" — the same
|
|
609
|
+
# default-toward-clean shape this probe exists to find.
|
|
610
|
+
_s7_rc() { grep "$@" "$f" >/dev/null 2>&1; echo $?; }
|
|
611
|
+
_s7_lines=$(grep -nE '(^|[;{&|])[[:space:]]*set[[:space:]]+(-[A-Za-z]*e[A-Za-z]*|-o[[:space:]]+errexit)([[:space:];]|$)' "$f" 2>/dev/null); _s7_r1=$?
|
|
612
|
+
_s7_set=$(printf '%s\n' "$_s7_lines" | grep -vE '^[0-9]+:[[:space:]]*#' | grep -vE '#[[:space:]]*noqa[:[:space:]]*degrade' | sed -n 1p)
|
|
613
|
+
_s7_r2=$(_s7_rc -qE '^[[:space:]]*#.*\b[Ee]xit([[:space:]]+codes?|[[:space:]]+status(es)?)?[[:space:]]*:')
|
|
614
|
+
_s7_r3=$(_s7_rc -qiE '^[[:space:]]*#.*\b[0-9]+([[:space:]]*(—|–|-|=|:|\))[[:space:]]*.{0,40}|[[:space:]]+)(harness|internal|tool)[ _-]?error')
|
|
615
|
+
# ^ a CONTRACT ENTRY (`10 — Harness error`, `10 harness error`), not prose that happens to hold a
|
|
616
|
+
# number and the word (an old test file's comment «the count is 0 … HARNESS_ERROR» was flagged).
|
|
617
|
+
_s7_r4=$(_s7_rc -qE '^[[:space:]]*[A-Z_]*(HARNESS|INTERNAL|TOOL)_?ERR(OR)?[A-Z_]*=[0-9]+')
|
|
618
|
+
# protecting trap: an ACTIVE (non-comment) `trap … ERR` line that exits, or that names a handler
|
|
619
|
+
# function whose body (next 12 lines) exits.
|
|
620
|
+
_s7_traps=$(grep -nE "^[^#]*\btrap[[:space:]].*[[:space:]'\"]ERR(['\"]|[[:space:];]|$)" "$f" 2>/dev/null); _s7_r5=$?
|
|
621
|
+
_s7_guard=""
|
|
622
|
+
if [ -n "$_s7_traps" ]; then
|
|
623
|
+
if printf '%s\n' "$_s7_traps" | grep -qE '\bexit\b'; then _s7_guard=1
|
|
624
|
+
else
|
|
625
|
+
_s7_h=$(printf '%s\n' "$_s7_traps" | sed -nE "s/.*trap[[:space:]]+['\"]?([A-Za-z_][A-Za-z0-9_]*)['\"]?[[:space:]].*/\\1/p" | sed -n 1p)
|
|
626
|
+
[ -n "$_s7_h" ] && grep -A12 -E "^[[:space:]]*(function[[:space:]]+)?${_s7_h}[[:space:]]*\(\)" "$f" 2>/dev/null | grep -qE '\bexit\b' && _s7_guard=1
|
|
627
|
+
fi
|
|
628
|
+
fi
|
|
629
|
+
if [ "$_s7_r1" -gt 1 ] || [ "$_s7_r2" -gt 1 ] || [ "$_s7_r3" -gt 1 ] || [ "$_s7_r4" -gt 1 ] || [ "$_s7_r5" -gt 1 ]; then
|
|
630
|
+
emit "$f" 1 "S7-UNMEASURED(sh)" "could not read this file for the set -e / exit-contract check (grep error) — NOT checked, not clean"
|
|
631
|
+
elif [ -n "$_s7_set" ] && { { [ "$_s7_r2" -eq 0 ] && [ "$_s7_r3" -eq 0 ]; } || [ "$_s7_r4" -eq 0 ]; } && [ -z "$_s7_guard" ]; then
|
|
632
|
+
emit "$f" "${_s7_set%%:*}" "S7:set-e-leaks-verdict(sh)" "\`set -e\` under an exit contract that has its own error code, but no ERR trap that exits — an unexpected failure exits with the failing command's status (usually 1), which the contract reads as a verdict; add \`trap '…; exit <error-code>' ERR\` and an EXIT check that 0..N only leave through the verdict sites (set -u and EXIT-trap failures do not fire ERR). Do NOT add set -E without checking \`\$( ) || rc=\$?\` captures"
|
|
633
|
+
fi
|
|
591
634
|
fi
|
|
592
635
|
|
|
593
636
|
# Probe A — except/else/finally block returning a permissive value within 2 lines.
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""dispatch_receipt.py — the governor's own receipt for edit work a dispatched agent says it did.
|
|
3
|
+
|
|
4
|
+
Why (2026-10-20): an agent's hand-back («committed 7f2acd2, 11 files, tests green») is a claim. CLAUDE.md §Agent Dispatch
|
|
5
|
+
says a sidecar's findings stay evidence until the governor closes each against a mechanical anchor — for EDIT work there was
|
|
6
|
+
no anchor, so the close step read the agent's own summary. Outside anchors for the same gap: arXiv:2610.15459 and «report ≠
|
|
7
|
+
change» (frontier digest 2026-10-20). This prints what the repository says, measured by the governor, and with a claim
|
|
8
|
+
compares it with the files the agent named.
|
|
9
|
+
|
|
10
|
+
Usage: python3 scripts/dispatch_receipt.py <repo-or-worktree> <base-ref> [--claimed a,b,...] [--claimed-file F] [--head REF]
|
|
11
|
+
--claimed comma-separated paths. An empty entry, a duplicate or a path with leading/trailing space is REFUSED (rc 2):
|
|
12
|
+
a claim is never silently rewritten. Paths containing a comma need --claimed-file.
|
|
13
|
+
--claimed-file one path per line (or NUL-separated if the file contains NUL bytes), same refusal rules.
|
|
14
|
+
Prints head sha · branch · commits base..head · per-path line (sha256 prefix of the blob at head, «deleted», «submodule <sha>»,
|
|
15
|
+
«symlink <sha>») · uncommitted(tracked) / untracked counts.
|
|
16
|
+
Exit: 0 = receipt printed and the claim (if any) equals the changed set exactly · 1 = claim differs (named both ways), or tracked
|
|
17
|
+
changes are not committed · 2 = usage / malformed claim · 10 = harness error (any git call failed, base is not an ancestor of head).
|
|
18
|
+
🟥 Rename detection is OFF: a move lists both the old and the new path — every affected path, independent of git config.
|
|
19
|
+
🟥 «0 paths» is not a pass when a claim names files: rc 1.
|
|
20
|
+
🟥 Named residual (codex R3, rounds capped there): the receipt overrides the git settings that changed its answer in review
|
|
21
|
+
(GIT_* env, replace refs, diff.relative, ignoreSubmodules, fileMode, quotePath) and measures from the top level. It still
|
|
22
|
+
trusts the rest of the repository's own config and hooks-free plumbing; it is a receipt for cooperative dispatch, not a
|
|
23
|
+
sandbox for a hostile repository.
|
|
24
|
+
"""
|
|
25
|
+
import hashlib, os, subprocess, sys
|
|
26
|
+
|
|
27
|
+
# 🟥 codex R3: inherited GIT_DIR / GIT_WORK_TREE / GIT_INDEX_FILE … would make it measure another repository — drop every GIT_*
|
|
28
|
+
# variable, then set only what the receipt needs. Replacement refs off: the printed sha must be the measured history.
|
|
29
|
+
ENV = {k: v for k, v in os.environ.items() if not k.startswith("GIT_")}
|
|
30
|
+
ENV.update(GIT_OPTIONAL_LOCKS="0", GIT_TERMINAL_PROMPT="0", GIT_LITERAL_PATHSPECS="1", GIT_NO_REPLACE_OBJECTS="1", LC_ALL="C")
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class HarnessError(Exception):
|
|
34
|
+
pass
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def git(repo, *args):
|
|
38
|
+
r = subprocess.run(["git", "-C", repo, "-c", "core.fsmonitor=false", "-c", "core.quotePath=false",
|
|
39
|
+
"-c", "diff.ignoreSubmodules=none", "-c", "status.showUntrackedFiles=normal",
|
|
40
|
+
"-c", "diff.relative=false", "-c", "core.fileMode=true", *args],
|
|
41
|
+
capture_output=True, env=ENV)
|
|
42
|
+
if r.returncode != 0:
|
|
43
|
+
raise HarnessError("git %s failed (rc=%d): %s" % (" ".join(args[:2]), r.returncode,
|
|
44
|
+
r.stderr.decode("utf-8", "replace").strip()[:200]))
|
|
45
|
+
return r.stdout
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def usage(msg):
|
|
49
|
+
print("usage: dispatch_receipt.py <repo-or-worktree> <base-ref> [--claimed a,b] [--claimed-file F] [--head REF]", file=sys.stderr)
|
|
50
|
+
if msg:
|
|
51
|
+
print(" " + msg, file=sys.stderr)
|
|
52
|
+
return 2
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def parse_claim(entries, origin):
|
|
56
|
+
"""→ (set of paths, error or None). Nothing is normalised: an ambiguous entry is an error, not a guess."""
|
|
57
|
+
seen = []
|
|
58
|
+
for e in entries:
|
|
59
|
+
if e == "":
|
|
60
|
+
return None, "empty entry in %s (a trailing or doubled separator?)" % origin
|
|
61
|
+
if e != e.strip():
|
|
62
|
+
return None, "entry with leading/trailing space in %s: %r — say exactly which path" % (origin, e)
|
|
63
|
+
if e in seen:
|
|
64
|
+
return None, "duplicate entry in %s: %r" % (origin, e)
|
|
65
|
+
seen.append(e)
|
|
66
|
+
return set(seen), None
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def main(argv):
|
|
70
|
+
if len(argv) < 2:
|
|
71
|
+
return usage("")
|
|
72
|
+
repo, base, rest = argv[0], argv[1], argv[2:]
|
|
73
|
+
head_ref, claim, have_claim = "HEAD", set(), False
|
|
74
|
+
i = 0
|
|
75
|
+
while i < len(rest):
|
|
76
|
+
a = rest[i]
|
|
77
|
+
if a in ("--claimed", "--claimed-file", "--head") and i + 1 >= len(rest):
|
|
78
|
+
return usage("%s needs a value" % a)
|
|
79
|
+
if a == "--head":
|
|
80
|
+
head_ref = rest[i + 1]
|
|
81
|
+
elif a == "--claimed":
|
|
82
|
+
got, err = parse_claim(rest[i + 1].split(","), "--claimed")
|
|
83
|
+
if err:
|
|
84
|
+
return usage(err)
|
|
85
|
+
if claim & got:
|
|
86
|
+
return usage("duplicate entry across claim options: %r" % sorted(claim & got)[0])
|
|
87
|
+
claim |= got; have_claim = True
|
|
88
|
+
elif a == "--claimed-file":
|
|
89
|
+
try:
|
|
90
|
+
raw = open(rest[i + 1], "rb").read().decode("utf-8")
|
|
91
|
+
except (OSError, UnicodeDecodeError) as exc:
|
|
92
|
+
return usage("cannot read --claimed-file: %s" % exc)
|
|
93
|
+
parts = raw.split("\0") if "\0" in raw else raw.split("\n")
|
|
94
|
+
if parts and parts[-1] == "":
|
|
95
|
+
parts.pop() # ONE final terminator is normal; a second one is an empty entry
|
|
96
|
+
got, err = parse_claim(parts, "--claimed-file")
|
|
97
|
+
if err:
|
|
98
|
+
return usage(err)
|
|
99
|
+
if claim & got:
|
|
100
|
+
return usage("duplicate entry across claim options: %r" % sorted(claim & got)[0])
|
|
101
|
+
claim |= got; have_claim = True
|
|
102
|
+
else:
|
|
103
|
+
return usage("unknown argument %r" % a)
|
|
104
|
+
i += 2
|
|
105
|
+
if not os.path.isdir(repo):
|
|
106
|
+
print("HARNESS-ERROR: not a directory: %s" % repo, file=sys.stderr); return 10
|
|
107
|
+
try:
|
|
108
|
+
repo = git(repo, "rev-parse", "--show-toplevel").decode().strip() # codex R3: a subdirectory must not narrow the diff
|
|
109
|
+
head = git(repo, "rev-parse", "--verify", "--quiet", head_ref + "^{commit}").decode().strip()
|
|
110
|
+
base_sha = git(repo, "rev-parse", "--verify", "--quiet", base + "^{commit}").decode().strip()
|
|
111
|
+
r = subprocess.run(["git", "-C", repo, "merge-base", "--is-ancestor", base_sha, head], capture_output=True, env=ENV)
|
|
112
|
+
if r.returncode == 1:
|
|
113
|
+
raise HarnessError("base %s is not an ancestor of head %s — the receipt would mix unrelated history" % (base_sha[:12], head[:12]))
|
|
114
|
+
if r.returncode != 0:
|
|
115
|
+
raise HarnessError("merge-base failed (rc=%d)" % r.returncode)
|
|
116
|
+
b = subprocess.run(["git", "-C", repo, "symbolic-ref", "--quiet", "--short", "HEAD"], capture_output=True, env=ENV)
|
|
117
|
+
branch = b.stdout.decode().strip() if b.returncode == 0 else "(detached)"
|
|
118
|
+
commits = int(git(repo, "rev-list", "--count", "%s..%s" % (base_sha, head)).decode().strip())
|
|
119
|
+
paths = [p.decode("utf-8", "surrogateescape") for p in
|
|
120
|
+
git(repo, "diff", "--name-only", "-z", "--no-renames", "--ignore-submodules=none", base_sha, head).split(b"\0") if p]
|
|
121
|
+
lines = []
|
|
122
|
+
for p in paths:
|
|
123
|
+
t = git(repo, "ls-tree", "-z", head, "--", p).split(b"\0")[0]
|
|
124
|
+
if not t:
|
|
125
|
+
prev = git(repo, "ls-tree", "-z", base_sha, "--", p).split(b"\0")[0]
|
|
126
|
+
if not prev:
|
|
127
|
+
raise HarnessError("path %r is in the diff but in neither tree" % p)
|
|
128
|
+
lines.append(("deleted", p)); continue
|
|
129
|
+
meta, _, _name = t.partition(b"\t")
|
|
130
|
+
mode, typ, obj = meta.decode().split(" ")
|
|
131
|
+
if typ == "commit":
|
|
132
|
+
lines.append(("submodule " + obj[:12], p)); continue
|
|
133
|
+
if typ != "blob":
|
|
134
|
+
raise HarnessError("unexpected object type %s for %r" % (typ, p))
|
|
135
|
+
data = git(repo, "cat-file", "blob", obj)
|
|
136
|
+
tag = hashlib.sha256(data).hexdigest()[:16]
|
|
137
|
+
lines.append((("symlink " if mode == "120000" else "") + tag, p))
|
|
138
|
+
st = git(repo, "status", "--porcelain=v1", "-z", "--untracked-files=normal", "--ignore-submodules=none").split(b"\0")
|
|
139
|
+
# assume-unchanged (h) / skip-worktree (S) entries are invisible to status — count them, they make «committed» unprovable
|
|
140
|
+
hidden = sum(1 for e in git(repo, "ls-files", "-v", "-z").split(b"\0") if e[:1] in (b"h", b"S", b"s"))
|
|
141
|
+
dirty = untracked = 0
|
|
142
|
+
skip = False
|
|
143
|
+
for e in st:
|
|
144
|
+
if skip:
|
|
145
|
+
skip = False; continue
|
|
146
|
+
if not e:
|
|
147
|
+
continue
|
|
148
|
+
code = e[:2]
|
|
149
|
+
if code == b"??":
|
|
150
|
+
untracked += 1
|
|
151
|
+
else:
|
|
152
|
+
dirty += 1
|
|
153
|
+
if code[:1] in (b"R", b"C"):
|
|
154
|
+
skip = True # rename/copy entries carry the source path as the next field
|
|
155
|
+
except HarnessError as exc:
|
|
156
|
+
print("HARNESS-ERROR: %s" % exc, file=sys.stderr); return 10
|
|
157
|
+
print("receipt repo=%s" % repo)
|
|
158
|
+
print(" head=%s branch=%s base=%s" % (head, branch, base_sha))
|
|
159
|
+
print(" commits=%d paths=%d" % (commits, len(paths)))
|
|
160
|
+
print(" uncommitted(tracked)=%d untracked=%d hidden-from-status=%d" % (dirty, untracked, hidden))
|
|
161
|
+
for tag, p in lines:
|
|
162
|
+
print(" path %-18s %s" % (tag, p))
|
|
163
|
+
rc = 0
|
|
164
|
+
if dirty:
|
|
165
|
+
print("NOT-COMMITTED: %d tracked path(s) changed but not committed — the receipt covers commits only" % dirty); rc = 1
|
|
166
|
+
if hidden:
|
|
167
|
+
print("UNPROVABLE-CLEAN: %d path(s) marked assume-unchanged/skip-worktree — status cannot show their edits" % hidden); rc = 1
|
|
168
|
+
if have_claim:
|
|
169
|
+
actual = set(paths)
|
|
170
|
+
missing, extra = sorted(claim - actual), sorted(actual - claim)
|
|
171
|
+
if missing:
|
|
172
|
+
print("CLAIMED-NOT-CHANGED:"); [print(" " + p) for p in missing]; rc = 1
|
|
173
|
+
if extra:
|
|
174
|
+
print("CHANGED-NOT-CLAIMED:"); [print(" " + p) for p in extra]; rc = 1
|
|
175
|
+
if not missing and not extra:
|
|
176
|
+
print("CLAIMED-MATCHES: %d path(s)" % len(claim))
|
|
177
|
+
return rc
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
if __name__ == "__main__":
|
|
181
|
+
try:
|
|
182
|
+
sys.exit(main(sys.argv[1:]))
|
|
183
|
+
except Exception as exc: # an instrument crash is never a pass
|
|
184
|
+
print("HARNESS-ERROR: %s: %s" % (type(exc).__name__, exc), file=sys.stderr)
|
|
185
|
+
sys.exit(10)
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
🟥 구조 술어만 쓴다 — FH 고유 어휘(마커·4축·영혼)를 넣지 않는다. 그래야 남의 레포에도 돈다.
|
|
18
18
|
"""
|
|
19
19
|
from __future__ import annotations
|
|
20
|
-
import os, re, sys, json, argparse
|
|
20
|
+
import os, re, sys, json, argparse, subprocess
|
|
21
21
|
from typing import Dict, List, Tuple
|
|
22
22
|
|
|
23
23
|
DOC_EXT = {".md"}
|
|
@@ -56,14 +56,53 @@ def _inside(root: str, path: str) -> bool:
|
|
|
56
56
|
return c == r or c.startswith(r + os.sep)
|
|
57
57
|
|
|
58
58
|
|
|
59
|
+
_TRACKED_CACHE: dict = {}
|
|
60
|
+
_INVENTORY_FAILED = "INVENTORY-FAILED"
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _tracked(root: str):
|
|
64
|
+
"""git 저장소면 추적된 파일의 실경로 집합(frozenset), git 밖이면 None, git 인데 목록을 못 얻으면 _INVENTORY_FAILED.
|
|
65
|
+
🟥 2026-10-20: 이름 대체 찾기가 os.walk 로 트리 «전체» 를 훑어서, 저자 머신의 미추적 실험 폴더(tracks/_meta/claude200 안 복제본
|
|
66
|
+
10개)가 known-pair 대상의 이름을 겹치게 만들었다 → 보정이 «대상이 실재하지 않는다» 로 거짓 실패(깨끗한 복제본은 통과).
|
|
67
|
+
반대로 미추적 파일 하나가 사라진 대상을 «있다» 로 만들 수도 있다(되돌림 레인 L9 B 에서 실측).
|
|
68
|
+
🟥 codex 1라운드: git 이 실패하면 «git 밖» 으로 떨어져 옛 동작이 돌아오면 안 된다 — «git 밖» 은 rev-parse 가 그렇다고 말할 때만,
|
|
69
|
+
그 밖의 실패는 _INVENTORY_FAILED(resolve 가 아무것도 못 찾는 닫힌 쪽). 서브모듈 안 파일도 포함(--recurse-submodules),
|
|
70
|
+
충돌 단계 중복은 한 번만(--deduplicate), 실경로 집합은 루트마다 한 번만 계산."""
|
|
71
|
+
if root in _TRACKED_CACHE:
|
|
72
|
+
return _TRACKED_CACHE[root]
|
|
73
|
+
env = {k: v for k, v in os.environ.items() if not k.startswith("GIT_")}
|
|
74
|
+
out = _INVENTORY_FAILED
|
|
75
|
+
try:
|
|
76
|
+
top = subprocess.run(["git", "-C", root, "rev-parse", "--show-toplevel"], capture_output=True, env=env, timeout=10)
|
|
77
|
+
if top.returncode != 0:
|
|
78
|
+
msg = top.stderr.decode("utf-8", "replace").lower()
|
|
79
|
+
out = None if "not a git repository" in msg else _INVENTORY_FAILED
|
|
80
|
+
else:
|
|
81
|
+
t = top.stdout.decode("utf-8", "surrogateescape").strip()
|
|
82
|
+
r = subprocess.run(["git", "-C", t, "-c", "core.fsmonitor=false", "ls-files", "-z", "--full-name",
|
|
83
|
+
"--recurse-submodules", "--deduplicate"], capture_output=True, env=env, timeout=30)
|
|
84
|
+
if r.returncode == 0:
|
|
85
|
+
out = frozenset(os.path.realpath(os.path.join(t, x.decode("utf-8", "surrogateescape")))
|
|
86
|
+
for x in r.stdout.split(b"\0") if x)
|
|
87
|
+
except (OSError, subprocess.SubprocessError):
|
|
88
|
+
out = _INVENTORY_FAILED
|
|
89
|
+
_TRACKED_CACHE[root] = out
|
|
90
|
+
return out
|
|
91
|
+
|
|
92
|
+
|
|
59
93
|
def resolve(root: str, p: str) -> str | None:
|
|
60
94
|
# `..` 를 담은 참조는 «해석하기 전에» 거절한다 — 해석 후 판정은 심링크 한 겹에 뚫린다.
|
|
61
95
|
cand = os.path.join(root, p)
|
|
62
|
-
|
|
96
|
+
tracked = _tracked(root)
|
|
97
|
+
if tracked == _INVENTORY_FAILED:
|
|
98
|
+
return None # git 인데 목록을 못 얻었다 — 못 찾은 것으로(닫힌 쪽), 옛 전체 훑기로 안 떨어진다
|
|
99
|
+
if os.path.isfile(cand) and not os.path.islink(cand) and _inside(root, cand) \
|
|
100
|
+
and (tracked is None or os.path.realpath(cand) in tracked):
|
|
63
101
|
return cand
|
|
64
102
|
base = os.path.basename(p)
|
|
65
|
-
|
|
66
|
-
|
|
103
|
+
pool = sorted(tracked) if tracked is not None else walk(root) # git 이면 추적 파일만, 아니면 종전처럼 트리 전체
|
|
104
|
+
hits = [f for f in pool
|
|
105
|
+
if os.path.basename(f) == base and os.path.isfile(f) and not os.path.islink(f) and _inside(root, f)]
|
|
67
106
|
return hits[0] if len(hits) == 1 else None
|
|
68
107
|
|
|
69
108
|
# 실행 증거: 인터프리터 뒤 또는 명령 위치. 주석줄과 grep 패턴 안은 제외.
|