Skip to content

feat: cancellable, authorized reports - #225

Merged
moshloop merged 1 commit into
mainfrom
pr/facet-task-context-auth
Oct 27, 2026
Merged

moshloop merged 1 commit into
mainfrom
pr/facet-task-context-auth

Conversation

@moshloop

@moshloop moshloop commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

What

  • Add cancellation support for report tasks
  • Add authorization for report tasks
  • Update entity, formatter, and task packages, with accompanying tests

Notes

  • Single commit, so the changes are reviewed together

Summary by CodeRabbit

  • New Features
    • Run listings, details, controls, and live updates now respect configured visibility rules. Unauthorized runs are hidden or return 404.
    • Custom registered formats can be used with output sinks, and formatters can respond to request cancellation.
  • Bug Fixes
    • Binary output is written without an added trailing newline.
    • Formatter errors and results now retain command context, supporting context-aware rendering.

@moshloop
moshloop enabled auto-merge (rebase) October 27, 2026 09:22
@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Caution

Review failed

The pull request is closed.

Walkthrough

Command and formatter contexts now flow through result rendering, and binary formats avoid added trailing newlines. Task run listings, snapshots, controls, stdin writes, and SSE output now apply optional source-based authorization.

Changes

Formatter context and output handling

Layer / File(s) Summary
Formatter options and custom format registration
formatters/options.go, formatters/format_spec_ginkgo_test.go
FormatOptions now carries a context that is excluded from serialization, and option merging preserves non-nil contexts. Format parsing accepts registered custom formatter names.
Context propagation to formatters
entity/command.go, entity/entity_cli.go, entity/primary_action.go, entity/render.go, entity_aliases.go, formatters/manager_context.go, formatters/manager_options_test.go, format_sinks_ginkgo_test.go, entity/*_spec_test.go
Generated commands pass their context to result and error rendering. The rendering callback passes that context through format options, and formatter calls populate options with the supplied context when applicable.
Binary format output
format.go, formatters/manager_context.go, format_sinks_ginkgo_test.go
Binary format detection is exported and used for no-color handling and newline decisions. Tests check that binary output bytes are unchanged.

Task run visibility authorization

Layer / File(s) Summary
Authorization contract and checks
task/source.go
The optional RunAuthorizer interface and helpers filter runs and snapshots. Run authorization checks local snapshots first and queries the source when no local snapshots exist.
Authorized API and SSE paths
task/api.go, task/sse.go, task/authorization_ginkgo_test.go
Run listings, detail requests, controls, stdin writes, and SSE output apply visibility checks. Tests verify that unauthorized runs are omitted or return 404, and that denied stop requests leave the run running.

Sequence Diagram(s)

sequenceDiagram
  participant TaskAPI
  participant authorizedRun
  participant RunSource
  participant RunAuthorizer
  TaskAPI->>authorizedRun: Check run visibility
  authorizedRun->>RunSource: Query when local snapshots are absent
  RunSource-->>authorizedRun: Return snapshots or an error
  authorizedRun->>RunAuthorizer: Check snapshot ownership
  RunAuthorizer-->>authorizedRun: Return authorization decision
  authorizedRun-->>TaskAPI: Return visible or denied
Loading

Possibly related PRs

  • flanksource/clicky#223: Adds custom formatter registration and content types, which this change uses when parsing custom formats and identifying binary output.

Suggested reviewers: flanksource

Priority: Not assessed

Change: Feature

Merge Risk: Moderate · up to def1b

The new run authorization has two gaps that could let a caller control or view runs the authorizer denied. Triggering them needs a group name that collides with another run's ID, or external snapshots with no group ID. Fix both before relying on this for access control.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
✨ Simplify code
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

Gavel summary

Source Pass Fail Skip Duration
lint: oxlint 0 1 0 148ms
lint: tsc 2 1 0 3.8s
lint: betterleaks 0 0 1 -
lint: golangci-lint 1 0 0 1m56s
lint: react-doctor 1 0 0 4.9s

Totals: 4 passed · 2 failed · 1 skipped · 2m5s

Failing linters

tsc — error

tsc wrapper failed: exit status 1
Stderr:
gavel-tsc: cannot load 'typescript' from /home/runner/work/clicky/clicky/task/ui/node_modules. Install it with your package manager (e.g. `npm i -D typescript`).

oxlint — 3 violation(s)

  • /home/runner/work/clicky/clicky/examples/enitity/webapp/src/LinkExamplesPage.tsx:217 — Empty fallbacks in spreads are unnecessary (oxlint)
  • /home/runner/work/clicky/clicky/examples/enitity/webapp/src/api.ts:53 — Empty fallbacks in spreads are unnecessary (oxlint)
  • /home/runner/work/clicky/clicky/examples/enitity/webapp/src/api.ts:133 — Empty fallbacks in spreads are unnecessary (oxlint)

View full results

@github-actions

Copy link
Copy Markdown
Contributor

Gavel summary

Source Pass Fail Skip Duration
aichat 24 0 0 2ms
api 326 0 0 17ms
cache 28 0 0 140ms
celfilter 14 0 9 17ms
clicky 128 0 0 1m25s
clirender 18 0 0 3ms
enitity 1 0 0 6.1s
entity 171 0 0 153ms
entitydemo 2 0 0 1ms
excel 12 0 0 61ms
exec 144 0 1 11.3s
extensions 1 0 0 131.166µs
filter 10 0 3 594.965µs
flags 40 0 0 1ms
formatters 81 0 0 7ms
github.com/flanksource/clicky 28 0 0 3.1s
github.com/flanksource/clicky/api 258 0 0 220ms
github.com/flanksource/clicky/api/tailwind 434 0 0 30ms
github.com/flanksource/clicky/api/wasmtest 1 0 0 180ms
github.com/flanksource/clicky/cmd/clicky 4 0 0 10ms
github.com/flanksource/clicky/docs 19 0 0 -
github.com/flanksource/clicky/entity 153 0 0 10ms
github.com/flanksource/clicky/examples/enitity/internal/entitydemo 7 0 0 -
github.com/flanksource/clicky/exec 3 0 0 410ms
github.com/flanksource/clicky/flags 53 0 0 20ms
github.com/flanksource/clicky/formatters 77 0 1 20ms
github.com/flanksource/clicky/formatters/http 38 0 0 -
github.com/flanksource/clicky/formatters/tests 201 0 1 20ms
github.com/flanksource/clicky/internal/gumchoose 2 0 0 -
github.com/flanksource/clicky/lint 13 0 0 -
github.com/flanksource/clicky/markdown 10 0 0 50ms
github.com/flanksource/clicky/mcp 102 0 0 3.1s
github.com/flanksource/clicky/middleware 31 0 0 -
github.com/flanksource/clicky/prompt 15 0 0 -
github.com/flanksource/clicky/route 12 0 0 -
github.com/flanksource/clicky/rpc 378 0 1 140ms
github.com/flanksource/clicky/rpc/http 8 0 0 10ms
github.com/flanksource/clicky/task 168 0 0 22.4s
github.com/flanksource/clicky/valkey 1 0 0 340ms
gomplatefilter 2 0 0 9ms
http 5 0 0 393.586µs
lint 16 0 0 17.3s
markdown 4 0 0 47ms
mcp 4 0 0 3ms
metrics 7 0 0 1ms
middleware 38 0 0 2ms
process 44 0 0 1.7s
rpc 53 0 0 1.9s
schemaform 61 0 0 1.8s
sse 74 0 0 1.8s
task 97 0 0 6.5s
tests 11 0 47 3ms
text 78 0 0 304ms
urlfetch 4 0 0 1ms
valkey 46 0 0 331ms

Totals: 3560 passed · 0 failed · 63 skipped · 2m44s

View full results

@moshloop
moshloop merged commit b47222a into main Oct 27, 2026
14 of 16 checks passed
@moshloop
moshloop deleted the pr/facet-task-context-auth branch October 27, 2026 09:29
@flankbot

Copy link
Copy Markdown

🎉 This PR is included in version 1.21.85

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants