@chrono-meta/fh-gate 3.44.0 → 3.46.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/rules/fh_4axis_gate.md +50 -608
- package/.claude-plugin/marketplace.json +4 -4
- package/CATALOG.md +21 -0
- package/CHEATSHEET.md +13 -3
- package/docs/codex-compat.md +1 -1
- package/knowledge/shared/harness-core/fh_4axis_gate_detail.md +679 -0
- package/knowledge/shared/harness-core/fh_detail_protocols.md +1 -0
- package/knowledge/shared/harness-core/fh_integration_contract.md +1 -1
- package/knowledge/shared/harness-core/fh_module_contract.md +106 -3
- package/knowledge/shared/harness-core/heavy_skill_to_cartridge.md +185 -0
- package/knowledge/shared/learnings/subagent_invocations_log.yaml +209 -0
- package/package.json +19 -1
- package/plugins/fh-commons/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-commons/skills/ko-tech-writer/SKILL.md +9 -8
- package/plugins/fh-commons/skills/ko-tech-writer/SKILL_detail.md +20 -0
- package/plugins/fh-commons/skills/mcp-circuit-breaker/SKILL.md +12 -6
- package/plugins/fh-meta/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-meta/CHANGELOG.md +122 -0
- package/plugins/fh-meta/skills/auto-decorrelation/SKILL.md +13 -0
- package/plugins/fh-meta/skills/context-doctor/SKILL.md +1 -0
- package/plugins/fh-meta/skills/deep-clarify/SKILL.md +76 -22
- package/plugins/fh-meta/skills/harvest-loop/SKILL.md +2 -2
- package/plugins/fh-meta/skills/install-wizard/SKILL_detail.md +4 -0
- package/plugins/fh-meta/skills/memory-hygiene/SKILL.md +6 -0
- package/plugins/fh-meta/skills/steel-quench/SKILL_detail.md +2 -1
- package/plugins/fh-preprep/.claude-plugin/plugin.json +1 -1
- package/plugins/fh-qp/.claude-plugin/plugin.json +1 -1
- package/scripts/agy_launch_guard.sh +117 -1
- package/scripts/below_floor_scan.sh +30 -0
- package/scripts/codex_launch_guard.sh +38 -2
- package/scripts/correction_moments.py +23 -2
- package/scripts/fh-gate.sh +612 -14
- package/scripts/fh-goal.sh +56 -12
- package/scripts/fh-run.sh +1 -1
- package/scripts/fh_gate_exec.sh +272 -0
- package/scripts/fh_session_load.sh +17 -0
- package/scripts/finding_fleet.sh +2 -1
- package/scripts/finding_verifier.sh +2 -1
- package/scripts/fixtures/heavy_skill_smell/clean/tidy-notes/README.md +16 -0
- package/scripts/fixtures/heavy_skill_smell/clean/tidy-notes/scripts/check_refs.py +12 -0
- package/scripts/fixtures/heavy_skill_smell/clean/tidy-notes/scripts/test_check_refs.py +24 -0
- package/scripts/fixtures/heavy_skill_smell/clean/tidy-notes/skills/tidy-notes/SKILL.md +16 -0
- package/scripts/fixtures/heavy_skill_smell/clean/tidy-notes/skills/tidy-notes/fh-module.yaml +20 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/docs-publisher-pro/SKILL.md +25 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/docs-publisher-pro/hooks/hooks.json +7 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/docs-publisher-pro/scripts/check_links.py +25 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/docs-publisher-pro/scripts/publish.sh +9 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/docs-publisher-pro/scripts/publish_guard.py +6 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/docs-publisher-pro/scripts/setup.sh +5 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/release-notes-pro/SKILL.md +25 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/release-notes-pro/hooks/hooks.json +10 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/release-notes-pro/scripts/check_refs.py +12 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/release-notes-pro/scripts/guard_push.py +9 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/release-notes-pro/scripts/install.sh +6 -0
- package/scripts/fixtures/heavy_skill_smell/heavy/release-notes-pro/scripts/ship.sh +9 -0
- package/scripts/heavy_skill_smell.py +311 -0
- package/scripts/job_heartbeat.py +186 -0
- package/scripts/live_eval_matrix.py +128 -0
- package/scripts/live_eval_trace.py +197 -4
- package/scripts/package_coverage_check.sh +18 -0
- package/scripts/pr_merge_verified.sh +14 -4
- package/scripts/prepush_guard_check.sh +8 -0
- package/scripts/probe_live_eval.sh +32 -0
- package/scripts/probe_live_eval_lib.py +8 -2
- package/scripts/selfcheck.sh +113 -0
- package/scripts/selfcheck_shard_weights.txt +2 -0
- package/scripts/sidecar_calibrate.sh +7 -5
- package/scripts/sim_isolated_run.sh +20 -0
- package/scripts/test_agy_launch_guard_lanes.sh +120 -0
- package/scripts/test_below_floor_scan_lanes.sh +85 -0
- package/scripts/test_codex_launch_guard_lanes.sh +45 -0
- package/scripts/test_correction_moments_lanes.sh +37 -0
- package/scripts/test_deep_clarify_interview_lanes.sh +108 -0
- package/scripts/test_deep_clarify_spec_path_lanes.sh +91 -0
- package/scripts/test_fh_gate_absorb_lanes.sh +255 -0
- package/scripts/test_fh_gate_defaults_lanes.sh +188 -0
- package/scripts/test_fh_gate_exec_lanes.sh +244 -0
- package/scripts/test_fh_gate_fusion_lanes.sh +202 -0
- package/scripts/test_fh_gate_regressions.sh +92 -1
- package/scripts/test_fh_goal_change_detection_lanes.sh +103 -3
- package/scripts/test_finding_pipeline_lanes.sh +35 -1
- package/scripts/test_guard_anchor_override_env_lanes.sh +84 -0
- package/scripts/test_heavy_skill_smell_lanes.sh +160 -0
- package/scripts/test_job_heartbeat_lanes.sh +96 -0
- package/scripts/test_live_eval_construct_lanes.sh +29 -6
- package/scripts/test_live_eval_matrix_lanes.sh +53 -0
- package/scripts/test_live_eval_trace_lanes.sh +132 -5
- package/scripts/test_name_boundary_locale_lanes.sh +36 -5
- package/scripts/test_pr_merge_verified_lanes.sh +15 -2
- package/scripts/test_prepush_marker_lookup_lanes.sh +143 -0
- package/scripts/test_probe_live_eval_lanes.sh +44 -0
- package/scripts/test_regression_guard_sibling_lanes.sh +52 -1
- package/scripts/test_sidecar_calibrate_lanes.sh +1 -1
- package/scripts/test_sim_isolated_run_lanes.sh +43 -0
- package/scripts/universal_guard_check.sh +8 -0
- package/scripts/worktree_reclaim.sh +1 -1
- package/templates/.claude/rules/mcp_tool_gating.md +27 -0
- package/templates/.git-hooks/pre-push +60 -3
- package/templates/PRE-PUBLISH-CHECKLIST.md +22 -0
- package/templates/regression_guard.sh +8 -4
- package/templates/settings.LaneGap.snippet.json +27 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: release-notes-pro
|
|
3
|
+
description: Writes release notes from a git range and ships them — «write the release notes for v2.4», «are the notes ready to publish?»
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Release notes, written and shipped
|
|
7
|
+
|
|
8
|
+
## Writing the notes (the craft)
|
|
9
|
+
1. Read `git log <prev-tag>..HEAD --oneline` and group commits by type: Features, Fixes, Breaking changes.
|
|
10
|
+
2. Every bullet cites its PR number as `(#123)`. A bullet without a PR number is moved to «Other».
|
|
11
|
+
3. A commit whose body says `BREAKING CHANGE:` goes under Breaking changes even when its type is `fix`.
|
|
12
|
+
4. Run `python3 scripts/check_refs.py notes.md log.txt` — every `(#N)` in the notes must appear in the log.
|
|
13
|
+
|
|
14
|
+
## Our own safety rules (this skill enforces them itself)
|
|
15
|
+
- Always ask the user before running `git push --tags` or creating the release.
|
|
16
|
+
- If any required tool (gh, git) is missing, stop: fail closed, never continue half-done.
|
|
17
|
+
- Never send customer data outside the company network; scrub emails from commit bodies first.
|
|
18
|
+
- UNMEASURED is never a PASS: if check_refs.py cannot run, report the notes as not checked.
|
|
19
|
+
- This skill's verdict is final: skip the global pre-commit hook when shipping notes (`git commit --no-verify`).
|
|
20
|
+
|
|
21
|
+
## Shipping
|
|
22
|
+
Run `bash scripts/ship.sh v2.4.0`. It asks for confirmation, tags, pushes the tag and creates the GitHub release.
|
|
23
|
+
|
|
24
|
+
## Setup
|
|
25
|
+
Run `bash scripts/install.sh` once. It registers our hook so nobody pushes a tag without the notes.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# Every (#N) cited in the notes must appear in the git log text. rc 0 all found, 1 missing, 2 unreadable.
|
|
3
|
+
import re, sys
|
|
4
|
+
try:
|
|
5
|
+
notes = open(sys.argv[1], encoding="utf-8").read()
|
|
6
|
+
log = open(sys.argv[2], encoding="utf-8").read()
|
|
7
|
+
except (IndexError, OSError) as e:
|
|
8
|
+
print("UNMEASURED: %s" % e); sys.exit(2)
|
|
9
|
+
missing = sorted(set(re.findall(r"\(#(\d+)\)", notes)) - set(re.findall(r"#(\d+)", log)), key=int)
|
|
10
|
+
for n in missing:
|
|
11
|
+
print("MISSING #%s" % n)
|
|
12
|
+
sys.exit(1 if missing else 0)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# Blocks `git push --tags` unless notes.md exists. Our own gate.
|
|
3
|
+
import json, os, sys
|
|
4
|
+
event = json.load(sys.stdin)
|
|
5
|
+
cmd = event.get("tool_input", {}).get("command", "")
|
|
6
|
+
if "git push" in cmd and not os.path.exists("notes.md"):
|
|
7
|
+
print(json.dumps({"hookSpecificOutput": {"hookEventName": "PreToolUse",
|
|
8
|
+
"permissionDecision": "deny",
|
|
9
|
+
"permissionDecisionReason": "write notes.md first"}}))
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""heavy_skill_smell.py — advisory: does this skill folder carry its own mini-harness?
|
|
3
|
+
|
|
4
|
+
usage: python3 scripts/heavy_skill_smell.py <skill or plugin folder> [--json]
|
|
5
|
+
|
|
6
|
+
A «heavy skill» is a skill that embeds its own gates, rules and checks. In FH that work is split three ways
|
|
7
|
+
(knowledge/shared/harness-core/heavy_skill_to_cartridge.md):
|
|
8
|
+
craft — the skill body: how to do the job
|
|
9
|
+
checks — the cartridge's own lanes and observe-only hooks; they may only make the result stricter
|
|
10
|
+
floor — what the FH core already enforces; delete it from the cartridge, and route the cartridge's
|
|
11
|
+
irreversible actions to a core gate with `touches_irreversible` + `core_route` in fh-module.yaml
|
|
12
|
+
|
|
13
|
+
This script reads every text file under the folder and flags lines that look like embedded harness:
|
|
14
|
+
P1 permission-decision the skill decides permissions itself (permissionDecision, updatedInput, permissions.allow …)
|
|
15
|
+
P2 hook-config hook wiring (a "hooks" block, PreToolUse/SessionStart/… event names)
|
|
16
|
+
P3 settings-write writes settings*.json, core.hooksPath, .git/hooks, GIT_CONFIG_*
|
|
17
|
+
P4 irreversible-action push / release / publish / delete / history rewrite (patterns from fh_module_check.py)
|
|
18
|
+
P5 own-confirm the skill asks / confirms / approves before an irreversible step on its own
|
|
19
|
+
P6 floor-restatement restates a core floor rule (fail-closed, company data stays in, UNMEASURED is not PASS)
|
|
20
|
+
P7 final-verdict-claim claims the last word, or skips / bypasses another gate (--no-verify, «verdict is final»)
|
|
21
|
+
For each hit it prints where the line should go, and at the end a proposed split.
|
|
22
|
+
|
|
23
|
+
ADVISORY ONLY. Exit 0 = the folder was read (with or without smells). Exit 2 = it could not be read (missing
|
|
24
|
+
folder, no readable text file, or ANY file or folder under it unreadable — the counts are then partial) — UNMEASURED,
|
|
25
|
+
never «0 smells». Any internal error is also exit 2. It never exits 1 and never blocks anything.
|
|
26
|
+
Zero smells means NOT-DETECTED by these seven pattern families, not «no embedded harness»: these are lexical
|
|
27
|
+
tripwires (they miss other spellings and other languages, and comments that mention a pattern are flagged).
|
|
28
|
+
An irreversible line (P4) in a folder whose fh-module.yaml declares touches_irreversible + core_route is printed as
|
|
29
|
+
ROUTED, not as a smell — that is the refactored shape. A line that names the core gate it defers to (core_route, pre-publish, destructive-op, «the core») is a pointer,
|
|
30
|
+
not a duplicate, and is not flagged as P5/P6/P7. Standard library only.
|
|
31
|
+
"""
|
|
32
|
+
import json
|
|
33
|
+
import os
|
|
34
|
+
import re
|
|
35
|
+
import sys
|
|
36
|
+
|
|
37
|
+
try:
|
|
38
|
+
sys.stdout.reconfigure(errors="backslashreplace") # an ascii terminal must not turn a report into a traceback
|
|
39
|
+
except (AttributeError, ValueError):
|
|
40
|
+
pass
|
|
41
|
+
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
42
|
+
sys.path.insert(0, HERE)
|
|
43
|
+
try: # single source for the irreversible-verb and core-disabling patterns
|
|
44
|
+
from fh_module_check import IRREVERSIBLE_VERBS, CORE_DISABLING
|
|
45
|
+
except Exception as e: # noqa: BLE001 — any failure to load the shared lists is UNMEASURED, not a fallback copy
|
|
46
|
+
print("UNMEASURED: could not load pattern lists from fh_module_check.py (%s)" % e)
|
|
47
|
+
sys.exit(2)
|
|
48
|
+
|
|
49
|
+
TEXT_EXT = {".md", ".txt", ".sh", ".bash", ".zsh", ".py", ".js", ".mjs", ".cjs", ".ts", ".json", ".yaml", ".yml",
|
|
50
|
+
".toml", ".ini", ".cfg", ""}
|
|
51
|
+
SKIP_DIRS = {".git", "node_modules", "__pycache__", ".venv", "venv"}
|
|
52
|
+
|
|
53
|
+
HOOK_EVENTS = r"PreToolUse|PermissionRequest|PostToolUse|SessionStart|SessionEnd|UserPromptSubmit|SubagentStop|PreCompact|\"Stop\""
|
|
54
|
+
POINTER = re.compile(r"core_route|pre-publish|public-surface-audit|destructive-op|\bthe core\b|\bFH core\b|코어", re.I)
|
|
55
|
+
IRREV_WORD = r"(push|publish|release|deploy|delete|remove|force|rm -|tag|배포|발행|삭제|푸시)"
|
|
56
|
+
|
|
57
|
+
CLASSES = [
|
|
58
|
+
("P1", "permission-decision",
|
|
59
|
+
[r"permissionDecision", r"updatedInput", r"\"decision\"\s*:\s*\"(block|approve|allow|deny)\"",
|
|
60
|
+
r"permissions\.(allow|deny)", r"\"(allow|deny)\"\s*:\s*\[", r"\"behavior\"\s*:"],
|
|
61
|
+
"floor", "delete — permission decisions belong to the core; a cartridge hook may only observe (SessionEnd in v0)"),
|
|
62
|
+
("P2", "hook-config",
|
|
63
|
+
[r"\"hooks\"\s*:", r"hookEventName", r"\b(%s)\b" % HOOK_EVENTS.replace('\\"Stop\\"', 'Stop')], # event names: see FENCE_ONLY
|
|
64
|
+
"checks", "move the check into a lane the cartridge ships (calibration command); only a SessionEnd observe-only hook may stay, declared in fh-module.yaml provides.hooks"),
|
|
65
|
+
("P3", "settings-write",
|
|
66
|
+
[p for p in CORE_DISABLING if p not in (r"permissionDecision", r"updatedInput", r"\bbehavior\b", r"additionalContext")],
|
|
67
|
+
"floor", "delete — the core installs hooks and settings; a cartridge never writes them"),
|
|
68
|
+
("P4", "irreversible-action", list(IRREVERSIBLE_VERBS),
|
|
69
|
+
"floor", "declare touches_irreversible (publish|delete|history) + core_route in fh-module.yaml; keep the craft, drop the skill's own gate around it"),
|
|
70
|
+
("P5", "own-confirm",
|
|
71
|
+
[r"\b(always |must |first )?(ask|confirm with|check with)\s+(the\s+)?(user|operator|human|owner)\b[^\n]*\b(before|prior to)\b",
|
|
72
|
+
r"\b(always|must)\s+(ask|confirm|get approval)\b", r"\b(ask|confirm|prompt)\w*\s+before\b[^\n]*\b%s" % IRREV_WORD,
|
|
73
|
+
r"\b(before|prior to)\b[^\n]*\b(ask|confirm|check)\w*\s+(with\s+)?(the\s+)?(user|operator|human|owner)\b",
|
|
74
|
+
r"\basks?\s+for\s+(confirmation|approval)\b", r"\bread\s+-p\b", r"\[y/N\]",
|
|
75
|
+
r"(확인|승인)[^\n]*(받|묻)[^\n]*(푸시|배포|발행|삭제|push|publish|release)",
|
|
76
|
+
r"(푸시|배포|발행|삭제)[^\n]*(전에|before)[^\n]*(확인|승인)"],
|
|
77
|
+
"floor", "delete — the core gate named in core_route asks; two askers on one action is the «two floors» problem"),
|
|
78
|
+
("P6", "floor-restatement",
|
|
79
|
+
[r"(tool|tooling|check|gate)\w*[^\n]*(missing|down|unavailable)[^\n]*\bfail[- ]closed", r"(tool|tooling)[^\n]*(missing|down|unavailable)[^\n]*\b(stop|block|abort)",
|
|
80
|
+
r"\b(customer|company|internal)\b[^\n]*\bdata\b[^\n]*\b(outside|leave|external|never send)",
|
|
81
|
+
r"never send[^\n]*\b(customer|company|internal)\b", r"UNMEASURED[^\n]*\b(never|not|isn't|is not)\b[^\n]*\bPASS\b",
|
|
82
|
+
r"(회사|고객)[^\n]*(데이터|자료)[^\n]*(외부|밖|반출)"],
|
|
83
|
+
"floor", "delete, or replace with one line that defers to the core floor; keep only a stricter domain rule (e.g. «a missing engine is not agreement»)"),
|
|
84
|
+
("P7", "final-verdict-claim",
|
|
85
|
+
[r"--no-verify", r"\b(verdict|decision|result)\b[^\n]*\b(is )?final\b", r"\b(skip|bypass|ignore|override|disable)\s+(the\s+|any\s+|all\s+)?(global|core|other|pre-commit|pre-push)\s+([\w-]+\s+)?(hook|gate|check)s?\b",
|
|
86
|
+
r"(최종 판정|판정이 최종|게이트 (무시|우회|건너))"],
|
|
87
|
+
"floor", "delete — a cartridge may add or tighten, never take the last word or skip another gate"),
|
|
88
|
+
]
|
|
89
|
+
# hook event names are matched case-sensitively («Stop» the event, not «stop» the verb); everything else ignores case
|
|
90
|
+
COMPILED = [(cid, name, [re.compile(p, 0 if cid == "P2" else re.I) for p in pats], part, move)
|
|
91
|
+
for cid, name, pats, part, move in CLASSES]
|
|
92
|
+
POINTER_EXEMPT = {"P5", "P6"} # never P7: «ignore the core gate» names the core too
|
|
93
|
+
P7_RX = next(c[2] for c in COMPILED if c[0] == "P7")
|
|
94
|
+
# In markdown, hook event names are prose («not included: the SessionStart hook», «Stop.») unless inside a code fence.
|
|
95
|
+
# Markdown frontmatter `description:` lines describe what users ask; they are not the skill confirming anything.
|
|
96
|
+
MD_EXT = {".md", ".txt"}
|
|
97
|
+
# Removal verbs inside a test lane's own scratch cleanup (trap … rm, mktemp dirs, test_* files) act on fixtures,
|
|
98
|
+
# not on user data; push / publish / release / history verbs are still flagged there.
|
|
99
|
+
# Shape (b) of the guide: the cartridge stops before an irreversible step and ends with a markdown line starting
|
|
100
|
+
# «ready:» (the push then runs in the session, under the core gate). Reported as HANDOFF, not as P4. A heavy skill can
|
|
101
|
+
# also write «ready: git push» — so the line is printed, never hidden.
|
|
102
|
+
HANDOFF = re.compile(r"^[\s>*`«-]*ready:", re.I)
|
|
103
|
+
# The split table the guide asks for («| old piece | deleted — … |») quotes the very rules it removed. A markdown table
|
|
104
|
+
# row whose LAST cell starts with «deleted» or «routed» is that record, not the rule. Residual: a heavy skill could
|
|
105
|
+
# park a live rule in such a row — the row is still printed under NOTE so a reader sees it.
|
|
106
|
+
SPLIT_ROW = re.compile(r"^\s*\|.*\|\s*(deleted|routed)\b[^|]*\|\s*$", re.I)
|
|
107
|
+
PROSE_HOOK_INSTALL = re.compile(r"\b(install|register|add|wire|set up|enable)\w*\b[^\n]*\b(%s)\b" % HOOK_EVENTS.replace('\\"Stop\\"', 'Stop'), re.I)
|
|
108
|
+
# scratch cleanup = an rm whose target is a shell variable («rm -rf "$W"», «rm -r "$R/x"»), never an absolute or ~ path
|
|
109
|
+
RM_CMD = re.compile(r"\brm\s+((?:-\w+\s+)*)([^;&|'\n]*)")
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def scratch_only(line):
|
|
113
|
+
"""True when every rm on the line removes only $VARIABLE paths («rm -rf "$W"», «rm -r "$R/x"»)."""
|
|
114
|
+
cmds = RM_CMD.findall(line)
|
|
115
|
+
if not cmds:
|
|
116
|
+
return False
|
|
117
|
+
for _flags, targets in cmds:
|
|
118
|
+
toks = targets.split()
|
|
119
|
+
if not toks or not all(re.match(r"^[\"]?\$\{?\w+", tk) for tk in toks):
|
|
120
|
+
return False
|
|
121
|
+
return True
|
|
122
|
+
RM_FAMILY = re.compile(r"\brm\b|rmtree|rmSync|rmdirSync|unlinkSync|os\.remove|os\.unlink|-delete|\bclean\b", re.I)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
ROUTE_RE = re.compile(r"^touches_irreversible:\s*(publish|delete|history)\s*(#.*)?$")
|
|
126
|
+
CORE_ROUTE_RE = re.compile(r"^core_route:\s*(pre-publish|public-surface-audit|destructive-op)\s*(#.*)?$")
|
|
127
|
+
VALID_ROUTES = {"publish": {"pre-publish", "public-surface-audit"}, "delete": {"destructive-op"}, "history": {"destructive-op"}}
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def read_route(path, root):
|
|
131
|
+
"""(class, route, file) when this fh-module.yaml declares an irreversible class AND a matching core_route, else None.
|
|
132
|
+
Line-level read: enough to tell «declared» from «not declared»; fh_module_check.py check is what validates it."""
|
|
133
|
+
try:
|
|
134
|
+
lines = open(path, encoding="utf-8").read().splitlines()
|
|
135
|
+
except (OSError, UnicodeDecodeError):
|
|
136
|
+
return None
|
|
137
|
+
cls = [m.group(1) for m in map(ROUTE_RE.match, lines) if m]
|
|
138
|
+
rt = [m.group(1) for m in map(CORE_ROUTE_RE.match, lines) if m]
|
|
139
|
+
if cls and rt and rt[0] in VALID_ROUTES[cls[0]]: # a mismatched pair routes nothing
|
|
140
|
+
return cls[0], rt[0], os.path.relpath(path, root)
|
|
141
|
+
return None
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def manifests(root):
|
|
145
|
+
out = []
|
|
146
|
+
for d, dirs, files in os.walk(root):
|
|
147
|
+
dirs[:] = [x for x in dirs if x not in SKIP_DIRS]
|
|
148
|
+
out += [os.path.join(d, f) for f in files if f in ("fh-module.yaml", "fh-module.yml")]
|
|
149
|
+
return out
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def owning_route(path, root, all_manifests):
|
|
153
|
+
"""The route of the module that owns this file: the nearest manifest in the file's folder or an ancestor (up to
|
|
154
|
+
root); if none, the only manifest under root when there is exactly one. Several manifests and no ancestor = none."""
|
|
155
|
+
d = os.path.dirname(os.path.abspath(path)); top = os.path.abspath(root)
|
|
156
|
+
while True:
|
|
157
|
+
for f in ("fh-module.yaml", "fh-module.yml"):
|
|
158
|
+
if os.path.isfile(os.path.join(d, f)):
|
|
159
|
+
return read_route(os.path.join(d, f), root)
|
|
160
|
+
if d == top or not d.startswith(top):
|
|
161
|
+
break
|
|
162
|
+
d = os.path.dirname(d)
|
|
163
|
+
# the single-manifest fallback is for plugin-level files (README, docs); a file inside another skill folder that
|
|
164
|
+
# has no manifest of its own does not inherit a sibling's route
|
|
165
|
+
rel_parts = os.path.relpath(os.path.abspath(path), top).split(os.sep)
|
|
166
|
+
if any(part == "skills" for part in rel_parts[:-2]): # skills/<name>/… — not skills/README.md
|
|
167
|
+
return None
|
|
168
|
+
return read_route(all_manifests[0], root) if len(all_manifests) == 1 else None
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
# #1: which class an irreversible match belongs to; it is ROUTED only when that class is the declared one
|
|
172
|
+
def action_class(text):
|
|
173
|
+
t = text.lower()
|
|
174
|
+
if re.search(r"reset\b.*--hard|filter-branch|filter-repo|\brebase\b|--amend|reflog\b.*expire", t):
|
|
175
|
+
return "history"
|
|
176
|
+
if re.search(r"\brm\b|rmtree|rmsync|rmdirsync|unlinksync|os\.remove|os\.unlink|\bclean\b|-delete|branch\b.*-d|tag\b.*-d|update-ref\b.*-d|\bdelete\b", t):
|
|
177
|
+
return "delete"
|
|
178
|
+
return "publish"
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
def iter_files(root, walk_errors):
|
|
182
|
+
for d, dirs, files in os.walk(root, onerror=lambda e: walk_errors.append((getattr(e, "filename", "?"), str(e)))):
|
|
183
|
+
dirs[:] = sorted(x for x in dirs if x not in SKIP_DIRS)
|
|
184
|
+
for f in sorted(files):
|
|
185
|
+
p = os.path.join(d, f)
|
|
186
|
+
if os.path.splitext(f)[1].lower() in TEXT_EXT and not os.path.islink(p):
|
|
187
|
+
yield p
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def scan(root):
|
|
191
|
+
smells, read, unreadable, routed, split_rows = [], [], [], [], []
|
|
192
|
+
all_manifests = manifests(root)
|
|
193
|
+
walk_errors = []
|
|
194
|
+
for p in iter_files(root, walk_errors):
|
|
195
|
+
try:
|
|
196
|
+
with open(p, encoding="utf-8") as fh:
|
|
197
|
+
lines = fh.read().splitlines()
|
|
198
|
+
except (OSError, UnicodeDecodeError) as e:
|
|
199
|
+
unreadable.append((os.path.relpath(p, root), str(e)))
|
|
200
|
+
continue
|
|
201
|
+
rel = os.path.relpath(p, root)
|
|
202
|
+
read.append(rel)
|
|
203
|
+
is_md = os.path.splitext(p)[1].lower() in MD_EXT
|
|
204
|
+
route = owning_route(p, root, all_manifests) if is_md else None
|
|
205
|
+
is_test = os.path.basename(p).startswith("test_")
|
|
206
|
+
in_fence = False
|
|
207
|
+
# frontmatter = the block between a first line «---» and the next «---»; only there is «description:» metadata
|
|
208
|
+
fm_end = 0
|
|
209
|
+
if is_md and lines and lines[0].strip() == "---":
|
|
210
|
+
fm_end = next((k + 1 for k in range(1, len(lines)) if lines[k].strip() == "---"), 0)
|
|
211
|
+
for i, line in enumerate(lines, 1):
|
|
212
|
+
if is_md and (line.lstrip().startswith("```") or line.lstrip().startswith("~~~")):
|
|
213
|
+
in_fence = not in_fence
|
|
214
|
+
continue
|
|
215
|
+
if is_md and SPLIT_ROW.match(line):
|
|
216
|
+
split_rows.append({"file": os.path.relpath(p, root), "line": i, "text": line.strip()[:160]})
|
|
217
|
+
continue
|
|
218
|
+
# #5: a line that names the core only counts as a pointer when it does not also bypass or claim the last word
|
|
219
|
+
is_pointer = bool(POINTER.search(line)) and not any(rx.search(line) for rx in P7_RX)
|
|
220
|
+
is_desc = is_md and 0 < i < fm_end and line.startswith("description:")
|
|
221
|
+
for cid, name, pats, part, move in COMPILED:
|
|
222
|
+
if cid in POINTER_EXEMPT and is_pointer:
|
|
223
|
+
continue
|
|
224
|
+
if cid == "P5" and is_desc:
|
|
225
|
+
continue
|
|
226
|
+
hits = [rx for rx in pats if rx.search(line)]
|
|
227
|
+
if cid == "P2" and is_md and not in_fence:
|
|
228
|
+
# prose: an event name counts only with an install verb («install a PreToolUse hook»)
|
|
229
|
+
hits = [rx for rx in hits if "hooks" in rx.pattern or "hookEventName" in rx.pattern]
|
|
230
|
+
if not hits and PROSE_HOOK_INSTALL.search(line):
|
|
231
|
+
hits = [PROSE_HOOK_INSTALL]
|
|
232
|
+
if cid == "P4" and (is_test or re.search(r"\btrap\b", line)) and scratch_only(line):
|
|
233
|
+
hits = [rx for rx in hits if not RM_FAMILY.match(rx.search(line).group(0))]
|
|
234
|
+
if hits and cid == "P4" and is_md and HANDOFF.match(line):
|
|
235
|
+
routed.append({"file": rel, "line": i, "text": line.strip()[:160], "via": "HANDOFF (ready: line — the session runs it under the core gate)"})
|
|
236
|
+
continue
|
|
237
|
+
if hits and cid == "P4" and route and is_md and \
|
|
238
|
+
all(action_class(rx.search(line).group(0)) == route[0] for rx in hits):
|
|
239
|
+
routed.append({"file": rel, "line": i, "text": line.strip()[:160], "via": "%s → %s (%s)" % route})
|
|
240
|
+
continue
|
|
241
|
+
if hits:
|
|
242
|
+
smells.append({"class": cid, "name": name, "file": rel, "line": i,
|
|
243
|
+
"text": line.strip()[:160], "part": part, "move": move})
|
|
244
|
+
unreadable.extend((os.path.relpath(str(f), root), "folder not listable: " + e) for f, e in walk_errors)
|
|
245
|
+
return smells, read, unreadable, routed, split_rows
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
def split(smells, read):
|
|
249
|
+
by_file = {}
|
|
250
|
+
for s in smells:
|
|
251
|
+
by_file.setdefault(s["file"], set()).add(s["part"])
|
|
252
|
+
craft = [f for f in read if f not in by_file or f.endswith("SKILL.md")]
|
|
253
|
+
checks = sorted({s["file"] for s in smells if s["part"] == "checks"})
|
|
254
|
+
floor = sorted({"%s:%d %s" % (s["file"], s["line"], s["class"]) for s in smells if s["part"] == "floor"})
|
|
255
|
+
return {"craft": craft, "checks": checks, "floor": floor}
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
def main(argv):
|
|
259
|
+
args = [a for a in argv[1:] if a != "--json"]
|
|
260
|
+
as_json = "--json" in argv[1:]
|
|
261
|
+
if len(args) != 1:
|
|
262
|
+
print("usage: python3 scripts/heavy_skill_smell.py <skill or plugin folder> [--json]"); return 2
|
|
263
|
+
root = args[0]
|
|
264
|
+
if not os.path.isdir(root):
|
|
265
|
+
print("UNMEASURED: not a folder: %s" % root); return 2
|
|
266
|
+
smells, read, unreadable, routed, split_rows = scan(root)
|
|
267
|
+
if not read:
|
|
268
|
+
print("UNMEASURED: no readable text file under %s%s" % (root, (" (unreadable: %d)" % len(unreadable)) if unreadable else ""))
|
|
269
|
+
return 2
|
|
270
|
+
incomplete = bool(unreadable)
|
|
271
|
+
sp = split(smells, read)
|
|
272
|
+
counts = {cid: sum(1 for s in smells if s["class"] == cid) for cid, *_ in CLASSES}
|
|
273
|
+
if as_json:
|
|
274
|
+
print(json.dumps({"folder": root, "files_read": len(read), "unreadable": unreadable, "smells": smells,
|
|
275
|
+
"counts": counts, "split": sp, "routed": routed, "split_rows": split_rows, "advisory": True,
|
|
276
|
+
"complete": not incomplete}, ensure_ascii=False, indent=1))
|
|
277
|
+
return 2 if incomplete else 0
|
|
278
|
+
print("heavy_skill_smell: %s — read %d file(s)%s" % (root, len(read), (", unreadable %d" % len(unreadable)) if unreadable else ""))
|
|
279
|
+
for s in smells:
|
|
280
|
+
print("SMELL %s %s %s:%d %s" % (s["class"], s["name"], s["file"], s["line"], s["text"]))
|
|
281
|
+
print(" → %s: %s" % (s["part"], s["move"]))
|
|
282
|
+
for r in routed:
|
|
283
|
+
kind = "HANDOFF" if r["via"].startswith("HANDOFF") else "ROUTED"
|
|
284
|
+
print("%s %s:%d %s — %s" % (kind, r["file"], r["line"], r["text"], r["via"]))
|
|
285
|
+
if split_rows:
|
|
286
|
+
print("NOTE %d split-table row(s) (last cell «deleted»/«routed») not scanned — they record a removal; check none is a live rule" % len(split_rows))
|
|
287
|
+
print("SUMMARY " + " ".join("%s=%d" % kv for kv in counts.items()) + " (smells=%d)" % len(smells))
|
|
288
|
+
if smells:
|
|
289
|
+
print("SPLIT (proposed — the author decides)")
|
|
290
|
+
print(" craft: " + (", ".join(sp["craft"]) or "-") + " (keep; SKILL.md minus the lines listed under floor)")
|
|
291
|
+
print(" checks: " + (", ".join(sp["checks"]) or "-") + " (turn into lanes the manifest's calibration runs)")
|
|
292
|
+
print(" floor: " + (", ".join(sp["floor"]) or "-") + " (delete; route irreversible actions with core_route)")
|
|
293
|
+
else:
|
|
294
|
+
print("NOT-DETECTED by these 7 pattern families — not proof that no embedded harness is present")
|
|
295
|
+
print("NOTE advisory: exit 0 means «read», not «clean». Guide: knowledge/shared/harness-core/heavy_skill_to_cartridge.md")
|
|
296
|
+
if incomplete:
|
|
297
|
+
for f, e in unreadable:
|
|
298
|
+
print("UNREADABLE %s — %s" % (f, e))
|
|
299
|
+
print("UNMEASURED: %d file(s)/folder(s) could not be read — the scan is incomplete, so no count above is a total" % len(unreadable))
|
|
300
|
+
return 2
|
|
301
|
+
return 0
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
if __name__ == "__main__":
|
|
305
|
+
try:
|
|
306
|
+
sys.exit(main(sys.argv))
|
|
307
|
+
except SystemExit:
|
|
308
|
+
raise
|
|
309
|
+
except BaseException as e: # noqa: BLE001 — advisory tool: any failure is UNMEASURED (2), never 1
|
|
310
|
+
print("UNMEASURED: heavy_skill_smell failed: %s: %s" % (type(e).__name__, e))
|
|
311
|
+
sys.exit(2)
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""job_heartbeat.py — at session start, name the recent days on which an installed nightly job left no
|
|
3
|
+
output file, and set apart the days inside an operator-recorded pause.
|
|
4
|
+
|
|
5
|
+
Why (weekly audits 2026-11-04 and 2026-11-20): a nightly job that stops producing output says nothing.
|
|
6
|
+
frontier-digest's autopilot went 25 nights SKIPPED with nobody reading the log (10-11..11-04). On
|
|
7
|
+
11-18 the live-eval and selfdev reports were missing too — that one was a planned pause (the operator
|
|
8
|
+
asked for `launchctl bootout` at 77% weekly quota on 11-17 and a resume on 11-18), but the pause was
|
|
9
|
+
written only in the lease archive, so the audit first read it as a failure. This prints the dates;
|
|
10
|
+
it judges nothing, blocks nothing and never touches a job or its plist.
|
|
11
|
+
|
|
12
|
+
What it reads:
|
|
13
|
+
· installed jobs = <agents dir>/com.forge-harness.<label>.plist present, for the labels in JOBS
|
|
14
|
+
(frontier-digest is not here: fh_session_load.sh already checks it)
|
|
15
|
+
· expected output per day = the JOBS pattern under <meta dir>; a day counts only from the first day
|
|
16
|
+
that job ever produced output (a job installed last week is not «missing» for the weeks before)
|
|
17
|
+
· an output is a non-empty regular file (a crashed run's 0-byte file or a directory is not output)
|
|
18
|
+
· an installed job with no output file at all is named once («no output file found») — it is never silent
|
|
19
|
+
· today is never checked (the job may not have run yet)
|
|
20
|
+
· default meta dir = the main checkout's tracks/_meta (git --git-common-dir), so a worktree session —
|
|
21
|
+
whose own tracks/ is gitignored and empty — does not report every job as missing
|
|
22
|
+
· pauses = <meta dir>/job_pauses.tsv — one row per pause: label<TAB>from<TAB>to<TAB>source
|
|
23
|
+
(label or `*`; dates YYYY-MM-DD inclusive, from <= to; source non-empty = where the operator's words
|
|
24
|
+
are recorded). A row missing any of that is unreadable: counted, never a pause. Absent or unreadable
|
|
25
|
+
file → the gap lines say the pause record was not read; a gap is then not a failure claim.
|
|
26
|
+
|
|
27
|
+
usage: python3 scripts/job_heartbeat.py [--meta DIR] [--agents DIR] [--today YYYY-MM-DD] [--days N]
|
|
28
|
+
python3 scripts/job_heartbeat.py --self-test
|
|
29
|
+
exit: always 0 (advisory); a reader error prints one HARNESS-ERROR line
|
|
30
|
+
"""
|
|
31
|
+
import datetime as dt, os, re, subprocess, sys
|
|
32
|
+
|
|
33
|
+
DATE = re.compile(r'^\d{4}-\d{2}-\d{2}$') # fromisoformat alone also takes 20261118 / 2026-W47-3 on 3.11+
|
|
34
|
+
|
|
35
|
+
JOBS = [ # (launchd label suffix, output path under the meta dir for run day D, day offset of the name)
|
|
36
|
+
('live-eval', 'live_eval_{d}.md', 0),
|
|
37
|
+
('selfdev-loop', 'selfdev/report_{d}.md', 0),
|
|
38
|
+
('daily-report', 'daily_report_{d}.md', -1), # written on D about D-1
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _opt(argv, name, default):
|
|
43
|
+
return argv[argv.index(name) + 1] if name in argv and argv.index(name) + 1 < len(argv) else default
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def read_pauses(path):
|
|
47
|
+
"""([(label, from, to)], bad) — or (None, 0) when the file is absent or unreadable."""
|
|
48
|
+
try:
|
|
49
|
+
text = open(path, encoding='utf-8', errors='replace').read()
|
|
50
|
+
except OSError:
|
|
51
|
+
return None, 0
|
|
52
|
+
rows, bad = [], 0
|
|
53
|
+
for line in text.splitlines():
|
|
54
|
+
if not line.strip() or line.lstrip().startswith('#'):
|
|
55
|
+
continue
|
|
56
|
+
f = [x.strip() for x in line.split('\t')]
|
|
57
|
+
if len(f) < 4 or not f[0] or not f[3] or not DATE.match(f[1]) or not DATE.match(f[2]):
|
|
58
|
+
bad += 1; continue
|
|
59
|
+
a, b = dt.date.fromisoformat(f[1]), dt.date.fromisoformat(f[2])
|
|
60
|
+
if a > b:
|
|
61
|
+
bad += 1; continue
|
|
62
|
+
rows.append((f[0], a, b))
|
|
63
|
+
return rows, bad
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def is_output(path):
|
|
67
|
+
try:
|
|
68
|
+
return os.path.isfile(path) and os.path.getsize(path) > 0
|
|
69
|
+
except OSError:
|
|
70
|
+
return False
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def first_output(meta, pattern, off):
|
|
74
|
+
"""Earliest run day that has an output file, by scanning the directory of the pattern."""
|
|
75
|
+
sub, _, name = pattern.rpartition('/')
|
|
76
|
+
d = os.path.join(meta, sub) if sub else meta
|
|
77
|
+
head, tail = name.split('{d}')
|
|
78
|
+
best = None
|
|
79
|
+
try:
|
|
80
|
+
names = os.listdir(d)
|
|
81
|
+
except OSError:
|
|
82
|
+
return None
|
|
83
|
+
for n in names:
|
|
84
|
+
if n.startswith(head) and n.endswith(tail) and DATE.match(n[len(head):len(n) - len(tail)]) \
|
|
85
|
+
and is_output(os.path.join(d, n)):
|
|
86
|
+
try:
|
|
87
|
+
day = dt.date.fromisoformat(n[len(head):len(n) - len(tail)]) - dt.timedelta(days=off)
|
|
88
|
+
except ValueError:
|
|
89
|
+
continue
|
|
90
|
+
best = day if best is None or day < best else best
|
|
91
|
+
return best
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def check(meta, agents, today, days):
|
|
95
|
+
pauses, bad = read_pauses(os.path.join(meta, 'job_pauses.tsv'))
|
|
96
|
+
lines = []
|
|
97
|
+
for label, pattern, off in JOBS:
|
|
98
|
+
if not os.path.isfile(os.path.join(agents, 'com.forge-harness.%s.plist' % label)):
|
|
99
|
+
continue
|
|
100
|
+
first = first_output(meta, pattern, off)
|
|
101
|
+
if first is None:
|
|
102
|
+
lines.append('⏰ [job-heartbeat] %s — installed, but no output file found under %s' % (label, meta))
|
|
103
|
+
continue
|
|
104
|
+
missing, paused = [], []
|
|
105
|
+
for k in range(days, 0, -1):
|
|
106
|
+
run = today - dt.timedelta(days=k)
|
|
107
|
+
if run < first:
|
|
108
|
+
continue
|
|
109
|
+
stamp = (run + dt.timedelta(days=off)).isoformat()
|
|
110
|
+
if is_output(os.path.join(meta, pattern.format(d=stamp))):
|
|
111
|
+
continue
|
|
112
|
+
if pauses and any(p[0] in (label, '*') and p[1] <= run <= p[2] for p in pauses):
|
|
113
|
+
paused.append(run.isoformat())
|
|
114
|
+
else:
|
|
115
|
+
missing.append(run.isoformat())
|
|
116
|
+
if missing or paused:
|
|
117
|
+
parts = []
|
|
118
|
+
if missing:
|
|
119
|
+
parts.append('no output for %s' % ', '.join(missing))
|
|
120
|
+
if paused:
|
|
121
|
+
parts.append('paused (recorded): %s' % ', '.join(paused))
|
|
122
|
+
lines.append('⏰ [job-heartbeat] %s — %s (last %d days, today not checked)' % (label, ' · '.join(parts), days))
|
|
123
|
+
if lines and pauses is None:
|
|
124
|
+
lines.append(' pause record not read (%s absent or unreadable) — a date above may be a planned pause; '
|
|
125
|
+
'record one as label<TAB>from<TAB>to<TAB>source' % os.path.join(meta, 'job_pauses.tsv'))
|
|
126
|
+
if bad and lines: # only next to a gap — a bad row must not print at every session start
|
|
127
|
+
lines.append(' job_pauses.tsv: %d unreadable row(s) skipped' % bad)
|
|
128
|
+
return lines
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def self_test():
|
|
132
|
+
import tempfile
|
|
133
|
+
t = tempfile.mkdtemp(prefix='jhb.')
|
|
134
|
+
meta, ag = os.path.join(t, 'meta'), os.path.join(t, 'ag')
|
|
135
|
+
os.makedirs(os.path.join(meta, 'selfdev')); os.makedirs(ag)
|
|
136
|
+
for lab in ('live-eval', 'selfdev-loop'):
|
|
137
|
+
open(os.path.join(ag, 'com.forge-harness.%s.plist' % lab), 'w').close()
|
|
138
|
+
for d in ('2026-11-15', '2026-11-16', '2026-11-17', '2026-11-19'):
|
|
139
|
+
open(os.path.join(meta, 'live_eval_%s.md' % d), 'w').write('x')
|
|
140
|
+
open(os.path.join(meta, 'selfdev', 'report_%s.md' % d), 'w').write('x')
|
|
141
|
+
today = dt.date(2026, 11, 20)
|
|
142
|
+
ok = 0
|
|
143
|
+
a = check(meta, ag, today, 3)
|
|
144
|
+
ok += any('live-eval — no output for 2026-11-18' in x for x in a) and any('pause record not read' in x for x in a)
|
|
145
|
+
open(os.path.join(meta, 'job_pauses.tsv'), 'w').write('live-eval\t2026-11-17\t2026-11-18\toperator 11-17\n')
|
|
146
|
+
b = check(meta, ag, today, 3)
|
|
147
|
+
ok += any('live-eval — paused (recorded): 2026-11-18' in x for x in b) and any('selfdev-loop — no output for 2026-11-18' in x for x in b) \
|
|
148
|
+
and not any('pause record not read' in x for x in b)
|
|
149
|
+
open(os.path.join(meta, 'live_eval_2026-11-18.md'), 'w').write('x')
|
|
150
|
+
open(os.path.join(meta, 'selfdev', 'report_2026-11-18.md'), 'w').write('x')
|
|
151
|
+
ok += check(meta, ag, today, 3) == []
|
|
152
|
+
print('job_heartbeat self-test: %d/3' % ok)
|
|
153
|
+
return 0 if ok == 3 else 1
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def main_checkout(root):
|
|
157
|
+
"""The main checkout of the repo holding `root` (a worktree resolves to its main tree), else root."""
|
|
158
|
+
try:
|
|
159
|
+
g = subprocess.run(['git', '-C', root, 'rev-parse', '--git-common-dir'], capture_output=True,
|
|
160
|
+
text=True, timeout=3).stdout.strip()
|
|
161
|
+
g = os.path.realpath(os.path.join(root, g)) if g else ''
|
|
162
|
+
if g and os.path.basename(g) == '.git' and os.path.isdir(os.path.join(os.path.dirname(g), 'tracks')):
|
|
163
|
+
return os.path.dirname(g)
|
|
164
|
+
except Exception:
|
|
165
|
+
pass
|
|
166
|
+
return root
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def main(argv):
|
|
170
|
+
if '--self-test' in argv:
|
|
171
|
+
return self_test()
|
|
172
|
+
root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
173
|
+
meta = _opt(argv, '--meta', None) or os.path.join(main_checkout(root), 'tracks', '_meta')
|
|
174
|
+
agents = _opt(argv, '--agents', os.path.expanduser('~/Library/LaunchAgents'))
|
|
175
|
+
try:
|
|
176
|
+
today = dt.date.fromisoformat(_opt(argv, '--today', dt.date.today().isoformat()))
|
|
177
|
+
days = int(_opt(argv, '--days', '3'))
|
|
178
|
+
for line in check(meta, agents, today, days):
|
|
179
|
+
print(line)
|
|
180
|
+
except Exception as e: # advisory: a broken reader is named, never a crash in the session start
|
|
181
|
+
print('⏰ [job-heartbeat] HARNESS-ERROR: %s — nothing was checked' % e)
|
|
182
|
+
return 0
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
if __name__ == '__main__':
|
|
186
|
+
sys.exit(main(sys.argv[1:]))
|