Work Packages: Autonomous Runtime Safety Follow-ups

Inputs: Design documents from /kitty-specs/autonomous-runtime-safety-followups-01KS52BD/ Prerequisites: plan.md, spec.md, research.md, data-model.md, contracts/, quickstart.md Tests: Focused affected packages per WP; no full-suite run required per WP. Organization: Six issue-aligned work packages. WP01-WP05 are code/runtime workstreams. WP06 is docs-only and should be implemented after runtime behavior is settled, but it intentionally has no metadata dependency so current lane collapse does not serialize the mission.

Work Package WP01: Retrospect schema reconciliation (Priority: P1)

Goal: Make agent retrospect synthesize accept records written by retrospect create. Independent Test: A create-shaped retrospective.yaml passes synthesize dry-run and --apply. Prompt: /tasks/WP01-retrospect-schema-reconciliation.md Requirement Refs: FR-001, FR-002, FR-003, NFR-001, NFR-002, NFR-003, NFR-004, NFR-006, C-001, C-005, C-007, C-008

Included Subtasks

  • □ T001 Reproduce the pydantic extra_forbidden failure with a create-shaped retrospective record.
  • □ T002 Align synthesize reader schema with create writer output.
  • □ T003 Cover dry-run/default synthesize against the create-shaped record.
  • □ T004 Cover --apply synthesize against the create-shaped record.
  • □ T005 Run focused retrospective tests and mypy on touched modules.

Implementation Notes

  • Prefer a shared pydantic model if local impact is small; otherwise configure the synthesize reader to ignore informational extras.
  • Preserve existing missing-record, malformed-YAML, and I/O error behavior.

Parallel Opportunities

  • Independent from WP02-WP06.

Dependencies

  • None.

Risks & Mitigations

  • Risk: schema widening hides invalid records. Mitigation: keep findings/proposal fields strict where they drive behavior.

Work Package WP02: Decision deferred closure (Priority: P1)

Goal: Allow deferred decisions to close cleanly when plan defaults are accepted. Independent Test: Open -> defer -> resolve succeeds; marker removal no longer reports verifier drift. Prompt: /tasks/WP02-decision-deferred-closure.md Requirement Refs: FR-004, FR-005, FR-006, NFR-001, NFR-002, NFR-003, NFR-004, NFR-006, C-001, C-002, C-005, C-007, C-008

Included Subtasks

  • □ T006 Add regression coverage for deferred -> resolved conflict.
  • □ T007 Update decision service/state handling for explicit closure.
  • □ T008 Update verifier rules for closed deferred decisions without markers.
  • □ T009 Update acceptance clarification handling for closed decisions.
  • □ T010 Run focused decision/acceptance tests and mypy on touched modules.

Implementation Notes

  • Prefer allowing deferred -> resolved; add close-with-default only if the state model makes direct resolution unsafe.
  • Do not change open, defer, or cancel public contracts.

Parallel Opportunities

  • Independent from WP01, WP03, WP04, WP05, and WP06.

Dependencies

  • None.

Risks & Mitigations

  • Risk: unresolved deferred decisions become invisible. Mitigation: require explicit final answer or explicit default-closure action.

Work Package WP03: owned_files validator for kitty-specs/ paths (Priority: P1)

Goal: Make finalize-tasks reject kitty-specs/ entries in WP owned_files before lane work starts. Independent Test: Validate-only and full finalization fail with a structured WP/path error. Prompt: /tasks/WP03-owned-files-validator.md Requirement Refs: FR-007, FR-008, FR-009, NFR-001, NFR-002, NFR-003, NFR-004, NFR-005, NFR-006, C-001, C-003, C-005, C-007, C-008

Included Subtasks

  • □ T011 Add finalize-tasks fixture with kitty-specs/ in owned_files.
  • □ T012 Implement shared validation for validate-only and mutating finalization.
  • □ T013 Return structured JSON details naming offending WP and path.
  • □ T014 Add architectural regression coverage for WP frontmatter ownership.
  • □ T015 Run focused finalize/architectural tests and mypy on touched modules.

Implementation Notes

  • Preferred stable error code: OWNED_FILES_KITTY_SPECS_PATH.
  • Do not implement mission-branch auto-routing unless existing architecture makes it straightforward and testable.

Parallel Opportunities

  • Independent from WP01, WP02, WP04, WP05, and WP06.

Dependencies

  • None.

Risks & Mitigations

  • Risk: planning-artifact missions need a different route. Mitigation: WP04 handles planning-artifact pre-flight classification separately; this WP only fixes the contract split.

Work Package WP04: Bulk-edit planning pre-flight refinement (Priority: P2)

Goal: Treat WPs authoring occurrence_map.yaml as bulk-edit planning instead of blocking false positives. Independent Test: A claimed occurrence-map WP passes without --acknowledge-not-bulk-edit; active rewrite WPs still block. Prompt: /tasks/WP04-bulk-edit-planning-preflight.md Requirement Refs: FR-010, FR-011, NFR-001, NFR-002, NFR-003, NFR-004, NFR-006, C-001, C-003, C-004, C-005, C-007, C-008

Included Subtasks

  • □ T016 Add regression test for inferred bulk-edit text plus occurrence-map-owned WP.
  • □ T017 Add WP frontmatter inspection to implementation pre-flight.
  • □ T018 Downgrade planning-artifact inference to informational for that WP.
  • □ T019 Preserve blocking behavior for active rewrite WPs and invalid bulk_edit state.
  • □ T020 Run focused implement/bulk-edit tests and mypy on touched modules.

Implementation Notes

  • Do not change the bulk-edit skill.
  • Keep --acknowledge-not-bulk-edit behavior for true non-bulk-edit cases.

