Skip to content

fix(E0): local outcome JSONL reader must not acknowledge incomplete records #995

Closed

Description

@hyperpolymath

Event-chain position

Blocks E0 in #984. Follow-up to the post-merge E0 audit. This issue is about durable local outcome consumption, not a general redesign of Hypatia or a migration to a new database.

Reproducible code concern

At inspected main SHA f6f8864e772003a2ee66b18b3d8261a5484a6d2a, lib/learning_scheduler.ex:517-575 reads bytes after last_outcome_positions[file], splits them with String.split("\\n", trim: true), drops undecodable records, then stores the observed File.stat.size as the next offset. A producer can append an incomplete JSON object during poll A and complete that object before poll B; poll A advances past the incomplete prefix, so poll B reads only its suffix and the entire event can be lost. Reading at EOF without a trailing newline also risks accepting not-yet-durable records. Absent/read-unavailable logs and file truncation/rotation deserve explicit contracts rather than silent success.

Required repair

  • First reproduce under pinned Elixir toolchain with a temp JSONL fixture and an actual two-poll + restart invocation.
  • Acknowledge only complete newline-terminated records; persist/restore the offset of the last complete record, rather than file size, and retain incomplete trailing bytes until completion.
  • Make malformed complete rows visible and quarantined/auditable, while still allowing later valid records; do not classify malformed final tails as permanent corruption.
  • Test missing/unreadable files, failed destination or recipe-file writes, file shrink/rotation and scheduler restart. No double-credit on replay.
  • Two separately verified attempts with equal canonical JSON must be separate event identities; repeated delivery of one ID credits once. Do not derive attempt IDs from content hashes.
  • Preserve JSONL as the append-only journal. Respect the established ijson-jcs canonical evidence contract and KYAML policy/configuration responsibilities using their real tools, without blindly replacing JSONL or introducing Python.
  • Confirm no changes can enable fleet dispatch or advance Bayesian confidence, annealing or cross-repository learning from unqualified observations.
  • Publish a test receipt with exact head SHA and verified failing-before/passing-after fixtures. Keep E0 in Event chain E0–E5: warranted finding → identity → verified repair → qualified learning #984 blocked until all required acceptance conditions are demonstrated.

Boundaries

A narrowly scoped Elixir repair PR; never bypass CI/allowlist/signature requirements. Mirror outages and unrelated standards migration remain separate tracks.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions