@chrono-meta/fh-gate 1.0.3 → 1.2.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.
Files changed (69) hide show
  1. package/.claude/agents/challenger.md +169 -0
  2. package/AGENTS.md +160 -0
  3. package/CATALOG.md +256 -0
  4. package/CHEATSHEET.md +367 -0
  5. package/CLAUDE.md +331 -0
  6. package/CONTRIBUTING.md +198 -0
  7. package/LICENSE +21 -0
  8. package/README.md +131 -418
  9. package/bin/fh-goal.js +9 -0
  10. package/bin/fh-run.js +9 -0
  11. package/docs/banner.png +0 -0
  12. package/docs/codex-compat.md +123 -0
  13. package/docs/pillars.svg +70 -0
  14. package/knowledge/shared/harness-core/fh_integration_contract.md +48 -29
  15. package/package.json +31 -6
  16. package/plugins/fh-commons/README.md +37 -0
  17. package/plugins/fh-commons/agents/quench-challenger.md +373 -0
  18. package/plugins/fh-commons/skills/convergence-loop/SKILL.md +155 -0
  19. package/plugins/fh-commons/skills/deliberation/SKILL.md +288 -0
  20. package/plugins/fh-commons/skills/mcp-circuit-breaker/SKILL.md +196 -0
  21. package/plugins/fh-commons/skills/token-budget-gate/SKILL.md +175 -0
  22. package/plugins/fh-meta/agents/fact-checker.md +121 -0
  23. package/plugins/fh-meta/agents/hub-persona-auditor.md +109 -0
  24. package/plugins/fh-meta/agents/persona-innovator.md +195 -0
  25. package/plugins/fh-meta/skills/agent-composer/SKILL.md +461 -0
  26. package/plugins/fh-meta/skills/agent-composer/SKILL_detail.md +464 -0
  27. package/plugins/fh-meta/skills/apex-review/SKILL.md +185 -0
  28. package/plugins/fh-meta/skills/asset-placement-gate/SKILL.md +135 -0
  29. package/plugins/fh-meta/skills/contention-layer/SKILL.md +127 -0
  30. package/plugins/fh-meta/skills/context-bridge-dispatch/SKILL.md +30 -0
  31. package/plugins/fh-meta/skills/context-bridge-dispatch/SKILL_detail.md +144 -0
  32. package/plugins/fh-meta/skills/context-doctor/SKILL.md +341 -0
  33. package/plugins/fh-meta/skills/cross-ecosystem-synergy-detection/SKILL.md +202 -0
  34. package/plugins/fh-meta/skills/deep-clarify/SKILL.md +144 -0
  35. package/plugins/fh-meta/skills/edit-manifest/SKILL.md +210 -0
  36. package/plugins/fh-meta/skills/field-harvest/SKILL.md +384 -0
  37. package/plugins/fh-meta/skills/frontier-digest/SKILL.md +272 -0
  38. package/plugins/fh-meta/skills/goal-quench/SKILL.md +509 -0
  39. package/plugins/fh-meta/skills/harness-doctor/SKILL.md +277 -0
  40. package/plugins/fh-meta/skills/harness-doctor/SKILL_detail.md +484 -0
  41. package/plugins/fh-meta/skills/harvest-loop/SKILL.md +231 -0
  42. package/plugins/fh-meta/skills/harvest-loop/SKILL_detail.md +201 -0
  43. package/plugins/fh-meta/skills/hub-cc-pr-reviewer/SKILL.md +129 -0
  44. package/plugins/fh-meta/skills/hub-cc-pr-reviewer/SKILL_detail.md +158 -0
  45. package/plugins/fh-meta/skills/install-doctor/SKILL.md +207 -0
  46. package/plugins/fh-meta/skills/install-wizard/SKILL.md +613 -0
  47. package/plugins/fh-meta/skills/marketplace-gate/SKILL.md +193 -0
  48. package/plugins/fh-meta/skills/memory-hygiene/SKILL.md +143 -0
  49. package/plugins/fh-meta/skills/meta-prompt-builder/SKILL.md +167 -0
  50. package/plugins/fh-meta/skills/meta-prompt-builder/SKILL_detail.md +37 -0
  51. package/plugins/fh-meta/skills/pipeline-conductor/SKILL.md +430 -0
  52. package/plugins/fh-meta/skills/plugin-recommender/SKILL.md +221 -0
  53. package/plugins/fh-meta/skills/plugin-recommender/SKILL_detail.md +220 -0
  54. package/plugins/fh-meta/skills/prompt-regression/SKILL.md +178 -0
  55. package/plugins/fh-meta/skills/public-surface-audit/SKILL.md +224 -0
  56. package/plugins/fh-meta/skills/return-path-gate/SKILL.md +257 -0
  57. package/plugins/fh-meta/skills/self-marketing-lint/SKILL.md +129 -0
  58. package/plugins/fh-meta/skills/sim-conductor/SKILL.md +364 -0
  59. package/plugins/fh-meta/skills/sim-conductor/SKILL_detail.md +337 -0
  60. package/plugins/fh-meta/skills/skill-splitter/SKILL.md +126 -0
  61. package/plugins/fh-meta/skills/skill-splitter/SKILL_detail.md +185 -0
  62. package/plugins/fh-meta/skills/source-grounding-audit/SKILL.md +230 -0
  63. package/plugins/fh-meta/skills/source-grounding-audit/SKILL_detail.md +182 -0
  64. package/plugins/fh-meta/skills/steel-quench/SKILL.md +226 -0
  65. package/plugins/fh-meta/skills/steel-quench/SKILL_detail.md +453 -0
  66. package/plugins/fh-meta/skills/verify-bidirectional/SKILL.md +238 -0
  67. package/scripts/fh-gate.sh +175 -40
  68. package/scripts/fh-goal.sh +182 -0
  69. package/scripts/fh-run.sh +269 -0
@@ -0,0 +1,210 @@
1
+ ---
2
+ name: edit-manifest
3
+ description: Implements a predict-verify loop for harness edits. Every SKILL.md, rules/*.md, or CLAUDE.md change is paired with a predicted impact stored in a manifest. The next session verifies predictions against actual outcomes, and a validation gate accepts edits only when improvement is measurable. Runs automatically on harvest-loop Step 0-c and on explicit invocation.
4
+ user-invocable: true
5
+ allowed-tools: ["Read", "Write", "Edit", "Grep", "Glob", "Bash"]
6
+ model: sonnet
7
+ ---
8
+
9
+ # edit-manifest — Predict-Verify Loop for Harness Edits
10
+
11
+ > Implements two mechanisms from frontier harness research:
12
+ > - **Change Manifest** (AHE, arXiv:2604.25850): every edit declares a falsifiable prediction;
13
+ > the next iteration verifies it against actual outcomes.
14
+ > - **Validation Gate** (SkillOpt, arXiv:2605.23904): candidate edits are accepted only when
15
+ > the selection-split score strictly improves. Rejected edits are retained as negative
16
+ > feedback for future proposals — not silently discarded.
17
+
18
+ FH's regression_guard.sh catches backward regressions. edit-manifest closes the forward
19
+ loop: did the edit actually improve what it claimed to improve?
20
+
21
+ **Boundary vs. verify-bidirectional**: verify-bidirectional is *reactive* — it updates the
22
+ baseline when the user raises a counter-argument to an AI recommendation. edit-manifest is
23
+ *predictive* — it records a forward prediction at edit time and verifies it against outcomes
24
+ later, with no user counter-argument required. Different axes: one responds to challenge,
25
+ the other tests a self-declared hypothesis.
26
+
27
+ ## Manifest File Location
28
+
29
+ ```
30
+ tracks/_meta/edit_manifest.yaml
31
+ ```
32
+
33
+ Single append-only file. Entries are never deleted — they accumulate as the harness's
34
+ edit history and negative-feedback buffer.
35
+
36
+ ## Manifest Entry Format
37
+
38
+ ```yaml
39
+ - id: em-{YYYY-MM-DD}-{slug}
40
+ date: YYYY-MM-DD
41
+ file: plugins/fh-meta/skills/{skill}/SKILL.md # relative to repo root
42
+ edit_summary: "added 'trigger phrase X' to natural language triggers"
43
+ predicted_impact: "users entering via phrase X will increase — estimate +1 session/week"
44
+ predicted_measurable_by: "session start logs or user utterance pattern in next 2 sessions"
45
+ validation_status: pending # pending | verified | falsified | untestable
46
+ verified_at: null
47
+ verification_note: null
48
+ gate_decision: null # accepted | rejected
49
+ ```
50
+
51
+ ## Trigger Conditions
52
+
53
+ ### Automatic — Record Phase (on every FH asset edit)
54
+
55
+ Whenever the **3-axis auto-gate** in CLAUDE.md fires (any SKILL.md / rules / CLAUDE.md edit),
56
+ append a manifest entry **before** committing.
57
+
58
+ > **Wiring note**: This Record step is invoked manually or via harvest-loop until the
59
+ > CLAUDE.md 3-axis auto-gate is explicitly extended to call it. The auto-gate currently
60
+ > chains regression_guard → steel-quench → source-grounding-audit; adding edit-manifest
61
+ > Record as a pre-step is a proposed extension, not yet wired. Do not assume automatic
62
+ > invocation — call it explicitly after an FH asset edit.
63
+
64
+ ### Automatic — Verify Phase (harvest-loop Step 0-c)
65
+
66
+ At session start (via harvest-loop), read all `pending` entries and attempt verification.
67
+
68
+ ### Manual
69
+
70
+ | Phrase | Action |
71
+ |---|---|
72
+ | "check edit manifest", "did our edits work?" | Full verify pass on pending entries |
73
+ | "show rejected edits", "what didn't work?" | Display rejected-edits buffer |
74
+ | "add to manifest", "record this edit" | Manual Record step |
75
+
76
+ ## Execution Steps
77
+
78
+ ### RECORD mode (called on each FH asset edit)
79
+
80
+ **Step R1 — Draft Entry**
81
+
82
+ Prompt the AI (or the user, for high-stakes edits) to fill:
83
+ - `edit_summary`: one line, what changed
84
+ - `predicted_impact`: what observable improvement is expected
85
+ - `predicted_measurable_by`: how and when this can be checked
86
+
87
+ **Step R2 — Append to Manifest**
88
+
89
+ ```bash
90
+ # Append YAML block to tracks/_meta/edit_manifest.yaml
91
+ ```
92
+
93
+ Output confirmation: `edit-manifest: entry em-{date}-{slug} recorded`
94
+
95
+ **Step R3 — Flag Untestable Predictions**
96
+
97
+ If `predicted_measurable_by` is vague ("generally better", "feels cleaner") → mark
98
+ `validation_status: untestable` immediately. These are tracked separately as a signal
99
+ that the edit rationale needs sharpening.
100
+
101
+ ---
102
+
103
+ ### VERIFY mode (harvest-loop Step 0-c or manual)
104
+
105
+ **Step V1 — Load Pending Entries**
106
+
107
+ ```bash
108
+ grep -A20 "validation_status: pending" tracks/_meta/edit_manifest.yaml
109
+ ```
110
+
111
+ Skip entries where `predicted_measurable_by` date has not yet passed.
112
+
113
+ **Step V2 — Verify Each Entry**
114
+
115
+ For each pending entry, check the evidence source specified in `predicted_measurable_by`:
116
+
117
+ | Evidence Source | Check Method |
118
+ |---|---|
119
+ | Session utterance patterns | Grep `tracks/_meta/` for trigger phrases |
120
+ | Skill invocation count | Read `knowledge/shared/learnings/subagent_invocations_log.yaml` (create if absent) |
121
+ | User friction signals | Grep `tracks/_meta/fh_signal_*.md` for related friction |
122
+ | Git commit frequency | `git log --oneline --since={date} -- {file}` |
123
+
124
+ > **Circularity guard**: edit-manifest is invoked *by* harvest-loop (Step 0-c). To avoid a
125
+ > circular evidence loop, edit-manifest must NOT use harvest-loop's own synthesis outputs
126
+ > (proposal lists, curator decisions) as verification evidence. Evidence sources are limited
127
+ > to primary signals — raw utterance logs, invocation counts, git history, friction signals —
128
+ > that exist independently of any harvest-loop run.
129
+
130
+ **Step V3 — Apply Validation Gate**
131
+
132
+ | Outcome | Gate Decision | Next Action |
133
+ |---|---|---|
134
+ | Evidence confirms prediction | `verified` → `accepted` | No action needed |
135
+ | Evidence contradicts prediction | `falsified` → `rejected` | Add to rejected-edits buffer; propose revert if regression |
136
+ | No evidence yet | Keep `pending` | Re-check next session |
137
+ | Untestable | `untestable` | Flag for human judgment |
138
+
139
+ **Step V4 — Rejected-Edits Buffer Report**
140
+
141
+ After verification pass, output rejected entries as a learning signal:
142
+
143
+ ```
144
+ edit-manifest: verification complete
145
+ Verified (accepted): N
146
+ Falsified (rejected): N
147
+ Still pending: N
148
+ Untestable: N
149
+
150
+ Rejected edits (negative feedback buffer):
151
+ em-2026-05-28-trigger-phrase: predicted "+1 session/week via phrase X"
152
+ → falsified: no utterance evidence in 7 sessions
153
+ → proposed revert: [y/N]
154
+ ```
155
+
156
+ **Step V5 — Update Manifest**
157
+
158
+ Apply `verified_at`, `verification_note`, `gate_decision` to each resolved entry via Edit.
159
+
160
+ ## Validation Gate Logic
161
+
162
+ Mirrors SkillOpt's selection-split gate:
163
+
164
+ ```
165
+ IF verified evidence shows improvement:
166
+ gate_decision = accepted (edit stays)
167
+ ELSE IF falsified (no improvement or regression):
168
+ gate_decision = rejected
169
+ → retained in manifest as negative feedback
170
+ → future edit proposals for same file grep rejected entries first
171
+ → propose revert to human
172
+ ELSE:
173
+ stay pending
174
+ ```
175
+
176
+ **Rejected-Edit Reuse**: When proposing a new edit for a file, the AI must grep
177
+ `edit_manifest.yaml` for prior `rejected` entries on that file and explicitly
178
+ state why the new proposal avoids the same failure mode.
179
+
180
+ ## Constraints
181
+
182
+ - **Append-only**: Never delete manifest entries. Rejected edits are the most valuable
183
+ learning signal — they prevent the same mistake twice.
184
+ - **Human gate on revert**: Gate decision `rejected` proposes revert; human confirms.
185
+ - **Simplification guard**: If no pending entries exist, output one line
186
+ "edit-manifest: no pending entries" and exit.
187
+ - **Untestable rate alarm**: If `untestable` entries exceed 30% of total, flag:
188
+ "edit rationale quality degrading — predictions are not falsifiable."
189
+
190
+ ## Done When
191
+
192
+ ```
193
+ RECORD mode:
194
+ Entry appended to edit_manifest.yaml
195
+ + Untestable flag applied if vague prediction
196
+
197
+ VERIFY mode:
198
+ All pending entries checked
199
+ + Gate decisions applied (accepted / rejected / pending)
200
+ + Rejected-edits buffer reported
201
+ + Manifest file updated via Edit
202
+ + Human gate presented for any proposed reverts
203
+ ```
204
+
205
+ ## References
206
+
207
+ - Theoretical basis: AHE (arXiv:2604.25850) §4 change manifest + prediction falsifiability
208
+ - Validation gate: SkillOpt (arXiv:2605.23904) §3.3 selection-split gate + rejected-edit buffer
209
+ - Integrates with: `harvest-loop` Step 0-c · `verify-bidirectional` · 3-axis auto-gate (CLAUDE.md)
210
+ - Manifest file: `tracks/_meta/edit_manifest.yaml`
@@ -0,0 +1,384 @@
1
+ ---
2
+ name: field-harvest
3
+ description: Scans git history of field projects to detect patterns worth backporting to the meta-harness (Mode A), and logs session work to the knowledge hub when a session ends (Mode B). Triggers on "save this pattern", "make this reusable across projects", "can we automate this repetition?", "push this to FH", "reverse absorption", "harvest pattern", "session log", "log today's work", "sync to hub".
4
+ user-invocable: true
5
+ allowed-tools: ["Bash", "Read", "Edit", "Write", "WebFetch"]
6
+ model: sonnet
7
+ ---
8
+
9
+ # field-harvest — Field Pattern Harvest → FH Backport + Session Logger
10
+
11
+ Dual-mode skill:
12
+ - **Mode A (Pattern Harvest)**: Scans recent commits in field projects to detect patterns worth backporting to FH. One-click flow from detection to PR creation.
13
+ - **Mode B (Session Log)**: Records session work from field projects to the knowledge hub when a session ends. Auto-generates a session markdown file with commits, learnings, and next steps.
14
+
15
+ ## Mode Selection (Step 0-A)
16
+
17
+ Determine which mode to run based on user context:
18
+
19
+ | Condition | Mode | Priority |
20
+ |---|---|:---:|
21
+ | User message contains: "session log", "log today's work", "sync to hub", "sync session" | **Mode B (Session Log)** | 1 (highest) |
22
+ | **Session-end auto-trigger fires** (see below) and field commits exist today | **Mode B (Session Log)** — auto-proposed | 2 |
23
+ | Both Mode A and B applicable | Run Mode B first, then ask "Also run Mode A pattern harvest?" | 3 |
24
+ | Default or path specified | **Mode A (Pattern Harvest)** | 4 |
25
+
26
+ ### Session-End Auto-Trigger (item1 — Mode B)
27
+
28
+ Mode B should not wait for an explicit "session log" phrase when a session is plainly ending with un-logged field work. **Auto-propose Mode B** (one line, never auto-run) when **all** hold:
29
+
30
+ 1. A session-close signal is detected — the CLAUDE.md Session Wrap-up chain has begun, **or** the user says a closing phrase ("wrap up", "done", "good work", "end session", "that's it for today").
31
+ 2. The current cwd is a **mapped field project** (not the FH hub itself — hub close is owned by harvest-loop / the Session Wrap-up chain).
32
+ 3. `git log --since="today"` in that field project returns **1+ commits** by the session author that are **not yet logged** to the hub (cross-check via the detection-skip ledger, item2 below).
33
+
34
+ Proposal format (one line, then wait):
35
+ ```
36
+ "Session is wrapping up and {project} has N un-logged commits today. Log them to the hub with Mode B? [y/n]"
37
+ ```
38
+
39
+ **Collision guard (harvest-loop boundary)**: "wrap up" / "end session" in the **FH hub cwd** stay owned by the CLAUDE.md Session Wrap-up chain (which calls harvest-loop). This auto-trigger is **field-cwd only** and is a *proposal*, never an interception — if harvest-loop is already running for this session, do not also propose Mode B (harvest-loop calls field-harvest internally as Step H1). One proposal per session.
40
+
41
+ > **Note**: harvest-loop remains the owner of hub-side wrap-up. Mode B auto-trigger only covers the gap where a *field* session ends with un-logged commits and the user never typed an explicit session-log phrase.
42
+
43
+ **Execution order when both applicable**: Run git scan once, reuse results for both modes to avoid duplicate scans.
44
+
45
+ ---
46
+
47
+ ## Step 0. Field Project Path Detection
48
+
49
+ When no path is specified, auto-detect with 3-level priority:
50
+
51
+ ```bash
52
+ # Priority 1: Read FH auto_project_mapping.md
53
+ cat .claude/rules/auto_project_mapping.md 2>/dev/null | grep -E "path:|project:" | head -10
54
+
55
+ # Priority 2: Auto-discover git repos in common development directories
56
+ find "$HOME/projects" "$HOME/dev" "$HOME/workspace" "$HOME/PycharmProjects" \
57
+ -maxdepth 2 -name ".git" -type d 2>/dev/null \
58
+ | sed 's|/.git||' \
59
+ | grep -v "forge-harness\|harness_framework" \
60
+ | head -10
61
+
62
+ # Priority 3: Scan parent directory of current cwd
63
+ find "$(dirname "$(pwd)")" -maxdepth 1 -name ".git" -type d 2>/dev/null \
64
+ | sed 's|/.git||'
65
+ ```
66
+
67
+ List discovered repos to user and ask to select target. If 0 repos found, prompt for direct path input.
68
+
69
+ ## Step 1. Recent Commit Scan
70
+
71
+ ```bash
72
+ cd "$FIELD_PATH"
73
+ git log --oneline --since="<N> days ago" --no-merges
74
+ ```
75
+
76
+ If commit count is 0, report "no changes within last <N> days" and exit.
77
+
78
+ ## Step 2. Harvest Candidate Classification
79
+
80
+ Classify each commit using the following criteria:
81
+
82
+ ### FH Reverse Absorption Candidate Conditions (when one or more apply)
83
+
84
+ | Signal | Example | FH absorption type |
85
+ |---|---|---|
86
+ | **New workflow pattern** | New CLI tool, pipeline automation | Skill candidate / SKILL.md improvement |
87
+ | **Cross-project feedback** | "This approach can apply to other projects too" | `.claude/rules/` improvement |
88
+ | **Prompt engineering pattern** | Few-shot additions, new CRITICAL RULE | knowledge/shared pattern |
89
+ | **Error pattern solution** | Recurring error → converted to rule | Skill guard addition |
90
+ | **Tool integration method** | MCP integration, API usage patterns | Skill Step expansion |
91
+
92
+ ### Field-only (No FH Reverse Absorption Needed)
93
+
94
+ - Domain-specific code (insurance logic, UXW prompt content itself)
95
+ - Project-specific config/environment files
96
+ - Bug fixes (one-off non-reproducible)
97
+ - Simple documentation updates
98
+
99
+ Classification method:
100
+
101
+ ```bash
102
+ # Commit detail check
103
+ git show <hash> --stat
104
+ git show <hash> -- "*.md" "*.py" "*.sh" | head -100
105
+ ```
106
+
107
+ First classify by commit message + changed file patterns → read diff for detail when needed.
108
+
109
+ ## Step 3. Harvest Candidate List Presentation
110
+
111
+ ```
112
+ field-harvest results — <project name> (within <N> days)
113
+
114
+ Scanned: <total commits>
115
+ FH absorption candidates: <N>
116
+
117
+ Candidate list:
118
+ ┌─────────────────────────────────────────────────────┐
119
+ │ [1] <commit hash> "<commit message>" │
120
+ │ Type: <workflow pattern / feedback rule / ...> │
121
+ │ Absorption location: plugins/fh-meta/skills/<X>/ │
122
+ │ Impact: ★★★ (applicable across projects) │
123
+ ├─────────────────────────────────────────────────────┤
124
+ │ [2] ... │
125
+ └─────────────────────────────────────────────────────┘
126
+
127
+ Field-only (skipped): <M>
128
+
129
+ → Absorb to FH via PR? [all / select number / skip]
130
+ ```
131
+
132
+ If 0 candidates, report "no absorption candidates" and exit.
133
+
134
+ ## Step 4. PR Creation (upon user approval)
135
+
136
+ ```bash
137
+ cd "$FH_ROOT"
138
+ git checkout -b harvest/"$FIELD_PROJECT"-"$YYYYMMDD"
139
+
140
+ # Apply approved patterns
141
+ # - Update skill SKILL.md
142
+ # - Update .claude/rules/
143
+ # - Update templates/
144
+
145
+ git add -A
146
+ git commit -m "harvest($FIELD_PROJECT): $PATTERN_SUMMARY — $FIELD_COMMIT_HASH absorbed"
147
+ git push origin harvest/"$FIELD_PROJECT"-"$YYYYMMDD"
148
+
149
+ gh pr create \
150
+ --title "harvest: $FIELD_PROJECT pattern absorption ($DATE)" \
151
+ --body "..."
152
+ ```
153
+
154
+ PR body includes:
155
+ - Original field commit hash + link
156
+ - Absorbed pattern summary
157
+ - Application location (which skill/rule)
158
+ - Expected cross-project impact
159
+
160
+ ## Step 5. Done (Mode A Complete)
161
+
162
+ Report harvest candidate list and PR creation status to user.
163
+
164
+ ---
165
+
166
+ ## Invocation Triggers
167
+
168
+ ### Auto-Proposal Conditions (detecting user conversation context)
169
+
170
+ Propose `/field-harvest` proactively when these patterns are detected:
171
+
172
+ | Pattern | Example | Proposal strength |
173
+ |---|---|---|
174
+ | **FH absorption intent** | "Should we push this to FH?", "Is this worth absorbing?", "harvest this pattern" | Immediate proposal |
175
+ | **Field pattern discovery** | "Found this pattern in my project", "There's something repeating on that side" | Immediate proposal |
176
+ | **FH improvement idea** | "What if we made this a skill?", "We could turn this into a rule" | Immediate proposal |
177
+ | **Field git log mention** | "Looking at the commits", "Checking recent changes", "What did I do this week?" | Proposal |
178
+
179
+ ### Natural Language Triggers (activates without internal vocabulary)
180
+
181
+ | Example utterance | Intent |
182
+ |---|---|
183
+ | "This approach could be reused in other projects" | Cross-project pattern harvest |
184
+ | "Would be good to save what we found somewhere" | Pattern persistence → absorption |
185
+ | "If our team uses this, other teams probably can too" | FH sharing value detection |
186
+ | "This seems repetitive — can we automate it?" | Repeating pattern harvest candidate |
187
+ | "I forgot what we did last week and had to look it up again" | git log scan trigger |
188
+ | "session log", "log today's work", "sync to hub" | Mode B session log |
189
+
190
+ Proposal format:
191
+ ```
192
+ "There seems to be a field pattern worth absorbing to FH. Scan with `/field-harvest`?"
193
+ ```
194
+
195
+ ### Simplification Guard
196
+
197
+ - If user has already invoked `/field-harvest`, no duplicate proposals
198
+ - If only 1 trigger pattern detected → light 1-line suggestion only (avoid over-intervention)
199
+ - If field cwd cannot be confirmed before proposing → first ask "which field project do you mean?"
200
+
201
+ ---
202
+
203
+ ## Simplification Guard (Global)
204
+
205
+ - **Domain code absorption forbidden**: Field domain logic is not an FH target — auto-skip when detected
206
+ - **Duplicate detection**: When a similar pattern already exists in FH, replace with "cross-reference existing assets then suggest merge"
207
+ - **Minimum validation criteria**: One-off patterns show as candidate + ★ 1 → recommend proper absorption after 3+ accumulations
208
+ - **PRD/sensitive data**: Diffs containing field PRD content or personal information are auto-masked and only the pattern is extracted
209
+
210
+ ---
211
+
212
+ ## External User Environment Adaptation
213
+
214
+ When project paths from the original developer environment are not present:
215
+
216
+ > The original developer's project paths are examples. In external environments, replace with your own project names/paths — Step 0 auto-discover handles detection automatically, no manual replacement needed.
217
+
218
+ - Step 0: Fallback to user-specified path
219
+ - Step 4: `GH_HOST` auto-detection (internal GHE vs github.com)
220
+ - FH ROOT: Auto-detect with `git rev-parse --show-toplevel`
221
+
222
+ ---
223
+
224
+ # Mode B: Session Log → Knowledge Hub Sync
225
+
226
+ Records session work from field projects to the knowledge hub when a session ends. Generates a session markdown file from git history only (no conversation context), then commits to the hub.
227
+
228
+ ## Step 0-B. Locate Hub Path
229
+
230
+ Auto-detect knowledge hub location (3-level priority):
231
+
232
+ ```bash
233
+ # Priority 1: FH environment variables (set in ~/.zshrc)
234
+ echo "${FH_DIR:-${CC_HUB_DIR:-}}"
235
+
236
+ # Priority 2: Auto-discover hub candidates near home
237
+ find ~ -maxdepth 3 -name "tracks" -type d 2>/dev/null \
238
+ | grep -E "(forge-harness|knowledge-hub)" | head -3
239
+
240
+ # Priority 3: Ask user
241
+ ```
242
+
243
+ Determine track subdirectory:
244
+ - Field projects → `tracks/{project-name}/`
245
+ - External collaborations → `tracks/external/{name}/`
246
+
247
+ ## Step 0-B.1. Detection-Skip — Already-Logged Pattern Filter (item2)
248
+
249
+ Before scanning session work, build a **skip ledger** of commits already recorded in the hub so the same commit is not logged twice across sessions (re-runs, overlapping auto-trigger + explicit invocation, multi-session same-day work).
250
+
251
+ **Skip rule**: a field commit hash is **skipped** (excluded from Step 1-B scan output) if it already appears in any existing session file under the project's track directory.
252
+
253
+ > **Detection-skip style: stateless inline-grep (finalized).** FH uses the inline-grep form below
254
+ > rather than a persisted ledger file (`tracks/{project}/.logged_commits`): it keeps no extra state to
255
+ > sync and is self-correcting — the hub session files *are* the ledger. Adequate at FH's scale; a
256
+ > persisted ledger would only pay off on a very large hub where re-grepping all session files is slow.
257
+
258
+ Bind the three paths from earlier Mode B steps: `HUB_PATH` = the hub root from Step 0-B, `TRACK` = the track subdirectory chosen above, `FIELD_PATH` = the field project cwd from Step 0.
259
+
260
+ ```bash
261
+ # Stateless inline-grep: collect hashes already present in hub session files,
262
+ # then filter today's field commits against them.
263
+ LOGGED=$(grep -rhoE '\b[0-9a-f]{7,40}\b' "$HUB_PATH/tracks/$TRACK/" 2>/dev/null | sort -u)
264
+
265
+ git -C "$FIELD_PATH" log --oneline --since="today" --no-merges \
266
+ --author="$(git -C "$FIELD_PATH" config user.name)" \
267
+ | while read -r hash rest; do
268
+ # skip if this hash is already logged in any hub session file
269
+ echo "$LOGGED" | grep -q "^${hash}" && continue
270
+ echo "$hash $rest"
271
+ done
272
+ ```
273
+
274
+ If **all** of today's commits are already logged, report `"All N commits today are already logged to the hub — nothing new to record"` and exit (Mode B done, no empty session file written). This is also what the item1 auto-trigger consults to count *un-logged* commits — the auto-trigger must not fire on a session whose commits are all already logged.
275
+
276
+ **Limitations (honest)**: hash-prefix matching can collide on very short prefixes (use 7+ chars) and only catches commits that were logged with their hash listed in the `## Commits` section (Step 3-B always lists hashes, so hub-generated logs are covered). It does not dedupe *uncommitted* work — that is intentional, uncommitted changes have no stable identity to skip on.
277
+
278
+ ## Step 1-B. Scan Current Session Work
279
+
280
+ Use the **detection-skip-filtered** commit set from Step 0-B.1 (already-logged hashes removed), not the raw `git log`:
281
+
282
+ ```bash
283
+ cd <field-project-path>
284
+ # raw scan — then pass through the Step 0-B.1 skip ledger before use
285
+ git log --oneline --since="today" --no-merges --author="$(git config user.name)"
286
+ git status --short # uncommitted changes
287
+ ```
288
+
289
+ ## Step 2-B. Extract Session Summary
290
+
291
+ **From git log only** (no conversation context — prevents hallucination):
292
+
293
+ 1. **Context**: Infer from first commit message
294
+ 2. **Solution**: Aggregate commit messages
295
+ 3. **Commits**: List with hashes
296
+ 4. **Next Session**: Parse TODO/FIXME via `git grep`
297
+ 5. **Key Learnings**: Ask user (optional, 1–2 lines)
298
+ 6. **FH Backport Points**: Auto-detect from "pattern"/"reusable" keywords in commits
299
+
300
+ ## Step 3-B. Generate Session Markdown
301
+
302
+ Template:
303
+
304
+ ```markdown
305
+ # Session YYYY-MM-DD — <Slug>
306
+
307
+ ## Context
308
+ <Initial problem inferred from first commit>
309
+
310
+ ## Solution
311
+ <What was implemented — aggregated from commits>
312
+
313
+ ## Commits
314
+ 1. `<hash>` — <message>
315
+
316
+ ## Next Session
317
+ <Parsed from TODO/FIXME, or user-supplied>
318
+
319
+ ## Key Learnings
320
+ <Patterns discovered — user-supplied or inferred>
321
+
322
+ ## FH Backport Points (Optional)
323
+ <If patterns worth meta-skill/rule promotion>
324
+
325
+ ---
326
+ **Tags**: #<project> #<topic>
327
+ ```
328
+
329
+ Filename: `session_YYYY_MM_DD_<slug>.md`
330
+
331
+ ## Step 4-B. Write + Commit to Hub
332
+
333
+ ```bash
334
+ cd <hub-path>
335
+ # Write session file
336
+ git add tracks/<track>/session_$(date +%Y_%m_%d)_<slug>.md
337
+ git commit -m "session: <title> (<project> <date>)
338
+
339
+ Co-Authored-By: Claude <noreply@anthropic.com>"
340
+ ```
341
+
342
+ > **Push policy**: commit only. Push requires explicit user approval ("push해줘", "push it"). Do not auto-push — consistent with FH PR principle.
343
+
344
+ ## Step 5-B. Confirmation
345
+
346
+ ```
347
+ ✅ Session logged to knowledge hub
348
+ 📝 tracks/<track>/session_YYYY_MM_DD_<slug>.md
349
+ 🔀 Commit: <hash> — push? (y/n)
350
+ ```
351
+
352
+ ---
353
+
354
+ ## Done When
355
+
356
+ **Mode A (Pattern Harvest)**:
357
+ ```
358
+ All stages Step 0~4 complete
359
+ + Step 3 harvest candidate list output (N candidates + M field-only)
360
+ + Upon user approval, Step 4 PR creation complete (gh pr create executed)
361
+ + When 0 candidates, "no absorption candidates" reported then exit
362
+ ```
363
+
364
+ **Mode B (Session Log)**:
365
+ ```
366
+ All Steps 0-B ~ 5-B executed
367
+ + Step 0-B.1 detection-skip ledger applied (already-logged commits filtered)
368
+ + Session markdown file generated from git log (or "all commits already logged" exit)
369
+ + Hub commit created (no auto-push)
370
+ + Confirmation output with push offer
371
+ ```
372
+
373
+ Verdict: PASS (harvest candidates output and PR created, or 0 candidates confirmed) | CONDITIONAL_PASS (candidates found but PR pending user approval; or Mode B commit created, push pending) | FAIL (contention-layer blocked candidate registration; or hub path not found) | ESCALATE (role collision with existing skill requires human decision)
374
+
375
+ **→ Mandatory next: `contention-layer`** — run immediately after Step 3 candidate list is confirmed, before Step 4 PR creation. New patterns must be checked for collision with existing skill role clusters before registration. Skip only when 0 candidates found.
376
+
377
+ ## Linked Skills
378
+
379
+ | Situation | Linked skill |
380
+ |---|---|
381
+ | Auto-pipeline on session wrap | `harvest-loop` — calls field-harvest internally as Step H1 |
382
+ | devil attack/innovator synthesis on harvest candidates | `harvest-loop` Steps H3~H3.5 |
383
+ | Need PR directly after standalone pattern extraction | This skill Step 4 direct execution |
384
+ | Session log to hub | This skill Mode B (standalone) |