The events table had no attempt column, so two attempts of the same task were indistinguishable: a retried task's stage events interleaved into one timeline and nothing could say which run produced a given result. - events gains an `attempt` column through the existing presence-gated migrateTasks loop rather than a version bump, so user_version stays 3 and an existing archie.db is migrated in place. A legacy-database test builds the pre-change schema and proves both that existing rows survive unattributed (attempt = 0) and that a new value round-trips. - Event.attempt = 11 and ReadTaskLogRequest.stage = 9 are field additions to existing messages: no new RPC, no new table, and no change to any canonical error message that crosses the state-store wire. - Every task event the workflow engine emits now carries the attempt. Producers that have no attempt yet (task_queued, binding_dispatch_failure) stay unattributed rather than guessing one. - Changed files are captured as a durable changes_captured event at commit and push time, reusing the existing three-dot diff primitive: paths from FilePatches(), counts from Stats(), base_sha recorded as the merge base actually diffed rather than the base tip, a 200-file cap with totals kept complete. Consumption goes through an unexported optional interface so workflow.Trees -- the yaegi capability surface for interpreted stage plugins -- is not widened. A capture is also taken once the pull request exists, so the capture can link it. - The per-attempt configuration is captured as a durable config_captured event carrying the non-secret config.TaskConfig, instead of a new table plus two new state-store RPCs: events are already this system's per-attempt provenance stream, so a table would have given one feature two provenance mechanisms. Redaction is proven against canary secrets. Measured payload: 539 bytes typical, 2333 bytes at 20 models. - Captures carry a schema marker and are refused unless their key set matches the declared payload shape, so drift surfaces as "recorded but could not be read" rather than as a capture of zeroes. - Three read endpoints serve the attempt rail, the changed-file captures and a raw debug view, mapping to UI-owned response types rather than dumping store types. - The task-log read gains a stage filter, bound to the stage logger for that stage's own lines; agent and tool output records no stage. A task-scoped grant may already insert events on its own task, so this provenance is exactly as trustworthy as the rest of that task's event stream. That limit is documented rather than papered over.
68 lines
2.8 KiB
Go
68 lines
2.8 KiB
Go
package task
|
|
|
|
// ChangeStats is the change one attempt produced, measured at the moment it
|
|
// was committed or pushed.
|
|
//
|
|
// It is a measurement, not a view: the worktree it was read from is deleted on
|
|
// merge, close and no-PR terminal states, and a retry resets the branch onto
|
|
// its base, so this is the only record of what an attempt actually changed.
|
|
// Nothing re-derives it after the fact.
|
|
//
|
|
// The value types live in this subpackage rather than in package workflow or
|
|
// internal/worktree, for two reasons that were checked rather than assumed.
|
|
// Package workflow must never import internal/worktree -- it has no such
|
|
// import today -- so a shared value cannot live there. And this subpackage is
|
|
// not projected into the interpreted-stage symbol table (the generated
|
|
// wfextract table names no type from here), whereas a new exported type in
|
|
// package workflow would be reachable from repository-authored
|
|
// `.archie/stages/*.go`. Declaring it here widens nothing and needs no
|
|
// symbol-table regeneration.
|
|
type ChangeStats struct {
|
|
BaseSHA string `json:"base_sha"`
|
|
HeadSHA string `json:"head_sha"`
|
|
Files []FileChange `json:"files"`
|
|
Totals ChangeTotals `json:"totals"`
|
|
}
|
|
|
|
// FileChange is one file's contribution to a change.
|
|
type FileChange struct {
|
|
Path string `json:"path"`
|
|
// OldPath is the pre-change path, populated only for a rename.
|
|
OldPath string `json:"old_path"`
|
|
// Status is one of the Change* values below.
|
|
Status string `json:"status"`
|
|
Additions int `json:"additions"`
|
|
Deletions int `json:"deletions"`
|
|
// Binary reports that the file produced no textual hunks. It is NOT a
|
|
// claim that the file is binary on disk: an empty or otherwise chunkless
|
|
// edit reports this too, so it must never be rendered as a file type.
|
|
Binary bool `json:"binary"`
|
|
}
|
|
|
|
// ChangeTotals summarises a change. Totals always cover the FULL set of
|
|
// changed files, even when FileChange entries were dropped by the
|
|
// MaxCapturedFiles cap, so a truncated capture still reports honest totals.
|
|
type ChangeTotals struct {
|
|
Files int `json:"files"`
|
|
Additions int `json:"additions"`
|
|
Deletions int `json:"deletions"`
|
|
}
|
|
|
|
// Change status values as they are persisted inside a changes_captured
|
|
// event's data. Like the task lifecycle statuses, these strings are part of
|
|
// the on-disk format: renaming one is a migration, not a rename.
|
|
const (
|
|
ChangeAdded = "added"
|
|
ChangeModified = "modified"
|
|
ChangeDeleted = "deleted"
|
|
ChangeRenamed = "renamed"
|
|
ChangeTypeChanged = "typechange"
|
|
)
|
|
|
|
// MaxCapturedFiles caps how many file entries one capture persists. Unlike
|
|
// Event.Detail, an event's data is not length-limited by the store, so this cap
|
|
// is what keeps one large refactor from writing an unbounded payload. A capture
|
|
// that dropped entries keeps the totals of the full set and reports itself as
|
|
// truncated.
|
|
const MaxCapturedFiles = 200
|