Skip to content

feat(plan-tune): registry-independent autonomy signal from followed_recommendation (partial #2623) - #2625

Closed
v639dragoon wants to merge 1 commit into
garrytan:mainfrom
v639dragoon:feat/autonomy-recommendation-signal
Closed

v639dragoon wants to merge 1 commit into
garrytan:mainfrom
v639dragoon:feat/autonomy-recommendation-signal

Conversation

@v639dragoon

Copy link
Copy Markdown
Contributor

Partial fix for #2623.

What this does

Adds one registry-independent signal — followed_recommendation → autonomy —
so /plan-tune can read existing history for one of five dimensions.

It does not fix #2623. Gates 1 and 3 there need a design call I did not want
to make on your behalf, and four of five dimensions still sit at 0.5 after this
lands. The title says "signal", not "fix", deliberately.

Why this signal specifically

It is the only one that reads existing history retroactively.
gstack-question-log already computes followed_recommendation at write time
from (user_choice, recommended), so it is present on ~95% of rows today and
needs no registry entry, no <gstack-qid:> marker and no skill change.

Measured on a real 1,286-row log: autonomy 0.5 → 0.797 (1,187 of 1,240
eligible rows followed, 95.7%). Other dimensions unchanged.

Three design points worth reviewing

1. The contribution is O(1), not a per-event delta. normalizeToDimensionValue
is a sigmoid over an accumulated total, so a per-event delta at this file's
usual ±0.03..0.06 reaches 0.9994 by 50 events and 1.0 by 100 — as uninformative
as the 0.5 it replaces. This computes one bounded delta from the whole history:

smoothed   = (followed + 1) / (n + 2)          # Laplace
confidence = min(1, n / 20)                    # n = ELIGIBLE rows
delta      = 0.5 * confidence * (2*smoothed - 1)

2. The ramp is keyed on the eligible count, not sample_size. My first draft
dropped the ramp, reasoning that the documented 20-event calibration gate already
handles thin evidence. It does not: sample_size counts every logged row
(bin/gstack-developer-profile:351), so 3 eligible rows beside 1,200 unrelated
ones passes that gate and would render a confident score from three answers.

3. W = 0.5 is an unvalidated starting constant, and I have said so in the
code.
It was picked on one user's data because it lands near their declared
value, which is post-hoc. It is also confounded: a high follow rate may measure
how good the agent's recommendations are as much as how much the user delegates.
The comment frames it the way this file's header already frames v1 deltas —
"best-guess starting points". Happy to re-pick it on broader data.

Eligibility fails closed

question-log.jsonl is hand-editable JSONL, so every clause rejects rather than
coerces: strict boolean (the string "false" is truthy and would silently count
as a follow), source present and not auto-decided (the preference hook
auto-picks the recommendation, which would feed the dimension that licenses
auto-deciding straight back into itself), and precedence over the registry
autonomy path so one decision is never counted twice.

Also included: derivation provenance

inferred now carries per-dimension contributing_events (unique rows) and
derivation_version. normalizeToDimensionValue(0) is exactly 0.5, so today a
dead dimension and a perfectly balanced one print the same number — which is how
#2623 hid for two months behind sample_size: 1286. With this, --derive on an
unpatched log shows contributing_events: 0 across the board, which makes that
issue reproducible in one command.

Both fields are additive and sit beside diversity in the existing shape.

Known limitation, pinned rather than fixed

The per-event registry path can still swamp this signal, because it accumulates
unbounded. With 200 mapped decision-autonomy events one way and 60 rate rows
the other, the derived value is 1.0 where the rate evidence alone reads
0.190 — not diluted, erased, and the conclusion flips.

I did not fix that here: bounding per-event accumulation re-prices every delta in
psychographic-signals.ts and deserves its own change. Instead there is a test
named KNOWN LIMITATION: the per-event registry path still swamps the rate signal that pins the current behaviour, so whoever fixes it gets a red test and
re-baselines deliberately. Detail in #2623.

Tests

test/plan-tune.test.ts gets the math (in-process, beside the existing
psychographic signal map block); test/gstack-developer-profile.test.ts gets
the wiring. 117 pass across the two files.

Every new assertion is mutation-verified — 11 mutations, each reds its named
test: per-event accumulation, ramp keyed on total rows, smoothing removed,
truthiness instead of strict boolean, missing-source allowed, precedence dropped,
aggregate not applied, provenance write deleted, applications counted instead of
unique rows, and two that strip the trace aggregate.

One of those mutations caught a weak test of mine: the UNIQUE ROWS case
originally used a rate-only fixture, so the registry contributor count was 0 and
multiplying it changed nothing. It now uses a question whose signal_key writes
more than one dimension from a single row.

One test-harness change

logQuestion now sets GSTACK_QUESTION_LOG_NO_DERIVE=1. gstack-question-log
fires --derive in the background after every append
(bin/gstack-question-log:242-250), which races the explicit --derive a test
then makes — I saw it as intermittently empty stdout. That env var exists for
exactly this; without it, any test that logs several rows and then derives is
flaky by construction.

Pre-existing failures, not from this change

bun run test:free has 3 failures on this branch, all in
browse/test/path-validation.test.ts and browse/test/data-platform.test.ts.
They reproduce identically on a clean worktree at c86e647 with none of my
changes, and this PR touches no file under browse/. Looks like macOS
/private/tmp symlink resolution.

VERSION is deliberately untouched — version-gate.yml only triggers on that
path, so I have left the bump to you.

…ecommendation

/plan-tune's inferred psychographic never leaves its 0.5 seed. On a real
1,286-row question-log with all four calibration gates passing, --derive
applied zero signal deltas and --trace reported "no events contribute" for
every dimension.

Cause (filed separately): SIGNAL_MAP attribution needs three exact-string
matches to land -- question_id in QUESTIONS, that entry carrying a signal_key,
and user_choice matching a key in SIGNAL_MAP[signal_key]. The third matched
0 of 1,286 rows: the capture hook records the UI LABEL while SIGNAL_MAP is
keyed by stable option keys, and AskUserQuestion has no slot for a key. So
growing the registry alone cannot fix it.

followed_recommendation is different. gstack-question-log already computes it
at write time from (user_choice, recommended), so it is present on ~95% of
existing rows and needs no registry entry, no marker and no skill change. It
is the only signal that can read existing history retroactively.

  scripts/psychographic-signals.ts
    recommendationSignal(): ONE bounded autonomy delta from the whole log.
    Laplace-smoothed rate, then a confidence ramp keyed on the ELIGIBLE count
    -- deliberately not sample_size, which counts every logged row, so 3
    eligible rows beside 1,200 unrelated ones would otherwise render a
    confident score from three answers.

    Eligibility fails closed on hand-edited JSONL: strict boolean (the string
    "false" is truthy), source present and not 'auto-decided' (the preference
    hook auto-picks the recommendation, which would feed the dimension that
    licenses auto-deciding back into itself), and precedence over the registry
    autonomy path so one decision is never counted twice.

  bin/gstack-developer-profile
    derive applies the aggregate; trace reports it, so --trace autonomy no
    longer says "no events contribute" while --profile shows a moved number.
    Both call the same exported function rather than re-implementing the rule
    in two separate bun -e blocks.

    inferred now records per-dimension contributing_events (UNIQUE ROWS) and
    derivation_version. normalizeToDimensionValue(0) is exactly 0.5, so
    without this a dead pipeline and balanced evidence print the same number
    -- which is how five 0.5s sat beside sample_size 1286 looking healthy.

Why the contribution is O(1) and not a per-event delta: the sigmoid runs over
an ACCUMULATED total, so a per-event delta at this file's usual +/-0.03..0.06
reaches 0.9994 by 50 events -- as uninformative as the 0.5 it replaced.

Measured on the 1,286-row log: autonomy 0.5 -> 0.797 (1,187/1,240 eligible
rows followed, 95.7%), other dimensions unchanged.

Known limitation, pinned by a test rather than fixed here: the per-event
registry path can still swamp this signal, because it accumulates unbounded.
With 200 mapped events one way and 60 rate rows the other, the result is 1.0
where the rate evidence alone reads 0.190. Bounding that re-prices every delta
in the signal map and belongs in its own change.

Test harness: logQuestion now sets GSTACK_QUESTION_LOG_NO_DERIVE=1.
gstack-question-log fires --derive in the background after every append, which
races the explicit --derive a test then makes; observed as intermittently
empty stdout.

Co-Authored-By: Claude Opus 5 <[email protected]>
@trunk-io

trunk-io Bot commented Aug 18, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@capy-ai

capy-ai Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Thank you for this, @v639dragoon. It's a reasonable idea, but not one we can take right now: Fix #2623's root cause first (signal keys versus logged UI labels) so all five dimensions move, then decide whether a whole-history autonomy prior is still needed. We're parking it: closing the PR and recording the idea in TODOS.md under its theme, so it isn't lost. When we pick that theme up we'll reference this PR and credit you.

@capy-ai capy-ai Bot closed this Oct 8, 2026
capy-ai Bot added a commit that referenced this pull request Oct 26, 2026
… record contributing_events (GSTA-79) (#3397)

* feat(plan-tune): per-dimension contributing_events in the inferred profile

Port of the provenance part of #2625 by @v639dragoon: --derive records, per
dimension, how many unique log rows moved it, so "no evidence" and
"balanced evidence" no longer both print a bare 0.5. Also ports the test
harness fix: logQuestion sets GSTACK_QUESTION_LOG_NO_DERIVE=1 so the
background derive cannot race the test's own --derive.

The registry-independent autonomy signal from #2625 stays parked, as the
Oct 8 review decided.

Co-authored-by: v639dragoon <[email protected]>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* fix(plan-tune): clamp each session's pull on a dimension to one strong answer; trace shares derive's accumulation (#2623)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* fix(plan-tune): shared accumulation JS as a quoted string, not a heredoc (heredoc pipe-deadlock guard)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* fix: pre-landing review fixes

Own-property signal lookups so a logged choice such as constructor cannot
break every later --derive; --trace replaces control characters in the
fields it prints; tests for the negative clamp, empty session_id, an
unmatched answer and both fixes; docs and CHANGELOG say the bound keys on
the writer session_id.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* fix: pre-landing review fixes (pass 2)

A session_id that is an unsubstituted placeholder such as SESSION_ID
counts as its own session instead of collapsing every agent-logged
answer into one bound; a log line that parses to null is skipped; the
accumulation tolerates a dimension it did not seed; the trace test covers
DEL and C1 controls; docs and CHANGELOG wording match the code.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* fix(plan-tune): bound each UTC day instead of each session_id

The per-session bound trusted whatever session_id a writer logged. The
PostToolUse hook and the agent log different ids for one review, and an
unsubstituted SESSION_ID placeholder either merged every review into one
bound or left each answer unbounded. Bucketing by the UTC day of ts
stops one burst from pinning a dimension without trusting any id;
several reviews on one day count as one. Decision A from GStack Minder.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* fix: pre-landing review fixes (day bound)

Rows without a parseable string ts share one undated bucket instead of
each escaping the bound; a ts without a zone is read as UTC, so the day
does not depend on the machine's zone; days_span counts the same UTC
days; question_id and user_choice must be strings. Tests pin a zone west
of UTC. CHANGELOG says contributing_events is recorded in the profile
JSON and not displayed yet (#3436).

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* fix: pre-landing review fixes (strict ISO ts)

Only an ISO 8601 date or date-time ts counts as dated; Date alone parses
strings such as "junk 1" as real days, which let junk rows escape the
bound and inflate days_span. A zoneless time, T- or space-separated, is
read as UTC. Tests cover array-valued fields, an offset ts in days_span,
the space separator and every undated row reaching the shared bucket.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* docs: narrow the #2623 TODOS entry to its remaining Gate 1 work (#3442)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

---------

Co-authored-by: v639dragoon <[email protected]>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai

capy-ai Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Thank you, @v639dragoon. The contributing_events provenance from this PR and the GSTACK_QUESTION_LOG_NO_DERIVE test-harness fix shipped in #3397 (v1.91.233.0), in their own commit with your Co-authored-by. Each profile dimension now records how many answers moved it, so "no evidence" no longer looks the same as balanced evidence. #3397 also bounds how far one UTC day can move a dimension, and together with #3394's label-to-key mapping that closes #2623. The {skill}-{slug} hinted fallback you raised is tracked, with credit to you, in #3442. The followed_recommendation → autonomy signal stays parked, as the Oct 8 review decided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/plan-tune inferred psychographic never leaves 0.5: SIGNAL_MAP is keyed by stable option keys, the capture hook logs UI labels (0 of 1,286 rows match)

1 participant