Let applications ask whether a caller may act on a step (tm.MayAct), then move file references into core
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- go
- Lĩnh vực
- backend-api-design
Hướng nghiên cứu
Start with CompleteTaskStep and checkRequiredPreResume to understand the existing write guard, then inspect how PRE_RESUME extensions are declared and executed. The first deliverable is tm.MayAct with an optional Authorizer interface and coverage for guarded steps and extensions that do or do not implement it; done means callers can check whether a command is allowed without side effects. The file reference migration is explicitly later and spans core and application interfaces.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Current Limitation
Core enforces who may complete or draft a step, but it gives an application no way to ask that same question without making the write. So an application that needs the answer while it renders a task works it out itself, from config core owns.
nsw-srilanka is the case today. GET /api/v1/tasks/{id} gives a reader file references with submit only when the reader may act on the active step. To decide that, it:
- loads the active step template and finds its
PRE_RESUMEauthzentry itself (stepCanActininternal/bootstrap/app.go,MayActOnStepininternal/tasks/extensions/authz); - evaluates that entry's rules itself, asking "may this reader run any command in this state?" rather than whether a given command would pass;
- repeats core's rule for whether a step is guarded. Core's
declaresExtension/checkRequiredPreResumerefuse a step with noauthz, and OpenNSW/nsw-srilanka#848 adds a separatedeclaredflag inMayActOnStepso that reads agree with it.
Problems with this:
- The guard is defined twice. If core changes what counts as guarded (which phase, which ids, what
WithRequiredPreResumeExtensionsis given), the write path follows and the read path doesn't. Readers would then be offered actions that are refused, or the other way round, with nothing failing. - The read reaches into write-side config. The application reads the
PRE_RESUMEentry of a step template and runs the rules itself, instead of asking the code that enforces them. - It is tied to one extension. The answer is "what the
authzrules say", not "what core would allow", so it breaks if write authorization ever moves to another or a second extension.
File references themselves (the reference format, their read/submit scopes, binding them on read and on submit/draft, and the read-only reference sent to an OGA on EXTERNAL_REVIEW) live in nsw-srilanka too (internal/storage/fileaccess, internal/tasks/file_binding.go). Yet what they protect is declared generically in the artifacts: a render config's files paths, and the rule that a submission must hand back a reference issued to the submitter with submit. Nothing about it is specific to one deployment.
Suggested Improvement
1. A dry-run authorization check on the task manager (do this first; it is small and useful on its own).
-
An optional interface a
PRE_RESUMEextension can implement besideExecute, which checks the caller without side effects:// Authorizer is a PRE_RESUME extension that can say, without side effects, // whether the caller in ctx may run command on the step. type Authorizer interface { Authorize(ctx context.Context, record store.TaskRecord, command string, properties json.RawMessage) error } -
tm.MayAct(ctx, taskID, stepID, command) error, which:- loads the active step template, as
CompleteTaskStepdoes; - applies
checkRequiredPreResume, the same guard writes use; - calls
Authorizeon each declaredPRE_RESUMEextension that implementsAuthorizer.
Extensions that only check the payload (e.g. a payload-schema check) don't implement it and are skipped, since a dry run has no payload.
- loads the active step template, as
-
The caller's identity stays in
ctx, as it is forExecute, so core stays identity-agnostic. -
The view's real question is "can they run some command?". Either add a
MayActAny, or let the caller pass the commands its render state offers. The second is more precise: it's exactly the buttons the user would see.
With this, nsw-srilanka's stepCanAct and MayActOnStep become a call to tm.MayAct, and the guard has one definition.
2. Move file references into core (later, building on 1).
Core would own:
- the reference format, its scopes and who it was issued to;
- binding on read (
GetTask, usingMayActto decide onsubmit) and on submit/draft; - the outbound reference on an
EXTERNAL_REVIEWdispatch.
The storage backend and the principal stay behind interfaces the application provides.
Version
main
Additional Context
- Came up reviewing OpenNSW/nsw-srilanka#848, which turns on
WithRequiredPreResumeExtensions("authz")(#323) and makes the read path match it. #848 is correct as it stands; this is cleanup to do afterwards, not a blocker. - File reference behaviour today: nsw-srilanka
docs/WORKFLOW_GUIDE.md, "File fields".
- Ngôn ngữ chính
- Go
- Star
- 6
- Fork
- 8
- Merge trung bình
- 21 giờ 36 phút
- Pull request đã merge (30 ngày)
- 42
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của OpenNSW/core
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
payment: test fixtures hardcode real gateway names (govpay/lankapay) instead of generic placeholdersĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
nsw-sl cleanup Type/Improvement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
Maintainer thường phản hồi trong vòng 1 ngày
-
remote: let the host inject a logger, and log with one consistent policyCó thể đã có người làm @mushrafmim đã nhận 5 ngày trước. Đang mởType/Improvement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 22/100
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
agent-research-finding chore
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
jordansmall/spindrift#7370 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
☢️ Bug v3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
The repo's gates check is clean and runs need no swapsCó thể đã có người làm @turbot-agent-fleet đã nhận hôm nay. Đang mởagent:ready
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
turbot/tailpipe#677 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-kind needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 2 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
crossplane-contrib/provider-keycloak#806 ·
Maintainer thường phản hồi trong vòng 1 ngày