Repository navigation
feat(promote): the runbooks you already have but never wrote down - #29
Conversation
…variable already found mem captures everything and replays named groups, but nothing connected the two: a group only exists if you remembered to run `mem save` while busy doing the thing. `mem promote` mines the history instead — sequences recurring across three separate sessions, with the argument that changed between runs already turned into a $VAR. Calibrated on eight hand-designed 45-day histories: 0 false positives in the default five-candidate listing, 88% of planted workflows surfaced. The measurements that set the thresholds are pinned as tests, notably that removing the inspection-command filter takes the false-positive rate to 80%, and that ranking on occurrences alone puts a deploy's own prefix above the deploy. Also fixes a session-splitting defect found on the way: elapsed time was measured from completion timestamps, so a slow `docker build` read as idle time and cut every deploy sequence in half at its slowest step. Refs ADR-012
…is bad ADR-012 records the calibration rather than asserting a rate: eight hand-designed 45-day histories, 0/40 false positives in the default listing, and the three ablations that set the thresholds — the inspection filter (0% -> 80% without it), MIN_OCCURRENCES (mined pool 97 -> 223 at two), and ranking by occurrences x length rather than occurrences (88% -> 80% workflow coverage). The README says out loud that mem will sometimes propose the commit dance. Someone will see it, recognise a poor runbook, and conclude the feature is broken; better they read that we already know why it happens and cannot tell from the outside.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1799c28b86
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if shape[index] == _HOLE: | ||
| return token.start, token.end |
There was a problem hiding this comment.
Preserve quoting around promoted variables
When a varying argument is quoted, this span includes the quote characters, so promotion rewrites examples such as git commit -m "release one" into git commit -m $COMMIT_ARG. mem run executes the template through a shell and supplies the variable through the environment, meaning an unquoted value containing spaces is split into multiple arguments and wildcard characters may expand. Preserve shell-safe quoting when replacing a quoted token so the promoted command retains the original argument semantics.
Useful? React with 👍 / 👎.
| for step in candidate.steps: | ||
| saved, _vars = groups.save_command( |
There was a problem hiding this comment.
Preserve repeated steps when saving a candidate
If a mined workflow legitimately contains the same command more than once, this loop passes each occurrence through groups.save_command, whose group path returns False whenever that command already exists in the group. A sequence such as make test; deploy; make test is therefore confirmed as three commands but stored with only the first make test, silently changing the runbook and causing it to be suggested again because the saved step list no longer matches. Save the candidate as an ordered sequence without applying the bookmark-style duplicate suppression.
Useful? React with 👍 / 👎.
mem has two halves that never spoke to each other. It captures everything you type. It also has groups — runbooks you can parameterise and replay — which are the most original thing in the product and are barely used, because creating one means remembering to run
mem save, and nobody remembers.mem promotereads the sequences you already repeat and offers to save them.Against a fixture of 200 commands — 8 runs of one workflow buried in ad-hoc noise of random length and random order:
One workflow found, the namespace extracted as one variable shared across four commands rather than four, the observed values shown, and nothing else proposed.
The measurement that matters
A suggestion engine that proposes junk is dismissed once and never opened again. So it was calibrated on 8 hand-designed 45-day histories (~1,100 commands each): 5 planted workflows against 6 ad-hoc pools generated as random-length, random-order draws — that is what makes work ad-hoc — plus 35% two-activity sessions specifically to invite bad splicing.
The default limit of 5 is load-bearing, not a display preference, and it is commented as such where someone changing it will read it.
Ablation — removing the inspection-command filter: 80% false positives in the top 5, coverage collapses 88% → 15%. That is the measurement that tells the next reader why the filter exists instead of leaving it looking like an arbitrary heuristic. Pinned as a test.
Ranking is occurrences × length, not occurrences. The obvious choice is worse — 88% → 80% coverage — because every prefix of a six-step deploy recurs more often than the deploy does. Also pinned.
Thresholds, each with its reason
mem fix's strong-evidence number. Two is coincidence-compatible: at two the mined pool goes 97 → 223 and its FP rate 42% → 75%. Repetitions inside one session do not count — a build loop is one episode.SessionTracker, but measured as think time. This was a real defect found on the way: raw timestamps cut every deploy sequence in half at its slowest step, because mem timestamps completion. Third place this has bitten — the shell hooks andmem fixwere the others — so it is now written down in the code."The same sequence" when arguments differ
Commands reduce to a shape where argument positions become holes; a hole with one observed value collapses back to a literal. Never
argv[0], never the token after it, never a flag name — that is what separatesgit checkout main/staging(a branch, one workflow) fromgit push/pull(different intents). Commands containing shell grammar are never generalised.Surviving holes group into variables by value vector, not position, which is why one namespace used across four commands comes out as one variable.
The caveat, kept in the README and not just the ADR
Roughly 1 in 8 suggestions is the
git add -A; git commit -m ...; git pushclass: genuine repetition, poor runbook, and indistinguishable from a real workflow from the outside. Better that someone reads we know than concludes the feature is broken.Nothing is created without confirmation, and nothing is ever executed.
Tests
1450 passed, 91% branch coverage,
promote.pyat 96%, ruff clean. ADR-012.