fix(cli): curate channel escalate-rule-list with compact default projection - #174
Merged
Conversation
…ection The generated escalate-rule-list command marshaled the full nested EscalateRuleItem record (layers, time_filters, template, ...) for every rule in json/toon mode, so a channel with a few dozen rules produced an output far too large to read or pipe usefully. Shadow the generated twin with a curated command (same path, same positional/--channel-id/--data request surface): structured mode now projects each rule to rule_id,rule_name,status,priority,filters by default with a stderr note, overridable via --fields through the existing fieldproject helpers and bounded to the 16 KiB list budget; table mode renders explicit ID/NAME/STATUS/PRIORITY/UPDATED columns. Regenerate the escalation.md card fence (skilldoc check passes).
Conflict in internal/cli/fieldproject_test.go: both sides appended test functions after TestBoundProjectedListErrorNamesLargestFields (this branch: the escalate-rule-list projection suite; main: the identifier-exemption suite). Kept both blocks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Defect
channel escalate-rule-listwas still a raw generated command (internal/cli/zz_generated_channels.go): in json/toon mode it marshaled the full nestedEscalateRuleItemrecord for every rule —layerswith their notify targets,time_filters,template_id, etc. A channel with a few dozen rules produced a structured dump of tens of thousands of characters — far over any sane budget for piping intojqor reading directly — forcing callers to re-fetch with client-side filtering to get at the fields they actually wanted.Root cause
No projection layer: the generated command passes the SDK response straight to
printGenericResult, which marshals every field of every row. This is the same class of defect already fixed forincident list(seeinternal/cli/fieldproject.go).Fix
Curate the command exactly on the incident-list pattern — the hand-written leaf in
internal/cli/channel.goregisters first, sogenAddLeafdrops the generated twin (generated code untouched):escalate-rule-list <channel-id>,requireBodyFieldOrExactArg(channel_id,channel-id), same--channel-id/--dataflags, samegenAssembleBody+genFoldPositional+genBindBodyassembly intoflashduty.ChannelScopedListRequest.rule_id,rule_name,status,priority,filterswith a stderr note (noteDefaultProjection);--fieldsoverrides it (empty value is an error, unknown field names the valid set); output runs throughprojectFields→boundProjectedOutput(proj, compactListOutputLimit)→noteProjectionShortening.--helpdocuments the compact default plus the full response-field block (top-level array).make gen-cardsregenerates theGENERATED:channel[escalate-rule]fence inskills/flashduty/reference/escalation.md(CI's skilldoc check validates it).Intentional break (same as the incident-list curation): structured output changes from
{items:[...full records...]}to a bare top-level array of compact rows. Oldjq '.items[]'consumers fail loudly (jq cannot index an array), and the stderr note + updated--help+ regenerated card point at the new shape. Note:filtersis a nested object thatboundProjectedOutputdoes not truncate (it only shortens top-level strings), so a pathologically large filter set errors with the responsible field named instead of silently corrupting.Verification
make fmt— gofumpt/gci cleango test ./internal/cli/ -run TestChannelEscalateRuleListStructuredProjection -v— all subtests PASS (json default keys + stderr note + absence oflayers/template_id; toon default;--fieldsoverride; empty--fieldserror; unknown-field error; table-mode headers without note;channel_idfolded from positional and--channel-idinto the request body)go test ./...— whole suite green (incl.TestEveryOperationHasPathCommand/TestGeneratorTargetsFullSpec)make gen-cards→ onlyskills/flashduty/reference/escalation.mdmodified;go run ./internal/cmd/skilldoc check→skilldoc: cards OKmake lint— 0 issues;make build— buildsflashduty channel escalate-rule-list 1 2→Error: expects exactly one channel_id(curated leaf owns the path);--helpshows--fields, the compact-default prose, and the TOP-LEVEL array response block