Skip to content

Safety fixes: parent-done guard, verification nullsafe, metadata inheritance, role leak#69

Open
krandder wants to merge 1 commit into
mainfrom
safety-fixes
Open

Safety fixes: parent-done guard, verification nullsafe, metadata inheritance, role leak#69
krandder wants to merge 1 commit into
mainfrom
safety-fixes

Conversation

@krandder

Copy link
Copy Markdown
Contributor

Summary

Defensive improvements that prevent real bugs hit in production. Independent of the review/context/journal endpoints PR.

  • Parent-done guard: New verifyCompletion() function blocks marking a parent task done while children are still active (Layer 1: non-terminal children rejected, Layer 2: completionRule=and requires all children done, Layer 3: metadata.repo requires valid stateRef)
  • Role leak fix: Claim handler's role_mismatch error no longer includes the assigned agent's ID or the claimer's ID, preventing agents from learning who to impersonate
  • Metadata inheritance: Both decompose handlers (incremental + one-shot) now inherit all parent metadata to children, minus bookkeeping fields (claimedAt, claimedBy, claimSessionId, etc.)
  • Lease ts fallback: applyLeaseGranted() uses Date.now() when event.ts is missing, preventing leaseExpiresAt = NaN from external tool events
  • Type fixes: Pre-existing compilation errors fixed — added "file" to ArtifactKind, path/sizeBytes to ArtifactEvidence, optional source to TaskCompleted/TaskFailed

Not included

Verification

  • npx tsc --noEmit passes (0 errors, down from 6 pre-existing errors on main)
  • All 100 tests pass (npx vitest run)
  • No dependency on PR Add dependsOn to task creation API #1 (review/context/journal endpoints)

Test plan

  • Verify parent-done guard: attempt to mark a parent with active children as done — should get children_pending error
  • Verify role_mismatch messages no longer leak agent identities
  • Verify decomposed children inherit parent metadata (e.g., informed, tags)
  • Verify npx tsc --noEmit passes
  • Verify npx vitest run — 100 tests pass, 0 fail

…ritance, role leak

1. Parent-done guard (verifyCompletion):
   - Layer 1: block marking parent done if any children are non-terminal
   - Layer 2: block if completionRule=and and not all terminal children are done
   - Layer 3: block if metadata.repo set but stateRef missing/zeroed

2. Role_mismatch identity leak: remove agent ID and assignee/reviewer names
   from error messages to prevent agents from learning who to impersonate

3. Metadata inheritance in decompose handlers: children now inherit all
   parent metadata (minus bookkeeping fields like claimedAt, claimedBy, etc.)
   instead of only priority/assignee/reviewer

4. applyLeaseGranted ts fallback: use Date.now() when event.ts is missing
   to prevent leaseExpiresAt = NaN from external tool events

5. Type fixes (pre-existing compilation errors):
   - Add "file" to ArtifactKind union + path/sizeBytes to ArtifactEvidence
   - Add optional source to TaskCompleted and TaskFailed interfaces
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