Parallel Opportunities

  • Independent from WP01, WP02, WP03, WP05, and WP06.

Dependencies

  • None.

Risks & Mitigations

  • Risk: safety gate weakens for active rewrites. Mitigation: include negative tests for rewrite WPs.

Work Package WP05: Lane-collapse disjoint-ownership refinement (Priority: P2)

Goal: Preserve parallel lanes for disjoint upstream workstreams that only meet at a fan-in WP. Independent Test: Six disjoint workstreams plus one fan-in WP produce parallel lanes rather than one collapsed lane. Prompt: /tasks/WP05-lane-collapse-disjoint-ownership.md Requirement Refs: FR-012, FR-013, NFR-001, NFR-002, NFR-003, NFR-004, NFR-006, C-001, C-005, C-007, C-008

Included Subtasks

  • □ T021 Add fan-in lane fixture with disjoint owned_files.
  • □ T022 Refine lane collapse to consider ownership overlap and lane dependency ordering.
  • □ T023 Preserve collapse for overlapping owned-file dependencies.
  • □ T024 Improve collapse_report evidence for dependency/overlap decisions.
  • □ T025 Run focused lane/finalize tests and mypy on touched modules.

Implementation Notes

  • The fan-in WP is the synchronization point; upstream workstreams should not collapse solely due to transitive relationships.
  • Keep existing merge consumer compatibility with lanes.json.

Parallel Opportunities

  • Independent from WP01, WP02, WP03, WP04, and WP06.

Dependencies

  • None.

Risks & Mitigations

  • Risk: new parallelism creates conflicts. Mitigation: keep overlap collapse conservative and assert lane dependencies.

Work Package WP06: Focused-PR workflow documentation (Priority: P3)

Goal: Document the focused-PR fallback for autonomous local runs that hit TARGET_BRANCH_NOT_SYNCHRONIZED. Independent Test: Docs include trigger, focused branch commands, direct mission-branch PR path, and squash-merge guidance. Prompt: /tasks/WP06-focused-pr-workflow-docs.md Requirement Refs: FR-014, FR-015, NFR-001, NFR-004, C-001, C-005, C-007, C-008

Included Subtasks

  • □ T026 Locate or create the standing mission workflow documentation target.
  • □ T027 Update official autonomous-run docs with focused-PR fallback.
  • □ T028 Cite TARGET_BRANCH_NOT_SYNCHRONIZED and runtime remediation commands.
  • □ T029 Add direct mission-branch PR and squash-merge guidance from PR #1251.
  • □ T030 Run applicable docs/toc tests or document why none apply.

Implementation Notes

  • Implement after WP01-WP05 so docs reflect final behavior, even though metadata has no dependency to avoid current lane-collapse serialization.
  • If spec-kitty-mission-workflow.md is absent, create the closest standing workflow doc approved by existing docs structure.

Parallel Opportunities

  • Can draft in parallel, but final wording should be checked after runtime WPs land.

Dependencies

  • None in metadata; operationally run after runtime WPs.

Risks & Mitigations

  • Risk: docs target ambiguity. Mitigation: update existing how-to pages and create docs/how-to/run-an-autonomous-mission.md if no exact page exists.

Dependency & Execution Summary

  • Recommended sequence: WP01 -> WP02 -> WP03/WP04 -> WP05 -> WP06.
  • Metadata dependencies: none, to avoid current fan-in collapse behavior.
  • Parallelization: WP01-WP05 can run as separate workstreams because their owned_files are disjoint.
  • MVP Scope: WP01 alone unblocks retrospective synthesis; WP01 + WP02 unblock terminus learning and decision closure.

Requirements Coverage Summary

Requirement IDCovered By Work Package(s)
FR-001WP01
FR-002WP01
FR-003WP01
FR-004WP02
FR-005WP02
FR-006WP02
FR-007WP03
FR-008WP03
FR-009WP03
FR-010WP04
FR-011WP04
FR-012WP05
FR-013WP05
FR-014WP06
FR-015WP06

Subtask Index (Reference)

Subtask IDSummaryWork PackagePriorityParallel?
T001Reproduce retrospective schema mismatchWP01P1Yes
T002Align retrospective reader schemaWP01P1No
T003Dry-run synthesize regressionWP01P1Yes
T004Apply synthesize regressionWP01P1Yes
T005Retrospective focused verificationWP01P1No
T006Decision transition regressionWP02P1Yes
T007Decision closure implementationWP02P1No
T008Verifier closure awarenessWP02P1No
T009Acceptance closure awarenessWP02P1No
T010Decision focused verificationWP02P1No
T011Invalid owned-files fixtureWP03P1Yes
T012Finalize ownership validationWP03P1No
T013Structured ownership errorWP03P1No
T014Architectural ownership testWP03P1Yes
T015Ownership focused verificationWP03P1No
T016Bulk-edit planning regressionWP04P2Yes
T017WP frontmatter pre-flight inspectionWP04P2No
T018Informational planning warningWP04P2No
T019Active rewrite gate preservationWP04P2No
T020Bulk-edit focused verificationWP04P2No
T021Fan-in lane fixtureWP05P2Yes
T022Ownership-aware lane collapseWP05P2No
T023Overlap collapse regressionWP05P2Yes
T024Collapse report evidenceWP05P2No
T025Lane focused verificationWP05P2No
T026Docs target discoveryWP06P3Yes
T027Official autonomous docs updateWP06P3No
T028Runtime error remediation citationWP06P3No
T029Direct PR and squash guidanceWP06P3No
T030Docs verificationWP06P3No