Skip to content

bug(doctor): sync_mutation_required_fields blocks on already-dispositioned acked rows, not pending ones #2388

Closed

Description

@zdknet-0rgon

Existing Issue Search

  • I searched existing issues and will add evidence to a canonical tracker when applicable.

Closest match: #2304 (closed, completed) — it covers complete pending session upserts with an empty journal project, and the repair it shipped is scoped to Cloud-enrolled devices. This report is about the already-dispositioned class, which that repair does not reach and which still blocks doctor.

Related: #1239 (repair's next: hint), #1188 (maintainer triage of the empty-project class), #1289 (purge request, closed not_planned), #1026, #1104.

📝 Observed Consequence

engram doctor stays blocked forever on a machine whose cloud sync was never configured. The finding says:

Pending cloud mutation has an empty or padded project column.

but no such pending mutation exists. The rows it points at were already resolved on 2026-09-19 and are explicitly marked as "no cloud pipeline, local writes preserved". The rows are:

sqlite> SELECT seq, entity, entity_key, target_key, source, project,
                 disposition, disposition_reason, disposition_at, acked_at
        FROM sync_mutations WHERE trim(coalesce(project,''))='' ORDER BY seq;

 seq | op     | entity  | entity_key  | target_key | source | project | disposition            | disposition_at         | acked_at
-----+--------+---------+-------------+------------+--------+---------+-----------------------+------------------------+---------
 985 | upsert | session | manual-save | cloud      | local  | (empty) | acked_local_no_pipeline | 2026-09-19 06:21:22     | NULL
 998 | upsert | session | manual-save | cloud      | local  | (empty) | acked_local_no_pipeline | 2026-09-19 06:21:22     | NULL
1036 | upsert | session | manual-save | cloud      | local  | (empty) | acked_local_no_pipeline | 2026-09-19 06:21:22     | NULL
5361 | upsert | session | manual-save | cloud      | local  | (empty) | acked_local_no_pipeline | 2026-09-19 06:21:22     | NULL
 ...  (16 rows total, seq 985..10966)

sqlite> SELECT count(*) FROM sync_mutations
        WHERE trim(coalesce(project,''))='' AND disposition='pending';
0

sqlite> SELECT count(*) FROM sync_mutations WHERE disposition='pending';
253          -- all of them belong to an enrolled project and carry a non-empty project

disposition_reason on every row:

no cloud server configured (no effective server URL; no postgres at :5433); local writes preserved, cloud delivery not possible

Payload of row 985:

{"id":"manual-save","project":"","directory":"/Users/braingram","started_at":"2026-05-09 23:53:28"}

🔄 Steps to Reproduce

  1. Use a store where cloud was never configured for the affected project (here: ai-factory), while another project in the same store is enrolled (sync_enrolled_projects contains hermes-agent, enrolled 2026-09-19).
  2. Legacy manual-save session upserts with an empty journal project exist in sync_mutations and were dispositioned acked_local_no_pipeline when that enrollment happened.
  3. Run the doctor:
$ engram cloud status
Cloud status: not configured (no effective server URL)
Sync readiness: blocked (no effective server URL)

$ engram doctor --json
status: blocked   total 10, ok 9, warnings 0, blocked 1, errors 0
  check sync_mutation_required_fields -> blocked / sync_mutation_project_invalid
  safe_next_step: "Run `engram doctor repair --check sync_mutation_required_fields --dry-run`
                   to inspect local repairs; cloud-upgrade tooling requires configured cloud sync."

$ engram doctor repair --check sync_mutation_required_fields --dry-run
{ "applied": false, "actions": [], "project_repairs": [], "directory_repairs": [],
  "repairs": [], "superseded": [], "source_repairs": [], "source_unrepairable": [] }

The plan is empty, because the #2304 repair is scoped to pending rows and to Cloud-enrolled devices, and these rows are neither.

🔎 Why the documented local-only guard does not apply

docs/DOCTOR.md states:

A local-only install with no enrolled project does not report these cloud project findings.

This store has an enrolled project (hermes-agent), so that guard never activates — and the detector then scans the whole journal without filtering on disposition, collecting rows that were already resolved.

The authoritative local session does exist and does carry a canonical project:

sqlite> SELECT id, project, directory FROM sessions WHERE id='manual-save';
manual-save|hermes-agent|/Users/braingram

so the data needed to backfill the journal project exists; the repair simply does not look at dispositioned rows.

💡 Suggested change

  1. The detector should not report rows that are already dispositioned (disposition = 'acked_local_no_pipeline', or any terminal disposition). The finding text says "Pending cloud mutation", and by the store's own accounting these are not pending.
  2. Alternatively, extend the fix(doctor): sync_mutation_required_fields misses complete pending mutations with an empty project, which block every push and pull #2304 repair to dispositioned blank-project session upserts whose authoritative local session carries a canonical project (manual-save → hermes-agent here), so the journal stops carrying an empty project.
  3. If neither, the finding should degrade to info when engram cloud status reports not configured, consistent with how complete terminal quarantined and superseded rows already "remain informational without keeping doctor in warning or blocked status" (docs/DOCTOR.md).

ℹ️ Note on what is NOT proposed

Deleting sync_mutations rows is not proposed and is explicitly ruled out by docs/engram-cloud/troubleshooting.md ("What Not To Do — Do not delete sync_mutations rows to make the error disappear"), and #1289 (purge on local-only installs) is closed as not_planned. This report asks for a detector/repair fix, not a store cleanup.

Environment

  • engram core v3.7.2 (Homebrew, macOS arm64), gentle-engram 0.8.0 companion
  • Store: ~/.engram/engram.db; affected project ai-factory; enrolled project hermes-agent
  • 16 affected rows, seq 985..10966, all entity='session', entity_key='manual-save', target_key='cloud', source='local'

Activity

  1. dnlrsls commented on Nov 21, 2026

    @dnlrsls
    Member

    Maintainer triage

    Reproduced on canonical main 5a407913133cbd4f33a26cafb902f67755fadb03 using a disposable store with one enrolled project. A legacy session upsert with an empty journal project, disposition acked_local_no_pipeline and no cloud acknowledgement produces blocked / sync_mutation_project_invalid. Adding an otherwise identical pending row produces two blockers instead of one.

    The diagnostic deliberately reads rows without a cloud acknowledgement so it can inspect audit states. Its disposition switch fails to recognize the legacy local acknowledgement and sends it through pending-row validation.

    Approved scope is to exclude exactly this disposition from pending validation and its pending count. The check continues to block on the same defect in pending rows. Existing repair, transport and audit handling stay outside this change. The regression checks both cases and verifies that the diagnostic preserves the journal. Owner is @dnlrsls.

  2. added
    status:approved
    and removed
    status:needs-review
    on Nov 21, 2026
  3. self-assigned this
    on Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

status:approvedtype:bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions