fix(resolvers): question-log session_id becomes a substitution placeholder + stale-comment sweep

The question-log block bound $_SESSION_ID, a shell variable the
consolidated fence never sets — hook-less hosts logged empty session_id,
breaking /plan-tune per-session grouping. It now uses the same
substitute-from-the-skill-start-echoes contract as the telemetry block.
Also: retired the pre-Phase-2 stop-gate docstring, repointed the
gbrain-local-status cross-reference at the script's inline jq, dropped an
orphaned section comment, documented retro-metrics' suffix-only census.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Garry Tan
2026-08-25 20:50:15 +00:00
co-authored by Claude Fable 5
parent 46d158c5ed
commit 49321ce71f
5 changed files with 12 additions and 10 deletions
+3
View File
@@ -297,6 +297,9 @@ echo "PRS_REFERENCED: $(printf '%s' "$_PRS" | wc -w | tr -d ' ')"
[ -n "$_PRS" ] && echo "PR_REFS: $_PRS" || true
# ── Test health (repo-wide + window) ─────────────────────────────────────────
# Deliberately suffix-only (narrower than is_test's dir-based patterns): the
# repo-wide census counts conventional test FILES; is_test additionally counts
# dir-homed helpers toward test-insertion ratios.
_TF_TOTAL=$(git ls-files 2>/dev/null | grep -cE '(\.test\.|\.spec\.|_test\.|_spec\.)' || true)
case "$_TF_TOTAL" in ''|*[!0-9]*) _TF_TOTAL=0 ;; esac
echo "TEST_FILES_TOTAL: $_TF_TOTAL"
+3 -3
View File
@@ -146,9 +146,9 @@ function gbrainConfigPath(env?: NodeJS.ProcessEnv): string {
* cwd's NEAREST-ANCESTOR project scope only (#2499 made project scope
* visible; the per-project scoping fixes the machine-wide bleed where ONE
* project's remote registration reclassified broken local engines as
* thin-client for EVERY cwd). Ancestor matching mirrors the
* GBRAIN_MCP_ENTRY_JQ resolution in
* scripts/resolvers/preamble/generate-brain-sync-block.ts: cwd == key or
* thin-client for EVERY cwd). Ancestor matching mirrors the inline jq
* resolution in bin/gstack-skill-start (the single bash copy of the #2499
* resolution, moved there in token-reduction Phase 1): cwd == key or
* cwd startswith key + separator, longest matching key that actually
* carries a gbrain entry wins (a nested project WITHOUT gbrain doesn't
* shadow its parent's registration).
-2
View File
@@ -28,8 +28,6 @@ import {
generatePlanModeInfo,
} from './preamble/generate-completion-status';
// One-time onboarding prompts
// Host-specific instructions
import { generateBrainHealthInstruction } from './preamble/generate-brain-health-instruction';
@@ -6,9 +6,10 @@
* daily pull, queue-depth status) now runs inside `bin/gstack-skill-start`
* (invoked by the Preamble fence above) and reports through the same STATUS
* lines it always emitted: the GBrain hint text and the `ARTIFACTS_SYNC:`
* line. What remains here is the prose the model acts on — including the
* one-time privacy stop-gate, which stays inline until the Phase 2
* instruction-emission layer moves it behind its runtime gate.
* line. What remains here is the prose the model acts on. The one-time
* privacy stop-gate moved behind its runtime gate in Phase 2: it now arrives
* as a GSTACK_INSTRUCTION block from gstack-skill-start when consent is
* actually pending; this generator only carries the interpretation prose.
*
* Skill-END sync is no longer a separate fence: `bin/gstack-skill-end`
* (invoked by the Telemetry step) drains the queue before logging.
+2 -2
View File
@@ -33,9 +33,9 @@ Before each AskUserQuestion, choose \`question_id\` from \`${registry}\` or \`{s
**Embed the option recommendation via the \`(recommended)\` label suffix** on exactly one option per AUQ. The PreToolUse hook parses \`(recommended)\` first, falls back to "Recommendation: X" prose, and refuses to auto-decide if ambiguous. Two \`(recommended)\` labels = refuse.
After answer, log best-effort (PostToolUse hook also captures deterministically when installed; dedup on (source, tool_use_id) handles double-writes):
After answer, log best-effort (PostToolUse hook also captures deterministically when installed; dedup on (source, tool_use_id) handles double-writes). Substitute \`SESSION_ID\` with the value the preamble's skill-start output echoed — shell variables do not survive between Bash calls:
\`\`\`bash
${bin}/gstack-question-log '{"skill":"${ctx.skillName}","question_id":"<id>","question_summary":"<short>","category":"<approval|clarification|routing|cherry-pick|feedback-loop>","door_type":"<one-way|two-way>","options_count":N,"user_choice":"<key>","recommended":"<key>","session_id":"'"$_SESSION_ID"'"}' 2>/dev/null || true
${bin}/gstack-question-log '{"skill":"${ctx.skillName}","question_id":"<id>","question_summary":"<short>","category":"<approval|clarification|routing|cherry-pick|feedback-loop>","door_type":"<one-way|two-way>","options_count":N,"user_choice":"<key>","recommended":"<key>","session_id":"SESSION_ID"}' 2>/dev/null || true
\`\`\`
For two-way questions, offer: "Tune this question? Reply \`tune: never-ask\`, \`tune: always-ask\`, or free-form."