{
  "registered_revision": "4f5a2bf3e2331bde4b88f4d69917c6e1409e2a19",
  "implementation": [
    {
      "document": "village_zero/spatial.py",
      "file_sha256": "dde8c6cb0791ebd82a3e99ca1e3fd7e961018f52283f901ca7e773a622ecb7dd",
      "excerpts": [
        {
          "lines": "12–15",
          "verbatim": "PLACES = {'village':'Village Square','tavern':'Tavern','market':'Market','homes':'Residential Area'}\nSTART = {KEEPER:'tavern', SELLER:'market', 'gossip':'tavern'}\nVENUES = {KEEPER:'tavern', SELLER:'market', 'gossip':'village'}\nEDGES = {'tavern':1,'market':1,'homes':2}"
        },
        {
          "lines": "60–65",
          "verbatim": "                for place,name in PLACES.items():\n                    self.db.execute('INSERT OR IGNORE INTO location_nodes VALUES (?,?)',(place,name))\n                self.db.execute(\"UPDATE location_nodes SET name='Village Square' WHERE id='village'\")\n                for place,cost in EDGES.items():\n                    for origin,destination in (('village',place),(place,'village')):\n                        self.db.execute('INSERT OR IGNORE INTO location_connections VALUES (?,?,?)',(origin,destination,cost))"
        },
        {
          "lines": "74–86",
          "verbatim": "    def position(self, resident):\n        journey = self.db.execute('SELECT destination,arrival FROM journeys WHERE resident=? AND arrived_event IS NULL',\n                                  (resident,)).fetchone()\n        if journey:\n            return {'id':None,'status':'in_transit',**dict(journey)}\n        place = self.db.execute('SELECT location_id FROM resident_locations WHERE resident_id=?',(resident,)).fetchone()\n        if not place:\n            raise ValueError('Unknown resident location')\n        return {'id':place[0],'status':'present'}\n\n    def together(self, first, second):\n        origin = self.position(first)['id']\n        return origin is not None and origin==self.position(second)['id']"
        }
      ]
    },
    {
      "document": "village_zero/local_perception.py",
      "file_sha256": "a6aa887664e62d82eb0d462f1e70675b25c676b96ed7414466d49570b3065013",
      "excerpts": [
        {
          "lines": "10–23",
          "verbatim": "def visible(world, resident, detail=\"present\"):\n    if detail not in (\"present\",\"passing\"):\n        raise ValueError(\"Unknown observation detail\")\n    if resident not in world.config[\"personas\"]:\n        raise ValueError(\"Unknown observer\")\n    place = world.position(resident)[\"id\"]\n    if place is None:\n        return None\n    objects = []\n    for encounter in world.encounters(resident):\n        peer = encounter[\"peer\"]\n        if world.together(resident,peer):\n            objects.append(dict(id=\"resident:\"+peer,seen=\"present\",source_event=encounter[\"id\"]))\n    if place==\"village\" and world.config.get(\"local_market_board\"):"
        }
      ]
    },
    {
      "document": "village_zero/propagation.py",
      "file_sha256": "81306acb056842c1c4607673153e600f854c81fa08008241b03b12182dd78645",
      "excerpts": [
        {
          "lines": "180–202",
          "verbatim": "    def dispatch(self, message_id, recipient):\n        envelope = self.db.execute('SELECT * FROM envelopes WHERE message_id=?',(message_id,)).fetchone()\n        if not envelope or recipient not in self.config['personas'] or recipient == envelope['sender']:\n            raise ValueError('Invalid message delivery')\n        old = self.db.execute('SELECT memory_id FROM deliveries WHERE message_id=? AND recipient=?',\n                              (message_id,recipient)).fetchone()\n        if old:\n            self.db.execute('INSERT INTO delivery_attempts(message_id,recipient,status) VALUES (?,?,?)',\n                             (message_id,recipient,'duplicate_suppressed'))\n            return old[0]\n        route = self.db.execute(\"\"\"\n            SELECT q.accepted_call FROM message_queue q JOIN calls c ON c.id=q.accepted_call\n            WHERE q.message_id=? AND q.recipient=? AND c.applied=1\n            \"\"\",(message_id,recipient)).fetchone()\n        if not route:\n            raise ValueError('Message route has no committed acceptance')\n        mid = self.memory(recipient,'message',envelope['text'],sender=envelope['sender'],\n                          parents=json.loads(envelope['parents']),call_id=route['accepted_call'])\n        self.db.execute('INSERT INTO deliveries VALUES (?,?,?)',(message_id,recipient,mid))\n        self.db.execute('INSERT INTO delivery_attempts(message_id,recipient,status) VALUES (?,?,?)',\n                         (message_id,recipient,'delivered'))\n        return mid\n"
        }
      ]
    },
    {
      "document": "village_zero/living.py",
      "file_sha256": "6c4a47fc06b061777c9c61bea9842e8d5099123e27c91b4ec2e908af8e523ced",
      "excerpts": [
        {
          "lines": "148–169",
          "verbatim": "    def living_actions(self, actor):\n        place = self.position(actor)['id']\n        if place is None:\n            return {}\n        state = self.state()\n        choices = {}\n\n        def add(name, operation, **terms):\n            choices['local:'+name] = dict(kind='local_work',operation=operation,location=place,**terms)\n\n        stock = state['stock'][actor]\n        day = state['day']\n        if (actor==GARDENER and place=='homes' and stock<TAVERN_CAPACITY\n                and state['garden_reserve'] and state['garden_packed_day']!=day):\n            add('pack','pack_harvest',units=1)\n        active = self.active_local_offers(state)\n        if stock and not any(o['from']==actor for o in active):\n            for peer in self.config['personas']:\n                if peer!=actor and {actor,peer}!=set(PARTIES) and self.together(actor,peer):\n                    add('offer:'+peer,'local_offer',peer=peer,units=1,price=PRICE)\n                    if self.config.get('flexible_trade_prices'):\n                        for price in CASH_UNIT_PRICES:"
        },
        {
          "lines": "178–196",
          "verbatim": "                add(f\"take:{offer['id']}\",'local_trade',peer=seller,offer_id=offer['id'],units=1,price=offer['price'])\n        if place=='tavern':\n            units = state.get('evening_crates',0)\n            if (actor==KEEPER and self.config.get('tavern_service_now') and day>0 and units\n                    and stock>=units and state.get('tavern_served_day')!=day\n                    and self.config.get('daily_tavern_supply') and self.config.get('world_dynamics')\n                    and 'visitor_coins' in state):\n                add('serve_tavern_now','serve_tavern_now',units=units,service_day=day,\n                    effect='Run today’s regular tavern service now using your stock, once per day')\n            if actor==KEEPER and state['shutter']=='loose':\n                add('request_shutter','request_shutter')\n            elif actor==SMITH and state['shutter']=='requested' and self.together(actor,KEEPER):\n                add(f\"repair:{state['shutter_request']}\",'repair_shutter',\n                    peer=KEEPER,request_id=state['shutter_request'])\n        if self.config.get('local_market_board'):\n            from .market_board import choices as board_choices\n            choices.update(board_choices(self,actor,state,place))\n        return choices\n"
        }
      ]
    },
    {
      "document": "village_zero/memory_index.py",
      "file_sha256": "6544316c0ba2f1bf7ecaa4360b076d60f923fe50d2ea96060cbf04d0a503d629",
      "excerpts": [
        {
          "lines": "182–194",
          "verbatim": "    def search_memories(self, owner, query, *, filters=None, limit=5, mode='lexical', exclude=()):\n        self._owner(owner)\n        filters = {} if filters is None else filters\n        check_query(query,filters,limit)\n        if mode not in MODES or (mode!='lexical' and not self.embedder):\n            raise ValueError('Unavailable memory search mode')\n        rows = self.world.rows('''SELECT d.*, m.kind,\n            COALESCE(t.game_day,json_extract(e.body,'$.day')) AS day\n            FROM memory_documents d JOIN memories m ON m.id=d.memory_id\n            LEFT JOIN memory_times t ON t.memory_id=m.id LEFT JOIN events e ON e.id=m.event_id\n            WHERE m.owner=?''',(owner,))\n        candidates = {}\n        exclusions = set(exclude)"
        },
        {
          "lines": "207–229",
          "verbatim": "        tokens = list(dict.fromkeys(words(query)))[:64]\n        ranks = {}\n        if mode!='semantic' and tokens:\n            expression = ' OR '.join(f'\"{word}\"' for word in tokens)\n            hits = self.world.rows('''SELECT f.rowid AS id,f.tokens FROM memory_fts f\n                JOIN memories m ON m.id=f.rowid WHERE memory_fts MATCH ? AND m.owner=?''',(expression,owner))\n            hits = {r['id']:set(r['tokens'].split()) for r in hits if r['id'] in candidates}\n            df = Counter(token for text in hits.values() for token in text.intersection(tokens))\n            ranks['lexical'] = sorted(hits,key=lambda mid:(-sum(\n                math.log1p(len(candidates)/df[t]) for t in hits[mid].intersection(tokens)),mid))\n        if mode!='lexical':\n            model = self.embedder\n            vector, = model.encode([query.encode()[:1600].decode(errors='ignore')],query=True)\n            vector = normalized(vector,model.dimensions)\n            stored = self.world.rows('''SELECT v.* FROM memory_vectors v JOIN memories m ON m.id=v.memory_id\n                                       WHERE m.owner=? AND v.version=?''',(owner,model.version))\n            scores = {r['memory_id']:sum(a*b for a,b in zip(vector,struct.unpack(f'<{model.dimensions}f',r['vector'])))\n                      for r in stored if r['memory_id'] in candidates}\n            ranks['semantic'] = sorted(scores,key=lambda mid:(-scores[mid],mid))\n        if mode=='hybrid':\n            terms = ' '+' '.join(tokens)+' '\n            metadata = sorted((mid for mid,(_,tags) in candidates.items()\n                               if any(words(tag) and ' '+' '.join(words(tag))+' ' in terms"
        }
      ]
    },
    {
      "document": "village_zero/context.py",
      "file_sha256": "053b20b3e48d52f2018e10e532ae8cf8d30e4cb5595293886e433fde49dac004",
      "excerpts": [
        {
          "lines": "20–30",
          "verbatim": "    original = request['view']\n    memories = {m['id']:m for m in original['memories']}\n    trigger = request['trigger']\n    required = {trigger[k] for k in (\n        'memory_id','relay_source','self_model_required_source','experience_required34'\n    ) if trigger.get(k) is not None}\n    required.update(item['memory_id'] for item in trigger.get('batch',[]))\n    required.update(item['memory_id'] for item in trigger.get('attention',[]))\n    perception = trigger.get('local_perception',[])\n    if len(perception)>2 or any(p['memory_id'] not in memories for p in perception):\n        raise ValueError('Perception evidence is outside resident view')"
        },
        {
          "lines": "113–126",
          "verbatim": "    selected = set(memories) if mode=='full' else required.copy()\n    envelope,body = assemble(selected)\n    window = body['options']['num_ctx']\n    generation = body['options']['num_predict']\n    reserve = config.get('context_template_reserve',512)\n    target = (config.get('context_native_tokens',4096) if native else config.get('context_input_budget',4900)) if mode=='bounded' else window\n    recent_share = config.get('context_recent_percent',60)\n    if (type(reserve) is not int or reserve<256 or type(target) is not int or target<1\n        or type(recent_share) is not int or not 0<=recent_share<=100\n        or type(generation) is not int or generation<=0):\n        raise ValueError('Invalid context budget settings')\n    capacity = min(target,window-generation-reserve)\n    # An experimental metadata reserve is shared by both arms.\n    limit = capacity - (config.get('temporal_metadata_reserve',0) if native and mode=='bounded' else 0)"
        },
        {
          "lines": "179–197",
          "verbatim": "        def fill(candidates, ceiling, label):\n            nonlocal envelope,body,cost\n            for i in candidates:\n                if i in selected:\n                    continue\n                proposed,transport = assemble(selected|{i})\n                size = measure(transport)\n                if size<=ceiling:\n                    selected.add(i)\n                    envelope,body,cost = proposed,transport,size\n                    label.append(i)\n        # A selected read returns before optional background. Required evidence and limit stay fixed.\n        if config.get('requested_recall_first') and trigger.get('recall_origin')=='requested':\n            fill(recalled,limit,relevant)\n        fill([p['memory_id'] for p in perception],limit,relevant)\n        fill(reply_ids,limit,relevant)\n        fill(history_ids,limit,relevant)\n        fill(trigger.get('self_model_sources',[]),limit,relevant)\n        if native:"
        }
      ]
    },
    {
      "document": "village_zero/fair_attention.py",
      "file_sha256": "0eb922dcf08601d01b1dc70782c6a23dd0cd7ba0b552cfc7836c4e7e5c4b3145",
      "excerpts": [
        {
          "lines": "56–84",
          "verbatim": "def resident_order(world, order, budget):\n    tick = world.clock()[\"tick\"]\n    turns = world.rows(\"\"\"\n        SELECT agent, max(json_extract(request,'$.trigger.tick')) AS last_turn\n        FROM calls\n        WHERE json_extract(request,'$.contract') IN\n            ('busy','associative','reflection','managed_revision','cooperation')\n        GROUP BY agent\n    \"\"\")\n    last = {row[\"agent\"]: row[\"last_turn\"] for row in turns if row[\"last_turn\"] is not None}\n    budget = min(budget, world.config[\"max_social_per_tick\"]\n                 - sum(value == tick for value in last.values()))\n    if budget <= 0:\n        return []\n\n    deadline_aware = world.config.get(\"deadline_aware_fair_attention\", False)\n    candidates = []\n    for index, owner in enumerate(order):\n        if last.get(owner) == tick or not world.spatial_actions(owner):\n            continue\n        ready = pending(world, owner)\n        if not ready:\n            continue\n        for row in ready:\n            row[\"deadline\"] = deadline(world, row)\n        lead = personal_order(ready, tick, 1, deadline_aware)[0]\n        response = protect_response(world,owner,ready,tick)\n        if response is not None and not protect_waiting(tick):\n            lead = response"
        }
      ]
    },
    {
      "document": "temporal_experiment63.py",
      "file_sha256": "3a8d630c6f144546a890a1eb2254fc5787c933cf0367d4562476176359e5da72",
      "excerpts": [
        {
          "lines": "135–152",
          "verbatim": "    used = world.db.execute(\"\"\"SELECT count(DISTINCT agent) FROM calls\n        WHERE json_extract(request,'$.contract')=? AND json_extract(request,'$.trigger.tick')=?\"\"\",\n        (sim.spatial.contract,tick)).fetchone()[0]\n    for index in range(used,width):\n        world.sync_opportunities()\n        world.sync_attention()\n        available=resident_order(world,order,1)\n        first=floor(world,\"calls\")\n        results=sim.tick(limit=1)\n        rows=world.rows(\"SELECT id,agent,kind,applied,error,result FROM calls WHERE id>=? ORDER BY id\",(first,))\n        assert len(rows)==len(results)<=1\n        assert world.clock()[\"tick\"]==tick and world.state()[\"day\"]==day\n        if not rows:\n            break\n        assert available and rows[0][\"agent\"]==available[0]\n        attempts.append(dict(ordinal=index+1,rank=available,**rows[0]))\n    assert len({v[\"agent\"] for v in attempts})==len(attempts)\n    return attempts"
        }
      ]
    },
    {
      "document": "village_zero/social.py",
      "file_sha256": "b787e66ee053dbe9f5ab0f0e1eb4a2ab0ac1bbb22e04e86a6c6719a21aef9c27",
      "excerpts": [
        {
          "lines": "269–284",
          "verbatim": "    def apply_saved(self, call_id):\n        \"\"\"The only effect boundary for a recorded turn. Replays return its receipt.\"\"\"\n        w = self.world\n        call = w.db.execute('SELECT * FROM calls WHERE id=?',(call_id,)).fetchone()\n        if not call or call['error'] or call['response'] is None:\n            raise ValueError('Call has no applicable response')\n        request = json.loads(call['request'])\n        if request.get('contract')!=self.contract:\n            raise ValueError('Action contract mismatch')\n        if call['applied']:\n            return json.loads(call['result'])\n        agent = call['agent']\n        view, trigger = request['view'], request['trigger']\n        job = call['job_id']\n        try:\n            if job is not None:"
        },
        {
          "lines": "313–342",
          "verbatim": "                raise ValueError('Automatic relay must cite the incoming memory')\n            result = dict(action,call_id=call_id,accepted_messages=[])\n            with w.db:\n                if action['quest']:\n                    w.propose(agent, **action['quest'])\n                for message in action['messages']:\n                    if hasattr(w, 'send'):\n                        accepted = w.send(agent,message['to'],message['text'],message['sources'],call_id)\n                        result['accepted_messages'].append(accepted)\n                    else:\n                        w.memory(message['to'], 'message', message['text'], sender=agent,\n                                 parents=message['sources'], call_id=call_id)\n                reflection = action['reflection']\n                if reflection:\n                    before = view['attitude_to_player']\n                    delta = reflection['attitude_delta']\n                    if hasattr(w, 'attitude_delta'):\n                        delta = w.attitude_delta(agent, reflection['sources'], delta, call_id)\n                    after = max(-10, min(10, before + delta))\n                    w.db.execute('UPDATE agents SET attitude=? WHERE name=?', (after, agent))\n                    w.db.execute('INSERT INTO beliefs(agent,text,sources,delta,before_value,after_value,call_id) VALUES (?,?,?,?,?,?,?)',\n                        (agent, reflection['belief'], dump(reflection['sources']), reflection['attitude_delta'], before, after, call_id))\n                result.update(self.apply_extra(agent, trigger, view, extra, call_id))\n                if (service_lifecycle.enabled(w) and 'service_read' in result and 'tick' in trigger):\n                    service_lifecycle.register(w,call_id,agent,result['service_read'],trigger['tick'])\n                w.db.execute('UPDATE calls SET applied=1,result=? WHERE id=?',(dump(result),call_id))\n                self.finish_jobs(job,batch,result)\n            return result\n        except Exception as exc:\n            self._fail(call_id,exc)"
        },
        {
          "lines": "83–96",
          "verbatim": "        w = self.world\n        with w.db:\n            if kind=='llm' and w.db.execute(\"SELECT count(*) FROM calls WHERE kind='llm'\").fetchone()[0]>=w.config['max_calls']:\n                raise ValueError('Persistent LLM call budget exhausted')\n            if retry_of is not None:\n                w.db.execute(\"UPDATE calls SET error='Interrupted before response was saved' WHERE id=?\",(retry_of,))\n            cid = w.db.execute(\"\"\"\n                INSERT INTO calls(agent,request,job_id,kind,retry_of,response) VALUES (?,?,?,?,?,?)\n                \"\"\",(request['view']['resident'],json.dumps(request,ensure_ascii=False),job,kind,retry_of,\n                     dump(response) if response is not None else None)).lastrowid\n            from .attention_delivery import record\n            record(w,cid,request,'selected')\n            if service_lifecycle.enabled(w):\n                service_lifecycle.reserve(w,cid,request,kind)"
        }
      ]
    },
    {
      "document": "village_zero/everyday_rest.py",
      "file_sha256": "96fb9e8e083219d4e1d209a8005790bdf742ba5613d527fa40779310ee624d49",
      "excerpts": [
        {
          "lines": "40–63",
          "verbatim": "        if (row[\"operation\"]!=\"offer\" or row[\"event_id\"] in closed or actor not in row[\"residents\"]\n                or not row[\"tick\"]<=tick<row[\"expires_tick\"]):\n            continue\n        sender, recipient = row[\"residents\"]\n        peer = recipient if actor==sender else sender\n        if encounters.get(peer)==row[\"encounter_id\"] and world.together(actor,peer):\n            pending[peer] = row\n    waiting = any(row[\"actor\"]==actor for row in pending.values())\n    for peer, encounter in sorted(encounters.items()):\n        if not world.together(actor,peer):\n            continue\n        offer = pending.get(peer)\n        extra = dict(kind=\"leisure\",everyday=True,location=place,peer=peer,encounter_id=encounter)\n        if offer is None:\n            if not waiting:\n                options[f\"rest:offer:{peer}\"] = dict(extra,operation=\"offer\",duration_ticks=0,\n                    expires_tick=tick+OFFER_TICKS)\n            continue\n        if tick<=offer[\"tick\"]:\n            continue\n        extra.update(offer_id=offer[\"event_id\"],expires_tick=offer[\"expires_tick\"])\n        if actor==offer[\"actor\"]:\n            options[f\"rest:withdraw:{peer}\"] = dict(extra,operation=\"withdraw\",duration_ticks=0)\n        else:"
        }
      ]
    },
    {
      "document": "mid_tick_runner.py",
      "file_sha256": "b03ca66f4ca447a0ba7bca55a038bdff2f82c30965700c8f4f615b74ca04d83f",
      "excerpts": [
        {
          "lines": "97–118",
          "verbatim": "def unresolved(world):\n    return world.rows(\"SELECT * FROM calls WHERE applied=0 AND error IS NULL ORDER BY id\")\n\n\ndef watermark(world):\n    return tuple(world.db.execute(\"\"\"SELECT (SELECT max(id) FROM calls),\n                                      (SELECT max(id) FROM events)\"\"\").fetchone())\n\n\ndef settle(world, handler, journal, tick):\n    pending = unresolved(world)\n    if len(pending)>1:\n        raise RecoveryAbort(\"More than one unresolved decision in a single-writer world\")\n    for call in pending:\n        request = json.loads(call[\"request\"])\n        if request.get(\"contract\")!=handler.contract or request[\"trigger\"].get(\"tick\")!=tick:\n            raise RecoveryAbort(\"Cannot apply an unresolved decision outside its original tick\")\n        cid = call[\"id\"]\n        _, attempts = journal.attempts(cid,request)\n        try:\n            if call[\"response\"] is None:\n                if call[\"kind\"]!=\"llm\":"
        },
        {
          "lines": "25–38",
          "verbatim": "        self.db.row_factory = sqlite3.Row\n        self.db.execute(\"PRAGMA synchronous=FULL\")\n        self.db.executescript(\"\"\"\n            CREATE TABLE IF NOT EXISTS run (\n                id INTEGER PRIMARY KEY CHECK(id=1), lineage TEXT NOT NULL,\n                first_tick INTEGER NOT NULL, cap INTEGER NOT NULL,\n                ready_tick INTEGER, finished_tick INTEGER NOT NULL,\n                last_call INTEGER, last_event INTEGER);\n            CREATE TABLE IF NOT EXISTS attempt (\n                call_id INTEGER NOT NULL, sequence INTEGER NOT NULL,\n                request_sha256 TEXT NOT NULL, response TEXT, failure TEXT,\n                PRIMARY KEY(call_id,sequence), CHECK(response IS NULL OR failure IS NULL));\n        \"\"\")\n        try:"
        },
        {
          "lines": "51–67",
          "verbatim": "        return self.db.execute(\"SELECT * FROM run WHERE id=1\").fetchone()\n\n    def attempts(self, call_id, request):\n        key = sha256(json.dumps(request,ensure_ascii=False,separators=(\",\",\":\")).encode()).hexdigest()\n        rows = self.db.execute(\"SELECT * FROM attempt WHERE call_id=? ORDER BY sequence\",(call_id,)).fetchall()\n        if any(row[\"request_sha256\"]!=key for row in rows):\n            raise RecoveryAbort(f\"Request differs from journal for call {call_id}\")\n        return key,rows\n\n    @contextmanager\n    def provider(self, world, handler):\n        original = handler.llm.generate\n\n        def generate(request):\n            pending = unresolved(world)\n            if len(pending)!=1 or json.loads(pending[0][\"request\"])!=request:\n                raise RecoveryAbort(\"Model request has no unique matching reserved turn\")"
        },
        {
          "lines": "75–88",
          "verbatim": "                raise RecoveryAbort(\"Transport budget exhausted\")\n            with self.db:\n                self.db.execute(\"INSERT INTO attempt VALUES (?,?,?,NULL,NULL)\",(call_id,seq,key))\n            try:\n                response = original(request)\n            except Exception as exc:\n                with self.db:\n                    self.db.execute(\"UPDATE attempt SET failure=? WHERE call_id=? AND sequence=?\",\n                                    (f\"{type(exc).__name__}: {exc}\",call_id,seq))\n                raise\n            with self.db:\n                self.db.execute(\"UPDATE attempt SET response=? WHERE call_id=? AND sequence=?\",\n                                (dump(response),call_id,seq))\n            return response"
        }
      ]
    },
    {
      "document": "long_life_run.py",
      "file_sha256": "3c70bde215539e1b3b0e611fbbd29765f51411b822cc4c4d080adedc68513d1d",
      "excerpts": [
        {
          "lines": "81–107",
          "verbatim": "def recovery_check(root, configuration):\n    \"\"\"Reconcile a saved HTTP reply with its logical call before resuming a stopped run.\"\"\"\n    records = transport_records(root,configuration)\n    for key, entries in records.items():\n        if not entries:\n            continue\n        folder = root/key\n        with closing(immutable(folder/\"world.sqlite\")) as world, closing(\n                immutable(folder/\"transport.sqlite\")) as old:\n            cursor = dict(old.execute(\"SELECT * FROM run\").fetchone())\n            for (cid,seq), row in entries.items():\n                call = world.execute(\"SELECT * FROM calls WHERE id=?\",(cid,)).fetchone()\n                attempt = old.execute(\"SELECT * FROM attempt WHERE call_id=? AND sequence=?\",(cid,seq)).fetchone()\n                assert call and attempt and json.loads(call[\"request\"])[\"transport\"]==row[\"request\"]\n                if attempt[\"response\"] is not None:\n                    assert json.loads(attempt[\"response\"])==row.get(\"response\")\n        journal = TurnJournal(folder/\"transport.sqlite\",cursor[\"lineage\"],cursor[\"first_tick\"],cursor[\"cap\"])\n        with closing(journal.db), closing(immutable(folder/\"world.sqlite\")) as world:\n            for call in world.execute(\"SELECT * FROM calls WHERE applied=0 AND error IS NULL\"):\n                packet = json.loads(call[\"request\"])\n                _, attempts = journal.attempts(call[\"id\"],packet)\n                if not attempts or attempts[-1][\"response\"] or attempts[-1][\"failure\"]:\n                    continue\n                identity = call[\"id\"],attempts[-1][\"sequence\"]\n                if recorded := entries.get(identity):\n                    with journal.db:\n                        if \"response\" in recorded:"
        },
        {
          "lines": "152–163",
          "verbatim": "def validate_cohort(root, configuration, roots, dry):\n    logs = transport_records(root,configuration)\n    checks = []\n    for world in roots:\n        analyses = {}\n        origin = root/world/\"common\"/\"checkpoints\"/f\"tick-{configuration['warm']:03}.sqlite\"\n        for branch in (\"common\",\"A\",\"B\"):\n            key = f\"{world}/{branch}\"\n            folder = root/key\n            names = sorted(p.stem for p in (folder/\"checkpoints\").glob(\"*.json\"))\n            phase = configuration[\"plan\"][key]\n            expected = {f\"tick-{i:03}\" for i in range(phase[\"first\"]-1,phase[\"last\"]+1,configuration[\"block\"])}"
        }
      ]
    }
  ],
  "wire": "calls/1432.json",
  "model": "qwen3.8:27b",
  "request_options": {
    "temperature": 0.6,
    "seed": 6317006,
    "num_ctx": 16384,
    "num_predict": 460
  },
  "R06_A_config": {
    "model": "qwen3.8:27b",
    "context_native_tokens": 4096,
    "context_packing": "native",
    "max_social_per_tick": 1
  },
  "memory_model_and_scope": "See Architecture and boundaries, lines 31–37 and 53–59.",
  "stored_request_example": {
    "phase": "R06/A",
    "world_record": "world.sqlite, calls row 55, request",
    "resident": "gossip",
    "tick": 55,
    "canonical_logical_request_sha256": "5a357a1014d7bb047a1f8efd3d9b4298f25edfe13d663a7b6cac52d090485657",
    "journal_record": "transport.sqlite, attempt row for call 55, sequence 1",
    "transport_attempt": {
      "call_id": 55,
      "sequence": 1,
      "request_sha256": "5a357a1014d7bb047a1f8efd3d9b4298f25edfe13d663a7b6cac52d090485657",
      "has_saved_reply": 1,
      "has_failure": 0
    },
    "hash_method": "UTF-8 JSON of the reserved request, ensure_ascii=False and compact separators, preserving key order."
  }
}
