Skip to content

fix: shift ledger edit op; hold completion on a set-aside (M3.6d) #660

Closed

Description

@Jammy2211

Overview

Milestone task M3.6d of the autonomous-orchestrators epic. In shift 2026-11-16-pm a worker's op: write edits to existing Mind drafts were set aside while its complete/ record committed, so Mind recorded the task shipped with the drafts unchanged (PyAutoMind#579 still open); five workers also hit table-append failing on autonomy_log.md. This gives the Mind writer an edit op, makes a task's ops land together, refuses bad ops at queue time, and stops mechanical set-asides raising NEEDS YOU. Build first, in chat: a shift never changes its own writer.

Plan

  • write stays create-only; a new edit op replaces an expected old text that must appear exactly once (so it cannot clobber a concurrent change).
  • Worker ops carry their task; a task's closing ops (complete/ record, drop-section, retire) apply last and are withheld if any sibling op was set aside for a human.
  • shift_ledger refuses at queue time a write to an existing path, an edit whose base is missing, and a table-append with no heading, so the worker can switch while still running.
  • A mechanical set-aside (already true on main) is a digest line, not a NEEDS YOU; human set-asides give one NEEDS YOU per task.
  • PyAutoMind: a ## Calibration runs heading above the first autonomy_log.md table (and the matching spawn.py template), so table-append reaches it.
  • Tier: glance — merge mode: human /prm (the human's instruction for this sitting; no auto-merge)
Detailed implementation plan

Affected Repositories

  • PyAutoBrain (primary)
  • PyAutoMind

Branch Survey

Repository Current Branch Dirty?
PyAutoBrain (canonical) main, 6 behind origin untracked .worktrees/ only
PyAutoMind (canonical) main, behind origin another session's uncommitted batches/2026-11-16-pm.md (left alone)

Suggested branch: feature/shift-ledger-edit-op (worktree ~/Code/PyAutoLabs-wt/shift-ledger-edit-op/). Parallel with M3.6a/M3.6e.

Implementation Steps

  1. _mind_writer.py: OPS gains edit; class MechanicalError(MindWriteError); validate_op (edit needs non-empty old, new != old; optional one-line task); apply_op edit branch (exactly once → replace; 0 or >1 → MindWriteError; old absent and new present → MechanicalError); write of identical text and remove of a missing path → MechanicalError; is_critical: a tagged table-append is not critical; new _main_text (git show origin/main:<path>, no fetch) and queue_refusals(mind, op, ledger_dir) (fail-open to apply time when git is unreadable); _closing(op); _set_aside records task and needs (mechanical | human); commit_ledger stable-partitions closing ops last and withholds a blocked task's closing ops into set_aside/ as withheld.
  2. bin/shift_ledger.py: --task (required when PYAUTO_SHIFT_WORKER=1); edit <path> --old/--old-file --new/--new-file; fix table-append <path> "<## heading>" --text "<row>" [--unique] (heading/row are never set today); Mind lookup --mind → $PYAUTO_MIND → sibling organs layout; validate_op then queue_refusals, exit 1 without queueing on refusal.
  3. _events.py:_impaired: skip needs == "mechanical"; group human set-aside/conflict/withheld by task into one event impaired:ledger:task:<task>; untagged ops unchanged.
  4. _digest.py: withheld and mechanical wording in _REPORT_WORDS / report_line.
  5. worker_template.md, closeout_template.md: {shift_ledger} --task {task} …; write creates, edit changes; queue edits first and the complete record last; calibration row via table-append autonomy_log.md "## Calibration runs". Op lists in batch AGENTS.md; heading named in skills/ship_library/reference.md, ship_library.md, ship_workspace.md.
  6. _orchestrator.py: not touched.
  7. PyAutoMind PR: autonomy_log.md ## Calibration runs between the intro and the first table; scripts/spawn.py AUTONOMY_LOG_TEMPLATE same insertion (test_spawn_privacy.py checks the live log starts with it). Merge this Mind PR first.

Witness mapping (tests/test_orchestrator_mind_writer.py)

  1. test_a_write_on_a_path_on_main_is_refused_at_queue_time
  2. test_the_edit_op_applies_on_a_matching_base_and_is_set_aside_on_a_moved_one
  3. test_a_worker_with_an_op_set_aside_has_its_complete_record_held
  4. test_shift_ledger_table_append_reaches_the_first_autonomy_log_table
  5. test_a_mechanical_set_aside_is_a_digest_line_not_a_needs_you_event (+ two human set-asides for one task → one NEEDS YOU)

Key Files

  • agents/conductors/batch/_mind_writer.py, bin/shift_ledger.py, _events.py, _digest.py, the two templates
  • PyAutoMind autonomy_log.md, scripts/spawn.py

Original Prompt

Click to expand starting prompt

M3.6d A shift worker's edit to an existing Mind file is set aside, but its completion record still commits

Type: bug
Target: PyAutoBrain
Repos:

  • PyAutoBrain
  • PyAutoMind
    Difficulty: medium
    Autonomy: supervised
    Priority: high
    Status: draft
    Filed: 2026-11-16
    Epic: autonomous-orchestrators
    Phase: 10
    Consequence: glance
    Witness: python -m pytest tests/test_orchestrator_mind_writer.py -q passes with new tests that fail on today's main: (1) queueing op: write on a path that exists on Mind origin/main is refused at queue time and the worker is told; (2) the new edit op applies when the expected base matches and is set aside when it does not; (3) a worker with one op set aside has its complete/ record held (no completion commit lands); (4) shift_ledger table-append reaches the first table of autonomy_log.md once the heading is there; (5) a mechanical set-aside gives one digest line and no NEEDS YOU event
    Lane: any
    Unattended: never

Seen in shift 2026-11-16-pm (18:21Z). Worker dashboard_titles_two_drafts_by_their_filed_line shipped as Mind ledger ops. Its three op: write edits to existing drafts were set aside ("write: already exists", ledger set_aside/), raised as three NEEDS YOU lines, but its complete/2026/11/dashboard-titles-filed-line.md write committed. So Mind recorded the task shipped while the drafts were unchanged. The human applied the set-aside text by hand (cockpit, 2026-11-16).

  1. Give the Mind writer an op that edits an existing file (a replace with an expected-base check, so it cannot clobber a concurrent change), and have the worker contract use it for edits; keep write create-only.
  2. Make a worker's ledger ops land together: if any op is set aside, hold back its completion record (or mark the task not shipped) instead of committing it alone.
  3. One NEEDS YOU line per worker for set-aside ops, naming the task, not one per file.

Added 2026-11-17 (M3.6d, from the shift 2026-11-16-pm review)

This prompt is now milestone task M3.6d of the autonomous-orchestrators epic. Further
evidence from the same shift: four more write ops were set aside the same way (the record's
warnings list sibson_serial_kernel_loses_allocation_hoisting.md,
delaunay_nn_numba_optimal_remeasure_after_677.md,
tutorial_correctness_and_howtogalaxy_parity.md and complete/2026/11/seed-samplers-byte-stable.md).
PyAutoMind#579 is still open because of it. Five workers hit table-append failing on
autonomy_log.md, so no calibration row was queued for the shift's merges. The cockpit chat
applied four "needs you" events without waiting for the human, because they were mechanical
refusals.

  1. Refuse at queue time. A write on a path that already exists on Mind origin/main is
    refused when the worker queues it, so the worker can switch to the edit op while it is
    still running, instead of the set-aside surfacing after the worker has ended.
  2. The edit op in item 1 is part of this task, not a follow-up.
  3. A heading above the first autonomy_log.md table, so shift_ledger table-append can
    reach it (it needs a ## heading). This is a Mind data change and goes in this task's
    Mind PR.
  4. A mechanical set-aside is not a "needs you" event. It is a digest line (and, after
    M3.3 slice 2, an entry in the decisions block). Item 3 then applies only to set-asides that
    need a human choice.

Out of scope: the one network write path to Mind main (M4.3), and the auto-mode classifier
denying Mind lifecycle commands inside workers (infrastructure review).

Activity

  1. Jammy2211 commented on Nov 17, 2026

    @Jammy2211
    ContributorAuthor

    Library PRs created

    Built test-first (new tests fail on origin/main, pass on the branch), independently reviewed by Fable 5.2 (author Opus 5.5): FINDINGS → fixed → CLEAN. Workspace impact: none (organ-only change). Merge: human /prm. Suggested order across M3.6: M3.6d (#660, Mind PR first), then M3.6a (#659), then M3.6e (#661, which needs a one-line import resolution in _orchestrator.py after M3.6a: keep both imports).

    Heart RED override (development only), recorded

  2. Jammy2211 commented on Nov 17, 2026

    @Jammy2211
    ContributorAuthor

    Shipped

    Merged by the human's /prm (2026-11-17): PyAutoBrain#663 (419c15c), PyAutoMind#581 (cf57daefa). CI green on the merged heads; the Heart RED development override covered shipping only, and the merge was this separate human command.

    Mind writer: create-only write plus an edit op with an expected-base check; a task's closing ops land together (withheld on a human set-aside, pending beside a held sibling); queue-time refusals; mechanical set-asides are digest notes; one NEEDS YOU per task; ## Calibration runs heading so table-append reaches the first autonomy_log table.

    Close-out: completion record in PyAutoMind complete/2026/11/, active.md row released, dashboard regenerated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions