Skip to content

A Checkpoint Is an Intake Receipt

S5·E17 ·rootweaver · codex · reliability · memory

The dropped-work audit showed how much could depend on one closing action. A push, a ticket update or a review might be all that separated the code on disk from work the next session could pick up. The obvious answer was to capture more of each session. The harder question was what I would trust the next session to read back.

In late July I designed a small trial around that question. I wanted Codex sessions to leave evidence that could survive a change of context. A long conversation contains useful decisions alongside guesses, retries and instructions copied from other places. Importing it wholesale would move all those things into another system and hand the next session the same sorting job. The pilot was meant to produce bounded, attributable candidate facts and give me a way to judge whether they were worth keeping.

The engineer places one parcel at an intake counter with an archive behind glass

One intake slot opens for the new checkpoint. Older material stays separate. Conceptual illustration.

Keep the closing turn out of the upload path

The first decision was when to capture. A session-end hook looks like an obvious place to write a handover. It is close to the event, and the runner can point it toward the conversation file. The July evidence review found a weak fit for synchronous upload. A hook could stop early, its inputs could change with the harness, and a slow network would make the closing turn wait for a second system to acknowledge the handover.

I used a local scanner on a ten-minute interval as the authority for capture. A hook could signal something interesting, such as an approaching context compaction, while the background process owned finding eligible files, deciding whether they changed and dealing with failures. OpenAI’s Codex hooks documentation explains how hooks are triggered. The July record describes the design decision and the scanner in use. It does not establish that every proposed marker hook was installed or fired.

There was also an assumption hiding in the scheduler. Having a script that runs in an interactive shell does not establish that it will run under macOS’s background job manager, launchd. The operational baseline records that we changed the job to point explicitly at the Homebrew Python interpreter. The retained change is one line in the property list, the configuration file the scheduler reads. After the change the historical report observed a loaded job and a successful first run. That was evidence that the launcher worked in that environment. Scheduled-job exit status and per-checkpoint outcomes remained different signals.

Installing the scanner should leave the archive alone

A fresh scanner has no record of which sessions it has seen. If an absent cursor entry means “new,” the first scan could make the whole archive look eligible. I wanted the default installation to start with today’s work while explicitly accounting for the files that were already there.

The baseline operation therefore made a record of existing content without uploading it. The local state pairs each known session path with a hash, a fingerprint of the content, and a status. The initial baseline report recorded 630 entries. Those were deliberately held out of the pilot sample. The later handover recorded a different moving-state count. These are two observations of a changing cursor, and the records do not supply a row-by-row reconciliation.

Exact source excerpt. scripts/codex_memory_capture.py at 3ca2fe39, lines 226–232

        state["sessions"][str(path)] = {
            "checkpoint_hash": checkpoint.transcript_sha256,
            "retry_count": 0,
            "status": "baselined_not_uploaded",
        }
        seeded += 1
    _write_state(config.state_path, state)
Explain this code line by line
  1. Use the path as the local lookup key for this session record.
  2. Store the fingerprint of the version already on the machine.
  3. Start with zero failed upload attempts because this is a baseline operation.
  4. Give the entry a status that explicitly records that no upload took place.
  5. Close the state entry.
  6. Count one newly baselined record.
  7. Save the resulting local state after processing the inputs.

The normal scan compared the content it found with that stored hash. If it matched and there was no retry in progress, that pass recorded an unchanged result. For a changed version, the path still had to satisfy the scanner’s eligibility checks. The retained source checks whether a retry is due and, in the ordinary path, whether the session is idle or carries a pre-compaction signal. A dry run exits before the upload call.

Illustrative scanner input and outcome. Suppose session A is in the cursor with fingerprint a1. A scan sees a1 again and can skip it. The next time it sees a2, it knows this is a different version. If the conversation is still active and there is no pre-compaction signal, the scan records the active outcome. Once eligible, the upload can be attempted. If the request fails, a retry record retains the fingerprint, attempt count and earliest retry time. An unchanged fingerprint on that next pass cannot by itself suppress a pending retry.

