Skip to content

0.2.2: --revert hardening (#8) + command consolidation#10

Merged
betmoar merged 3 commits into
mainfrom
fix/revert-harden-0.2.2
Jul 14, 2026
Merged

0.2.2: --revert hardening (#8) + command consolidation#10
betmoar merged 3 commits into
mainfrom
fix/revert-harden-0.2.2

Conversation

@betmoar

@betmoar betmoar commented Jul 14, 2026

Copy link
Copy Markdown
Owner

This pull request introduces a major update to the model-tuning commands for the cc-agents plugin, consolidating the command surface and improving robustness, especially for reverting model changes. The previous per-agent commands have been unified into a single flexible command, new agent groups are now tunable, and the revert logic is hardened against malformed records. Documentation and tests are updated to reflect these changes.

Command consolidation and new features:

  • Replaced the three per-agent commands (/cc-agents:model, /cc-agents:crawler-model, /cc-agents:implementer-model) with a single switchable /cc-agents:model command. Users can now select the target group with flags (--crawler, --implementer, --scout, --brainstorm, --all), making the interface simpler and more flexible. [1] [2] [3] [4] [5] [6] [7] [8] [9]
  • Added support for tuning the glm-scout and glm-brainstorm agents, as well as an --all flag to retune every agent at once, ensuring all agents with a model: line can be updated in a single operation. [1] [2] [3] [4] [5] [6]

Robustness and revert improvements:

  • Hardened set-model.sh --revert against malformed or partial last-known-good records: now refuses to revert if records are corrupt, skips and warns for files deleted since the snapshot, and reports partial reverts clearly. Prevents silent errors and data loss. [1] [2] [3]

Closes #8

Gate: npm test 86/0 · release-gate v0.2.2 OK · shellcheck clean.

Documentation updates:

  • Updated README.md and command markdown files to document the new unified command, group flags, and improved revert behavior. Removed obsolete per-agent command docs. [1] [2] [3] [4]

Testing:

  • Added 10 new tests: 5 for revert hardening and 5 for the new groups and consolidated command. All tests pass and shell scripts are linted. [1] [2] [3]

Version bump:

  • Bumped version to 0.2.2 in package.json and .claude-plugin/plugin.json. [1] [2] [3]

These changes make the model-tuning workflow more intuitive, safer, and easier to maintain.

betmoar added 3 commits July 14, 2026 12:58
)

Bucket each lastgood record by SHAPE, not just "line non-empty", so a
corrupt-but-non-empty snapshot is refused instead of silently treated as
"every file deleted" and reported as a benign no-op.

- A well-formed record is exactly `<abspath>\t<non-empty-model>`. Records that
  are non-absolute, empty-model, or carry a stray 3rd column (format drift)
  now count as `malformed` and force exit 1 — no partial revert.
- Empty model column no longer writes a blank `model: ` line into an agent.
- `read ... || [ -n "$f$m$extra" ]` keeps a final record that lacks a trailing
  newline, closing a silent-partial-revert (last line dropped) on hand-edited
  or foreign snapshots.
- Success line discloses partial reverts: "reverted N of M ... (K skipped)".

Preserves bash 3.2 constraints (integer counters / ${#arr[@]} over ${arr[*]+x};
guarded empty-array expansions under set -u).

Gate: npm test 80/0 (was 75; +5 hardening drift-locks) · shellcheck clean.
One command retunes any agent group via a type flag instead of three
near-identical wrappers. BREAKING: /cc-agents:crawler-model and
/cc-agents:implementer-model are removed — use /cc-agents:model --crawler
| --implementer.

- set-model.sh: add --scout, --brainstorm, --all groups. Every agent with a
  model: line is now tunable (glm-scout, glm-brainstorm were not); --all
  rewrites all six transactionally (verified live: --all then --revert
  round-trips all files, crawler back to glm-5-turbo).
- commands/model.md: forwards $ARGUMENTS verbatim, documents every group flag;
  crawler-model.md + implementer-model.md deleted.
- Tests: +scout/brainstorm/all coverage; command drift-locks rewritten for the
  single-command surface; the CHANGELOG version drift-lock now tracks the newest
  heading instead of a hardcoded string (stops going stale each release).
- README command section collapsed to one flag table; notes get-model is
  pending cc-proxy /v1/models.

Version 0.2.1 -> 0.2.2. Gate: npm test 86/0 · release-gate v0.2.2 OK ·
shellcheck clean.
PR review of the 0.2.2 branch surfaced two verified HIGH silent-failures in
the arg/revert paths the diff already touches. Fixed with tests.

- --revert now charset-validates the recorded model value with the same guard
  as the forward path. A lastgood record with a literal `\n` in the model
  column (`<abspath>\tglm-x\ntools: Bash`) was fed to fm_rewrite's `awk -v`,
  which interprets the escape and injected `tools: Bash` into a least-privilege
  agent (exit 0, silent). A bad value now buckets as malformed → whole snapshot
  refused (exit 1). Live-verified: injection blocked, no tools: line written.
- Stray positional args rejected (exit 2) instead of silently mis-targeting:
  `set-model.sh scout glm-4.6` (missing --) used to be swallowed as the id and
  retune the REVIEWERS, not scout; a second positional last-won silently. Both
  now error, and a bareword group name suggests the --form.
- ALL derived from the group arrays (was a hand-maintained literal that a new
  group could silently escape); locked by a structure test.
- Tests: +injection (backslash-n + quote), +positional (typo/double/unknown-
  flag), +--all/--revert round-trip over DISTINCT per-file models (the only
  case a cross-file revert mixup surfaces). CHANGELOG: removals under Removed.

Charset pattern is `*[!]A-Za-z0-9._:/[-]*` (leading `]` = literal, matching the
forward path) so the bracketed default id glm-5.2[1m] stays valid.

Gate: npm test 93/0 (was 86) · release-gate v0.2.2 OK · shellcheck clean.
@betmoar
betmoar merged commit fd4bc68 into main Jul 14, 2026
1 check passed
@betmoar
betmoar deleted the fix/revert-harden-0.2.2 branch July 14, 2026 12:07
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.

Harden set-model.sh --revert against malformed / partial last-known-good records

1 participant