Skip to content

AA09: proposeAgentUpdate: patch semantics, instructions edits, carried-over folding - #859

Merged
LinuxDevil merged 1 commit into
mainfrom
fb-aa09-update-tool
Nov 3, 2026
Merged

LinuxDevil merged 1 commit into
mainfrom
fb-aa09-update-tool

Conversation

@LinuxDevil

Copy link
Copy Markdown
Owner

What changed

proposeAgentUpdate({ agentId, patch, instructionsEdits? }) returns an update card whose spec is the saved spec plus any earlier unsaved card for the same agent plus this patch, with a server-computed diffSpecs diff against the saved spec.

  • server/author/proposal/instructionsEdits.ts - applyInstructionsEdits: each oldText anchor must occur exactly once, edits may not overlap, applied right-to-left; ANCHOR_NOT_FOUND / ANCHOR_AMBIGUOUS (with count) / ANCHOR_OVERLAP (both indexes) results.
  • server/author/proposal/fold.ts - pendingUpdateCard (this turn's proposal record first, then the stored transcript's open card via the save gate's transcriptProposalStatus) and changedTopLevelKeys (canonical-JSON compare in SPEC_FIELD_ORDER).
  • server/author/tools/proposeAgentUpdateTool.ts - the tool: AGENT_NOT_FOUND, EMPTY_PATCH, EDITS_AND_INSTRUCTIONS, INSTRUCTIONS_IN_FILE and ANCHOR_* failures with the specified copy; anchors resolve against the folded base with one retry against the saved instructions; the pending card folds only while its baseSpecHash still matches the saved spec (a canvas edit breaks the chain); then the AA08 pipeline (applyAuthorPatch, catalog checks, requirements, reviewDraft) produces the card, recorded under update:<agentId> in proposalTurnState. Registered in AUTHOR_TOOL_FACTORIES (15 tools now; readTools.test.ts count updated).

Anchor failures carry { currentInstructions, retryWith: 'instructions' } where currentInstructions is exactly the text the edits were tried against. Nothing is written to disk.

How it was tested

  • instructionsEdits.test.ts (7 tests) + proposeAgentUpdate.test.ts (18 tests incl. a real on-disk AgentRepo asserting nothing is written): all pass.
  • Studio: npm run typecheck ✅ · npm run typecheck:server ✅ · npm test -- --run (968) ✅ · npm run test:server (1090) ✅ · npm run lint (workspace) ✅ 0 errors.
  • Root: npx tsc --noEmit ✅ · npm run lint ✅ · npm run test:coverage (7163 passed; needed --minWorkers=1 --maxWorkers=4 and LF-converted CRLF template READMEs - Windows checkout artifact, zero content diff) ✅ · npm run fallow ✅ 0 above threshold · npm run docs:ratchet ✅ at baseline · npm run api:check ✅ all 20 reports · npm run docs:llms:check ✅ · npm run size-check ✅ under budget.
  • Note: the earlier coverage run also showed packages/create-lousho failures that resolved once that package's own dist was built - environment-only, unrelated.

Acceptance criteria

  • Patch { tools: [] } on an agent with 2 tools → card with one remove change per tool and carriedOver: false.
  • Turn 1 proposes { description } (unsaved); turn 2 proposes { tools } → card spec has both, carriedFields: ['description'], changes list both.
  • After discardPendingChanges or a save, the next card does not fold (tested via stored discard part, save uiEvent, and turn-state marks).
  • If the agent was edited on the canvas after the pending card, the pending card is not folded (baseSpecHash mismatch).
  • Edits: not found / found twice / overlapping return the right code with currentInstructions; a valid pair of edits applies both.
  • Nothing is written to disk.

Generated with Devin

…ions edits, carried-over folding

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@LinuxDevil
LinuxDevil merged commit 93eb069 into main Nov 3, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant