feat: add artifact actions#2159
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughAdds built-in DAG actions ChangesArtifact Action Feature
Sequence DiagramsequenceDiagram
participant StepConfig as Step Config
participant Executor as Artifact Executor
participant RunWrite as runWrite
participant RunRead as runRead
participant RunList as runList
participant FS as Filesystem
StepConfig->>Executor: Run(ctx) with command "write|read|list" + config
Executor->>Executor: parse operation from first command
alt operation == write
Executor->>RunWrite: runWrite(config)
RunWrite->>FS: sanitize path, prepare root, create parents, write (atomic if enabled)
RunWrite->>Executor: JSON result (operation,path,bytes,created)
else operation == read
Executor->>RunRead: runRead(config)
RunRead->>FS: resolve path, read bytes (respect max_bytes)
RunRead->>Executor: raw bytes or JSON (content+metadata)
else operation == list
Executor->>RunList: runList(config)
RunList->>FS: walk/list entries (recursive?, pattern), collect metadata
RunList->>Executor: JSON listing (entries,count)
end
Executor->>StepConfig: set exit code and output
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
internal/core/spec/dag.go (1)
890-907:⚠️ Potential issue | 🟠 Major | ⚡ Quick winFail fast when
artifact.*is combined withartifacts.enabled: false.This now auto-detects artifact actions, but an explicit
artifacts.enabled: falsestill wins and the DAG builds successfully. That pushes a contradictory config into runtime, where the executor fails becauseDAG_RUN_ARTIFACTS_DIRis never populated. Please reject that combination during spec build instead of deferring it to execution.Suggested guard
func buildArtifacts(_ BuildContext, d *dag) (*core.ArtifactsConfig, error) { autoEnable := dagReferencesRunArtifactsDir(d) || dagUsesBuiltinArtifactAction(d) + + if autoEnable && d.Artifacts != nil && d.Artifacts.Enabled != nil && !*d.Artifacts.Enabled { + return nil, core.NewValidationError( + "artifacts.enabled", + *d.Artifacts.Enabled, + fmt.Errorf("artifact actions require artifacts.enabled to be true"), + ) + } if d.Artifacts == nil { if autoEnable { return &core.ArtifactsConfig{Enabled: true}, nil🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/core/spec/dag.go` around lines 890 - 907, The buildArtifacts function currently auto-enables artifacts when dagReferencesRunArtifactsDir(d) or dagUsesBuiltinArtifactAction(d) is true but silently accepts an explicit artifacts.enabled: false; update buildArtifacts to detect the conflict and return an error when autoEnable is true AND d.Artifacts != nil AND d.Artifacts.Enabled != nil AND *d.Artifacts.Enabled == false, referencing buildArtifacts, dagReferencesRunArtifactsDir, dagUsesBuiltinArtifactAction and d.Artifacts.Enabled; the error should reject the spec build rather than producing a runtime-misconfigured core.ArtifactsConfig.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/runtime/builtin/artifact/artifact.go`:
- Around line 218-250: The code currently uses os.WriteFile(target.abs, ...)
when e.cfg.Overwrite && !e.cfg.Atomic, which can follow a swapped-in symlink
after the earlier checks; change the write path so overwrite operations never
use os.WriteFile directly: when e.cfg.Overwrite is true, always write via the
atomic path (fileutil.WriteFileAtomic(target.abs, data, mode)) or alternatively
return an error rejecting the unsupported config combination (e.g. check
e.cfg.Overwrite && !e.cfg.Atomic and either call fileutil.WriteFileAtomic or
return fmt.Errorf(...)). Update the logic around ensureWritableTargetInsideRoot,
the overwrite branch, and the final write handling to route overwrite writes
through fileutil.WriteFileAtomic (or fail) instead of using os.WriteFile with
target.abs.
---
Outside diff comments:
In `@internal/core/spec/dag.go`:
- Around line 890-907: The buildArtifacts function currently auto-enables
artifacts when dagReferencesRunArtifactsDir(d) or
dagUsesBuiltinArtifactAction(d) is true but silently accepts an explicit
artifacts.enabled: false; update buildArtifacts to detect the conflict and
return an error when autoEnable is true AND d.Artifacts != nil AND
d.Artifacts.Enabled != nil AND *d.Artifacts.Enabled == false, referencing
buildArtifacts, dagReferencesRunArtifactsDir, dagUsesBuiltinArtifactAction and
d.Artifacts.Enabled; the error should reject the spec build rather than
producing a runtime-misconfigured core.ArtifactsConfig.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 190e3ba9-ab1c-4ed8-88c6-1d34ad24882e
📒 Files selected for processing (15)
internal/agent/system_prompt.gointernal/agent/system_prompt.txtinternal/agent/system_prompt_test.gointernal/cmn/schema/dag.schema.jsoninternal/cmn/schema/dag_schema_test.gointernal/core/spec/dag.gointernal/core/spec/dag_test.gointernal/core/spec/step_test.gointernal/core/spec/step_types.gointernal/core/spec/step_v2.gointernal/core/spec/step_v2_test.gointernal/runtime/builtin/artifact/artifact.gointernal/runtime/builtin/artifact/artifact_test.gointernal/runtime/builtin/artifact/config.gointernal/runtime/builtin/builtin.go
f5565e8 to
d960e37
Compare
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
a8f0c17 to
a8944d1
Compare
a355f8c to
54c6308
Compare
Summary
Add DAG-run artifact actions so workflows can write, read, and list run artifacts without shelling out to
DAG_RUN_ARTIFACTS_DIR.Changes
artifact.write,artifact.read, andartifact.listaction normalization and executor registration.Validation
go test ./internal/agent ./internal/cmn/schema ./internal/core/spec ./internal/runtime/builtin ./internal/runtime/builtin/artifactChecklist
Summary by CodeRabbit
New Features
Behavior
Documentation