Add agent artifact attestation
This commit is contained in:
@@ -2,4 +2,23 @@ package artifact
|
||||
|
||||
import "git.cin.su/m/Assistant/platform/ids"
|
||||
|
||||
import "errors"
|
||||
|
||||
type ArtifactID ids.ID
|
||||
|
||||
type AgentArtifactAttestation struct {
|
||||
ArtifactID ArtifactID
|
||||
ProducerRunID string
|
||||
SourceRevision string
|
||||
WorktreeID string
|
||||
ContentDigest string
|
||||
TestEvidenceRef string
|
||||
CreatedAtUnixMillis int64
|
||||
}
|
||||
|
||||
func (a AgentArtifactAttestation) Validate() error {
|
||||
if a.ArtifactID == "" || a.ProducerRunID == "" || a.SourceRevision == "" || a.WorktreeID == "" || a.ContentDigest == "" || a.TestEvidenceRef == "" || a.CreatedAtUnixMillis < 1 {
|
||||
return errors.New("agent artifact attestation is incomplete")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"task_file": "dev/tasks/DEV-000117-agent-callback-envelope.json",
|
||||
"task_id": "DEV-000117",
|
||||
"task_file": "dev/tasks/DEV-000118-agent-artifact-attestation.json",
|
||||
"task_id": "DEV-000118",
|
||||
"task_revision": 1
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"task_id": "DEV-000118",
|
||||
"task_revision": 1,
|
||||
"architecture_revision": "ADR-0018",
|
||||
"base_repo_revision": "a6eb4ab",
|
||||
"risk_tier": "E",
|
||||
"intent": "Add typed artifact attestation for agent-produced evidence with digest, source/worktree, producer run and test provenance.",
|
||||
"requirement_ids": ["WP-301", "Artifact attestation", "Independent evidence refs"],
|
||||
"allowed_change_scope": {"modules": ["artifact-agent-evidence"], "paths": ["contracts/artifact/**", "tests/agent_execution/**", "dev/ACTIVE_TASK.json", "dev/tasks/DEV-000118-agent-artifact-attestation.json"]},
|
||||
"forbidden_change_scope": {"paths": ["architecture/**", "database/**", "migrations/**", "deploy/**", "security/**", "cmd/**", "runtime/**", "adapters/**", ".gitea/**"]},
|
||||
"allowed_architecture_delta": {"new_cross_module_dependencies": 0, "new_canonical_owners": 0, "new_privileges": 0, "new_third_party_dependencies": 0, "new_database_owner_roles": 0},
|
||||
"contracts": {"consume": ["ADR-0017 Artifact ownership", "ADR-0020 agent evidence attestation", "Existing AgentRun identity"], "may_change": ["Artifact agent attestation contract"]},
|
||||
"semantic_owner": "artifact-agent-evidence",
|
||||
"canonical_state": [],
|
||||
"state_transitions": ["agent output -> attested artifact evidence", "missing provenance -> non-attested result"],
|
||||
"side_effects_and_privileges": ["Pure validation; no filesystem access, merge, deployment, credential access or external mutation"],
|
||||
"persistence_and_migrations": ["No schema or migration changes"],
|
||||
"failure_retry_restart": ["Attestation is immutable; changed digest/source requires a new attestation"],
|
||||
"assumptions": ["Artifact storage computes or verifies digest later", "Producer run and source revision are durable refs", "Verifier remains distinct from producer"],
|
||||
"acceptance_scenarios": ["Complete attestation validates", "Missing digest/source/worktree/test evidence rejects", "Attestation binds to one producer run", "Changed artifact requires a new attestation"],
|
||||
"required_tests": ["go test ./...", "go vet ./...", "go run ./cmd/devctl preflight -active dev/ACTIVE_TASK.json", "go run ./cmd/devctl check-diff -active dev/ACTIVE_TASK.json", "go run ./cmd/devctl check-architecture", "go run ./cmd/devctl/independent", "git diff --check", "artifact attestation tests"],
|
||||
"terminal_gap_states": ["BLOCKED_BY_MISSING_CAPABILITY", "BLOCKED_BY_SPEC_GAP", "BLOCKED_BY_CONFLICT"]
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package agent_execution_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.cin.su/m/Assistant/contracts/artifact"
|
||||
)
|
||||
|
||||
func TestAgentArtifactAttestationRequiresProvenance(t *testing.T) {
|
||||
attestation := artifact.AgentArtifactAttestation{ArtifactID: "artifact-1", ProducerRunID: "run-1", SourceRevision: "commit-1", WorktreeID: "worktree-1", ContentDigest: "sha256:artifact", TestEvidenceRef: "tests:1", CreatedAtUnixMillis: 10}
|
||||
if err := attestation.Validate(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
attestation.ContentDigest = ""
|
||||
if err := attestation.Validate(); err == nil {
|
||||
t.Fatal("expected missing digest rejection")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user