Fix SAM CLI contract drift#1173
Conversation
fadbad3 to
ac074eb
Compare
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix TestStatusJSONOutputUsesCurrentContracts to assert the inner sessions array via assertArrayField, not just check the outer object type - Remove unreachable int, int64, json.Number branches from FormatAnyTimestamp (encoding/json always decodes JSON numbers as float64 into any) - Use url.Values.Encode() for query params in ListLibraryFiles instead of raw string concatenation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Review Fixes AppliedAddressed findings from go-specialist code review: [HIGH] Test assertion bug fixed — [MEDIUM] Query param construction — [MEDIUM] Dead code removed — Commit: |



Summary
sam chat <sessionId>to use the session detail route, adds explicit library root-only/recursive behavior, sanitizes table cells, and improves invalid JSON errors with safe route/status/decode context.sam library --recursive.Validation
pnpm lintpnpm typecheckpnpm testpnpm buildgo test ./...inpackages/cligo test -race -coverprofile=coverage.out -covermode=atomic ./...inpackages/cligo tool cover -func=coverage.outinspected: total 80.9%,internal/cli81.1%Staging Verification (REQUIRED for all code changes — merge-blocking)
Deploy Stagingworkflow run26765014939passed for this branch at commitfadbad3226765014939Staging Verification Evidence
Deploy Staging run
26765014939completed successfully forsam/title-fix-sam-cli-01kt1v. The run included successfulBuild CLI,Upload CLI Binaries,Health Check, and smoke-test jobs.UI Compliance Checklist (Required for UI changes)
End-to-End Verification (Required for multi-component changes)
Data Flow Trace
packages/cli/internal/cli/run.gopackages/cli/internal/cli/commands.gopackages/cli/internal/cli/client.gopackages/cli/internal/cli/types.gopackages/cli/internal/cli/table.gopackages/cli/internal/cli/commands_test.go,client_test.go,run_test.go,table_test.goUntested Gaps
No live authenticated CLI smoke was run against staging because the staging workflow does not expose an authenticated CLI session for this task. Changed behavior is covered by command-boundary tests using current API response shapes and by staging CLI binary build/upload.
Post-Mortem (Required for bug fix PRs)
What broke
The CLI had drifted from current API response shapes, causing several commands to fail with
INVALID_JSONor produce incomplete/misleading table output.Root cause
CLI response structs and command renderers remained coupled to older API shapes while the API routes and shared types evolved.
Class of bug
Client/server contract drift with insufficient command-boundary coverage for current response shapes.
Why it wasn't caught
Existing CLI tests covered many command boundaries but used stale fake response shapes for several commands.
Process fix included in this PR
Added/updated CLI command-boundary tests for the affected text and JSON outputs, plus decode redaction and table-rendering tests.
Specialist Review Evidence (Required for agent-authored PRs)
Agent Preflight (Required)
Classification
External References
N/A: Internal contract alignment between CLI and API. Current contracts verified against local API routes and shared type definitions in
packages/shared/.Codebase Impact Analysis
Affected components:
packages/cli/internal/cli(commands, client, types, table, run). No API, web UI, or infrastructure runtime code changed. CLI binary build verified on staging.Documentation & Specs
CLI help text updated for
sam library --recursive. No other documentation changes needed as the CLI docs were consolidated into the public docs site.Constitution & Risk Check
Checked Principle XI: no new hardcoded URLs, secrets, timeouts, or environment identifiers introduced. Error output redaction verified to not expose credentials.