This matters for both privacy and budgeting. Installing a capture feature should not be the same decision as importing historical sessions. The cursor gave the installer a way to separate those decisions and let us examine future checkpoints as a small, observable cohort.

The engineer sends an envelope through a designated records hatch

The intake hatch and the downstream review area have different jobs. Conceptual illustration.

The write boundary should have one job

The next choice was where to send an eligible checkpoint. Reusing the existing retrieval gateway would have avoided adding another service. That gateway was already a broad query surface with service credentials and routes that the capture feature did not need. I chose a dedicated capture gateway. Its job was to authenticate and bound the intake, extract against a restricted contract and submit the resulting envelope to the broker.

The raw conversation was present on the Mac and crossed into the capture gateway for processing. The narrower downstream promise was about what we wrote to the memory pipeline. At the point of extraction the gateway scrubbed the input, passed the redacted version to the extractor and validated the returned facts. A repository inspection shows how the durable envelope was built from the session and time identifiers, transcript fingerprint and byte count, structured facts and server metadata. The journal payload deliberately omitted the transcript body. That is a property of this path and contract. It does not prove the extracted facts were automatically correct, complete, safe to promote, or free of all sensitive content.

The engineering tradeoff was where to put authority after intake. The capture gateway was allowed to submit only to an ingress topic. A topic is a named stream of events in Apache Kafka. The downstream scope stamper assigned trusted ownership from server-side rules. The writer persisted the result under the quarantine policy. Quarantine meant the result was isolated from ordinary retrieval pending a review decision. The client supplied evidence about the session. It did not get to decide who could retrieve the result or apply it as memory.

From checkpoint to quarantine

Local scannerEligible checkpointCapture gatewayRedact and extractKafka brokerAcknowledge ingressScoped writerPersist in quarantine
Local scannerEligible checkpointCapture gatewayRedact and extractKafka brokerAcknowledge ingressScoped writerPersist in quarantine
Dotted paths show direction. The broker receipt confirms ingress. Trusted scope stamping occurs after ingress and before the writer persists the quarantined fact.

The receipt only reaches the broker

The upload client could hear back from the gateway before the downstream writer finished. That should be visible in the receipt. Otherwise an “uploaded” flag becomes easy to read as “stored” or even “ready to recall,” though the client observed none of those events.

Exact source excerpt. packages/memory-capture-gateway/src/memory_capture_gateway/main.py at 3ca2fe39, lines 240–250

        delivered = safe_produce(
            kafka_producer,
            INGRESS_TOPIC,
            json.dumps(payload, sort_keys=True, separators=(",", ":")).encode("utf-8"),
            key=checkpoint_id.encode("utf-8"),
        )
        if not delivered:
            metrics.rejected_total.labels(reason="broker_unavailable").inc()
            raise HTTPException(status_code=503, detail="broker unavailable")

        broker_accepted_at = clock()
Explain this code line by line
  1. Ask the broker helper to produce one event and return a delivery result.
  2. Pass the configured Kafka producer.
  3. Target the designated ingress topic.
  4. Serialise the structured payload into UTF-8 JSON.
  5. Use the checkpoint ID as the Kafka message key.
  6. Finish the produce call and receive its result.
  7. Check whether the helper reported successful delivery.
  8. Count a failure under the broker-unavailable reason when it did not.
  9. Return an HTTP failure to the uploader instead of promising acceptance.
  10. The blank line separates the failure exit from the success path.
  11. Record the time at which the successful broker delivery is acknowledged to the caller.

The next lines return the checkpoint ID and broker-acceptance time. A broker receipt says the ingress event was accepted. I still need writer evidence to say it reached quarantine and a later policy decision to say it may be recalled. In the opposite direction, the client’s “retry scheduled” state does not identify which layer rejected or lost the request. The scanner collected multiple network and HTTP exceptions into one retry branch. It kept enough information to try later, but the July version lost the distinction needed for diagnosis.

An example of what the source did not allow me to conclude was that a negative receipt meant no downstream event could exist in every possible failure. A client can lose the response after the server has accepted a request. Stable identity and downstream reconciliation matter precisely because transport success and durable state can diverge. The draft’s source inspection establishes where the receipt is returned. The historical records do not establish that every ambiguous retry case was tested or resolved.

