Repository navigation
Commit b7c8e91
authored
Fix agent-help hidden-flag leak; make check-surface a real drift gate (#542)
* Fix agent-help hidden-flag leak; make check-surface a real drift gate
The committed .surface snapshot is generated and enforced by the Go
surface package (surface.SnapshotString) via TestSurfaceSnapshot, not by
scripts/check-cli-surface.sh. The two generators diverge: the Go one
walks the command tree (full inherited globals, excludes hidden flags,
no --version leak), while the shell script walks --help --agent (curated
salient globals post-#499, and — the bug here — emits hidden flags).
Rather than churn .surface to the script's shape (which would break
TestSurfaceSnapshot and enshrine the leak), fix the underlying issues:
- emitAgentHelp leaked hidden flags because pflag's VisitAll visits them,
so `basecamp recordings --help --agent` surfaced the MarkHidden'd,
"Not supported" --assignee flag. Skip hidden flags at all three
emission sites to match text --help and the tree walker. Add a
regression test.
- check-surface previously regenerated to /tmp and echoed a line count,
catching nothing. Repoint it at TestSurfaceSnapshot (the authority) so
it actually fails on drift, and add an update-surface target for
regeneration. check-surface-compat / the cli-surface CI job are
unchanged (they diff generated-vs-generated across versions).
- TestSurfaceSnapshot's -update-surface wrote .surface without a trailing
newline; add one so update-surface is idempotent and POSIX-clean.
Closes #539.
* Write .surface on acknowledged removal-only updates
TestSurfaceSnapshot's -update-surface only wrote .surface when there were
additions, so a removal-only change (removed lines acknowledged in
.surface-breaking) left the removed CMD/FLAG lines in .surface — and
consumers that read it as the current surface (check-skill-drift,
check-smoke-coverage) would keep validating removed commands. Write
whenever there are no unacknowledged removals instead.
* Only rewrite .surface when the snapshot actually changed
Refine the -update-surface write condition into a testable predicate,
shouldWriteBaseline: write when update mode is on, there are no
unacknowledged removals, and the baseline bytes differ from the freshly
generated surface. The byte-difference guard keeps removal-only updates
(acknowledged in .surface-breaking) writing while making an unchanged
surface a true no-op. Add a TestShouldWriteBaseline regression test
covering removal-only, addition, no-change, unacknowledged-removal, and
non-update cases.
Also refresh 'make help': describe check-surface as the drift gate and
list the new update-surface target.
* Harden surface drift gate and hidden-flag test from review
- check-surface now fails when the committed .surface differs from the
generated surface even if the only delta is an acknowledged removal
that was never regenerated (baselineNeedsRegen). Previously such a
baseline passed the gate while still feeding stale removed lines to
check-skill-drift and check-smoke-coverage.
- TestAgentHelpOmitsHiddenFlags now asserts Execute() succeeds and checks
both flags and inherited_flags, matching the guarantee that no hidden
flag appears anywhere in agent help.
- check-surface's failure hint is now conditional (TestSurfaceSnapshot
can fail for reasons other than drift).
Add TestBaselineNeedsRegen covering the acknowledged-removal, no-change,
addition, and unacknowledged-removal cases.1 parent 51c3493 commit b7c8e91
4 files changed
Lines changed: 138 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
357 | | - | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
358 | 360 | | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
363 | 364 | | |
364 | 365 | | |
365 | | - | |
366 | | - | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
367 | 374 | | |
368 | 375 | | |
369 | 376 | | |
| |||
542 | 549 | | |
543 | 550 | | |
544 | 551 | | |
545 | | - | |
| 552 | + | |
| 553 | + | |
546 | 554 | | |
547 | 555 | | |
548 | 556 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
532 | 532 | | |
533 | 533 | | |
534 | 534 | | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
535 | 573 | | |
536 | 574 | | |
537 | 575 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
771 | 771 | | |
772 | 772 | | |
773 | 773 | | |
774 | | - | |
| 774 | + | |
| 775 | + | |
775 | 776 | | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
776 | 780 | | |
777 | 781 | | |
778 | 782 | | |
| |||
785 | 789 | | |
786 | 790 | | |
787 | 791 | | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
788 | 795 | | |
789 | 796 | | |
790 | 797 | | |
| |||
796 | 803 | | |
797 | 804 | | |
798 | 805 | | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
799 | 809 | | |
800 | 810 | | |
801 | 811 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| 11 | + | |
| 12 | + | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
15 | 39 | | |
16 | 40 | | |
17 | 41 | | |
18 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
19 | 45 | | |
20 | 46 | | |
21 | 47 | | |
| |||
93 | 119 | | |
94 | 120 | | |
95 | 121 | | |
96 | | - | |
97 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
98 | 130 | | |
99 | 131 | | |
100 | 132 | | |
101 | 133 | | |
102 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
0 commit comments