{"record":{"id":"2dc8ffc7612d9667","repo":"MemPalace/mempalace","slug":"event-event-id-r-not-found","errorCode":null,"errorMessage":"event {event_id!r} not found","messagePattern":"event (.+?) not found","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mempalace/logstream.py","lineNumber":595,"sourceCode":"        from_agent: str,\n        status: str = None,\n        body: str = \"\",\n    ) -> dict:\n        \"\"\"Append an ``event.ack`` referencing a prior event.\n\n        The target event is never mutated. The ack copies the target's\n        stream/room, copies its ``correlation_id`` (falling back to the\n        target's id so request/ack stay tied together), and routes back\n        to the target's ``from_agent``.\n        \"\"\"\n        event_id = _sanitize_routing(event_id, \"event_id\")\n        with self._lock:\n            conn = self._conn()\n            target = conn.execute(\n                \"SELECT rowid, * FROM events WHERE id = ?\", (event_id,)\n            ).fetchone()\n        if target is None:\n            raise ValueError(f\"event {event_id!r} not found\")\n\n        return self.append_event(\n            type=ACK_EVENT_TYPE,\n            stream=target[\"stream\"],\n            room=target[\"room\"],\n            from_agent=from_agent,\n            to_agent=target[\"from_agent\"],\n            correlation_id=target[\"correlation_id\"] or target[\"id\"],\n            status=status,\n            body=body,\n            metadata={\"ack_of\": event_id},\n        )\n\n    def submit_patch(\n        self,\n        content: str,\n        from_agent: str,\n        stream: str,","sourceCodeStart":577,"sourceCodeEnd":613,"githubUrl":"https://github.com/MemPalace/mempalace/blob/06cb6987f02610784fefbad4b2bd5d026d164ba6/mempalace/logstream.py#L577-L613","documentation":"ack_event(event_id=...) could not find an event with that id in the events table, so no acknowledgment can be created. The ack mechanism copies stream/room/correlation_id from the target event and routes back to its from_agent — with no target there is nothing to copy, hence the hard failure. The id is first normalized through _sanitize_routing (trim, length, control chars).","triggerScenarios":"ack_event with a typo'd or truncated id string; acking an event that lives in a different db_path/palace directory; acking an event that was never appended (producer and consumer disagree on the exchange); passing rowid instead of the 'evt_...' string id.","commonSituations":"Multi-replica setups where the consumer's logstream has not yet replicated the original event; ids mangled through log truncation or clipboard copy; tests against a fresh in-memory Logstream without seeding the target event.","solutions":["Use the id exactly as returned: evt = ls.append_event(...) then later ls.ack_event(evt['id'], ...).","Confirm the id exists first: ls.get_event(event_id) or ls.list_events(since_event_id=...) to see what is visible.","Ensure producer and consumer open the same database file (same palace directory) — replication must deliver the original event before acking."],"exampleFix":"// before\nls.ack_event(\"evt_20250814\", from_agent=\"windows-codex\")  # truncated id\n// after\nevt = ls.list_events(type=\"task.request\", correlation_id=\"task_123\")[0]\nls.ack_event(evt[\"id\"], from_agent=\"windows-codex\", body=\"started\")","handlingStrategy":"try-catch","validationCode":"def event_exists(ls, event_id) -> bool:\n    try:\n        return ls.get_event(event_id) is not None\n    except ValueError:\n        return False\n\nif not event_exists(ls, target_id):\n    raise LookupError(f\"cannot ack unknown event {target_id!r}; not yet replicated?\")","typeGuard":null,"tryCatchPattern":"try:\n    ack = ls.ack_event(event_id, from_agent=me, body=body)\nexcept ValueError as e:\n    if \"not found\" in str(e):\n        # target not replicated/visible yet — schedule a retry after sync\n        retry_later(event_id, from_agent=me, body=body)\n    else:\n        raise","preventionTips":["Carry the full 'evt_...' id from the append_event return value — never retype or truncate it.","In replicated deployments, ack only events fetched from the same database you ack into.","Treat ack-not-found as an expected sync race: retry with backoff instead of crashing the agent."],"tags":["logstream","ack","not-found","event-id"],"backgroundTag":null,"analyzedSha":"06cb6987f02610784fefbad4b2bd5d026d164ba6","analyzedAt":"2026-08-15T03:03:36.213Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}