A sealed paper packet sits beside open spaces on a train table

An accepted item and an unresolved handover leave different evidence. Conceptual illustration.

One canary answered a narrow question

The late-July operational baseline reported one bounded canary, a small test event passed through the real path. The report counted one captured session, one provenance-only round and one quarantined fact. The provenance round anchored the checkpoint evidence. The fact remained in quarantine, and the report observed zero consumer lag at reconciliation. That was enough to establish an important first delivery path for that sample.

July evidenceWhat it supportedWhat still needed evidence
One session and one provenance-only roundThe captured sample acquired durable provenanceEvery candidate takes the same path under load
One quarantined fact, zero outside quarantineContainment for the observed sampleFactual precision, recall and a promotion decision
630 baseline records in the initial inspectionThe archive was accounted for without turning it into a historical upload batchA natural cohort of eligible new or changed sessions
Six retries in the later local snapshotSome candidate attempts remained unresolvedWhich boundary failed, whether a receipt existed, and how those attempts ended
Healthy workload and health endpoint, plus a firing scrape alertDifferent observation paths gave different answersWhether the monitoring collector could reach the scrape target

That last row is familiar from the earlier ingestion story. A process can be ready and a request can succeed over one route while a monitor fails over another. The later handover records a successful health endpoint and a failing Prometheus scrape target. Prometheus’s jobs and instances documentation explains how a monitored endpoint gets its own scrape status. The handover treated the discrepancy as a separate networking and discovery question. It did not give me a reason to reclassify it as a confirmed failure of the capture path or to say the alert was fixed.

Deployment came before the quality decision

I directed the trial toward a small natural sample of new or changed sessions. Agents helped implement the scanner, gateway and evaluation tools. My decision was that a working transport would earn a quality review, with any move into ordinary memory requiring a separate decision. The report planned a cohort of 10 to 20 sessions. It did not claim it collected and labelled that cohort.

Precision asks what share of extracted facts a human considers correct. Recall asks what share of the reference facts the extractor found. Duplicate rate and review time matter because a system can retrieve useful facts while still costing more human work than the handovers it replaces. The retained evaluator also computes uncertainty for observed proportions. As an illustration, four correct candidates out of five would be 80 percent precision for that tiny labelled example. The evaluator’s Wilson interval is about 38 to 96 percent. That width is a useful reminder of how easy it is to overread a small sample. The four-out-of-five example is explanatory arithmetic and was never an observed pilot result.

The July record kept the proposal stage blocked as well. The existing review credential could apply decisions. Putting a “proposal-only” label on a process that used it would leave the process with the power to do more. A separate identity and authority boundary had to be designed before automatic proposals could be considered. That is an architectural lesson I could carry forward even while extraction quality was still an open question.

What I would keep

  • Start the scanner from a deliberate baseline. Treat a historical import as its own decision, with its own scope and evidence.
  • Give acknowledgements names that match the boundary they prove. Broker acceptance, writer persistence, quarantine and approval describe different events.
  • Preserve retry context in a form that supports diagnosis without exposing the conversation. A retry timestamp can be enough for scheduling and still be insufficient for investigation.
  • Make the first quality decision from a reviewed sample. Keep uncertain evidence visible enough that a small canary cannot silently become a permission to promote.

The next engineering records ask a closely related question. If a later agent can recover evidence of what happened, how should the system decide which agent is allowed to act on the work? The following work began to put ownership and the right to make changes behind a separate control-plane boundary.

Glossary and primary references

Hook

A command triggered by a harness event.

Primary reference

Checkpoint

A versioned capture of eligible session evidence.

Primary reference

Content hash

A fingerprint of specific bytes.

Primary reference

Kafka topic

A named broker stream used to move events between components.

Primary reference

Broker acceptance

An observed publish acknowledgement, separate from consumption and downstream storage.

Primary reference

Quarantine

Pilot isolation from ordinary retrieval while a candidate awaits a separate policy decision.

Primary reference

Scrape target

An endpoint a Prometheus instance attempts to collect metrics from.

Primary reference