Repository navigation
Conversation
gstack-learnings-search only collapses exact key+type duplicates, so the same lesson relogged under a different key accumulates. gstack-learnings-refine finds semantic near-duplicates and merges them, keeping the highest-confidence survivor and unioning files[]. Deterministic and file-only (works with gbrain off): blends word-level TF-IDF cosine with character-trigram cosine, so a reworded duplicate that either signal alone would miss is still caught while unrelated pairs stay low. Dry-run by default; --apply is atomic, leaves a .bak, and never rewrites a file with an unparseable line. --review surfaces gray-zone pairs without merging them. Scope mirrors the sibling tools (current slug via gstack-slug, --slug, --all).
Runs the dry-run, presents the auto-mergeable and REVIEW bands, and applies only after AskUserQuestion confirmation. SKILL.md regenerated from the template.
10 tests: near-dup clustering, exact-dup compaction, cross-type gating, --apply (file union, confidence bump, idempotency, parse-error safety), the --review gray-zone band, and --min-entries lazy-on-overflow.
|
Merging to
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 |
…e + /learn refine subcommand (garrytan#2029) Deterministic TF-IDF + char-trigram blend, dry-run by default, atomic --apply with .bak, parse-error rewrite guard, gray-zone --review band never auto-merged. Generated learn/SKILL.md excluded (regenerated by the assembler).
garrytan#2029's rewrite built output only from rows with key+type, so legacy category/summary/detail rows (the ones garrytan#940 makes searchable again) would be silently deleted by the first refine --apply. Legacy rows now pass through the rewrite unchanged, and the timestamp sort tolerates rows with missing/invalid ts. Regression test added. Co-Authored-By: Claude Fable 5 <[email protected]>
|
@tonyjzhou Redesign as schema-lossless, dry-run-first conservative refinement with stable IDs, containment, locking, unique durable atomic writes, recovery, and adversarial chain/concurrency probes. |
|
Thank you for this, @tonyjzhou. It's a reasonable idea, but not one we can take right now: Duplicate learnings are a real annoyance, but this is a new helper and subcommand. It could fold into |
What
gstack-learnings-searchcollapses learnings by exactkey+typeonly, so the samelesson relogged under a different key accumulates forever. This adds
bin/gstack-learnings-refineand a/learn refinesubcommand that find semanticnear-duplicates and merge them, keeping the highest-confidence survivor and unioning
their
fileslists. It is the "grow-and-refine" step the log/search pair never had.How
Deterministic and file-only, so it runs with gbrain off (no embeddings DB, no model,
no network). It blends word-level TF-IDF cosine (precision: rare shared terms carry
the signal) with character-trigram cosine (recall: survives rewording and
sessionsvs
session). Neither signal alone catches a reworded duplicate. The larger of thetwo does.
Safe by default:
--apply.--applywrites atomically, leaves a.bak, and neverrewrites a file that has an unparseable line.
--reviewband surfaces gray-zone pairs in[--review-floor, --sim)for manualinspection and never auto-merges them. Because
--applydeletes a row, the 0.70default bar is tuned for precision and the REVIEW band catches the rest without
deleting on a guess.
gstack-slugby default,--slug SLUG, or--all. Survivor selection uses the same confidence-decay modelas
gstack-learnings-search./learn refine
New subcommand in the learn skill: runs the dry-run, presents the auto-mergeable and
REVIEW bands, and applies only after AskUserQuestion confirmation.
Tests
test/gstack-learnings-refine.test.tsadds 10 tests (mirroring thegstack-learnings-searchharness): near-dup clustering, exact-dup compaction,cross-type gating,
--apply(file union, confidence bump, idempotency, parse-errorsafety), the
--reviewband, and--min-entrieslazy-on-overflow.Every suite this change touches is green: learnings, skill-validation, gen-skill-docs,
and the package.json-to-VERSION sync. The remaining failures in a full local
bun test test/run are pre-existing and environmental (resolve-user-slug sandboxtimeouts, an iOS XCTest-toolchain test, a hook-install test). They fail identically on
main(c7ae632) without this branch.Numbers
On the test fixtures a reworded duplicate scores 0.58 on words alone, under any
threshold safe enough to use, but 0.77 blended once the character-trigram signal lifts
it. Unrelated same-domain pairs stay under 0.20. Reproduce with
bun test test/gstack-learnings-refine.test.tsandgstack-learnings-refine --all --review --debug-scores.VERSION 1.58.1.0 -> 1.59.0.0 (MINOR, new capability), with a CHANGELOG entry.
Note for CI
This is a fork PR, so the eval and E2E jobs will not receive base-repo secrets and
will fail on empty-env auth. The free unit tier (
bun test, skill validation,gen-skill-docs, the new dedup tests) runs without secrets. Happy to have the branch
re-pushed to a base-repo branch if you would rather run the full eval suite.