review-state update creates the card when none exists #715
Labels
No labels
agent-ready
bug
contract
documentation
duplicate
enhancement
good first issue
help wanted
invalid
needs-human
needs-input
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
iterative-works/iw-cli#715
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
A workflow step that records a state on the review-state card must today choose between
review-state update(card exists) andreview-state write(no card). kanon's instructions do this with anif [ -f <path> ]branch in the agent's shell code. Since IW-702 the card lives outside the work tree, so the agent cannot know where it is or whether it exists. A branch that still tracks its card in the tree makes it worse:review-state path(IW-710, never moves) reports no card at the core location, the agent runswrite,writemoves the tracked card and then overwrites it whole, andphase_checkpoints, artifacts and badges are lost.The agent must not decide this. It states the state it wants, and the tool decides whether the card exists and where it lives.
Change
iw review-state updatecreates the card when none exists for the key.withCardPath: core location, after the one-time move of a tracked in-tree card).version,issue_id,artifacts: []) instead of failing with "Review state file not found". When a card exists, merge as now.doestext says it creates the card when missing.updatealready takes--workflow-type, and--append-artifactis keyed by label, so oneupdatecall covers what the create branch passed towrite(an appended artifact whose label exists replaces it, no duplicate).writestays as it is, for a full replace (--from-stdin).Acceptance
update --issue-id K ...with no card for K writes a valid card with the given fields.updateon an existing card keeps checkpoints, badges and artifacts it did not touch (unchanged behaviour).updateon a branch that still tracks its card in the tree moves it and merges into it; nothing is lost.--inputpath that does not exist: decide and document (create, or keep failing).Context
Consumer: kanon DEVDOCS-439 Phase 2 (agent instructions call one
updateper state, noif, no path). kanon raises its// REQUIRES:headers to the release that ships this; DEVDOCS-439's final PR waits for that release.Known risk: a wrong key creates a stray card (required fields are only version/issue_id/artifacts/last_updated). The key comes from the branch or
--issue-idand is parsed as a WorktreeKey.Type: feature
Filed from:
/home/mph/ops/kanon-DEVDOCS-439on branchDEVDOCS-439Correction to the issue body, and two additions to scope.
--append-artifactis keyed by label. That is wrong. Incore/model/ReviewStateUpdater.scala:151-156the artifacts merge passes nokeyField; onlyavailable_actions(byid) andbadges(bylabel) are keyed. Without a key, every one-command update that appendsAnalysisadds a duplicate artifact. Scope addition: key artifact appends bylabel(mergeArray(..., keyField = Some("label"))), so an appended artifact whose label exists replaces it. Acceptance: twoupdate --append-artifact "Analysis:..."runs leave oneAnalysisartifact.updatehas no--versionflag. The empty card thatupdatecreates must setversion: 2itself, as well asissue_id, so the merged result passes validation. Acceptance:update --issue-id K --status xwith no card for K writes a card thatreview-state validateaccepts.