Skip to content

check-selftest сверяет восстановленный файл с копией, из которой его восстановил #1266

Closed

Description

@gHashTag

check-selftest compares the restored file against the copy it restored it from

Found while auditing "what event in the world could make this check fail".

check-selftest mutates two files - rings/SR-00/QueenObserver.swift and the Makefile itself - and restores them from copies. The exit trap does:

cp "$$backup" "$$victim"
vs=$$(shasum "$$victim" | cut -d" " -f1)
if [ "$$vs" != "$$victim_sha" ]; then echo "[FAIL] restore checksum mismatch"; fi

where victim_sha was taken from the same file BEFORE copying. Comparing a copy to the original of the copy cannot fail - it proves cp worked, not that nobody touched the file.

This is the hole make mutants had and closed in b4d1946fe: record the sum of the MUTATED state and compare before restoring; on mismatch refuse to overwrite someone else's write and name the backup path.

User Scenarios & Testing

User Story 1 - A concurrent edit is refused, not overwritten (P1)

Acceptance Scenarios:

  1. Given check-selftest has mutated the victim and recorded its sum,
    When a second writer changes the victim before the trap runs,
    Then the trap exits non-zero, prints the victim path and the backup path, and leaves the victim as the second writer left it.
  2. Given no concurrent edit,
    When the trap runs,
    Then the victim is restored and the recipe exits zero.

Requirements

  • FR-001: After each mutation the recipe MUST record the sum of the mutated file in a variable distinct from the pre-mutation sum.
  • FR-002: Before each restore the recipe MUST compare the live file to the mutated sum, not to the backup.
  • FR-003: On mismatch the recipe MUST NOT restore; it MUST print [REFUSED], the victim path and the backup path.
  • FR-004: Both arms MUST be driven and quoted in the bee's closing report, by extracting the restore trap into a shell function that takes victim, backup and mutated_sha as arguments and running it with sh against files in a temporary directory - the worker image has no make, so the recipe itself is not run.

Success Criteria

  • trios/Makefile check-selftest recipe contains a variable named mutated_sha; that identifier appears nowhere in the tree today.
  • The recipe contains the exact string [REFUSED].
  • The closing report quotes two sh runs of the extracted trap function: one ending in [REFUSED] with a non-zero exit, one ending in a clean restore with exit zero.
  • The temporary victim file is byte-identical before and after the clean run, proven by sha256sum quoted in the closing report.

Boundary

trios/Makefile

Activity

  1. gHashTag commented on Sep 4, 2026

    @gHashTag
    CollaboratorAuthor

    Closed after verifying the work exists.\n\nThe Queen accepted this dispatch. The result is commit on branch - fix(trios): check-selftest's restore trap refuses a victim it no longer holds (#1266) - now pushed to .\n\nIt stayed open because the deployed supervisor cannot write to GitHub: makes exactly two calls, both GET, and the container had no git credential configured. 100 branches of accepted work were sitting on the Railway volume unpushed, and 76 finished issues like this one stayed open and jammed the candidate pool - the round skipped them as every tick. The branches are pushed now; the missing write path is the remaining defect.

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