~ knotless Search/
↑↓ move↵ open⇧↵ all results

zat.dev/zlay

atproto relay in zig · mirror of https://tangled.org/zat.dev/zlay

0
0
158 lines · 9.0 KB Raw History

Commit operation order review

Ordered inversion verifies both saved delete/create frames while retaining signature verification, inverse-operation CID checks and the final prevData comparison. This is evidence for a narrow compatibility change, not a production policy change or attribution of the earlier validation burst.

Inputs and method

The live pod zlay-79b89b6799-88mb8 still reported image ReleaseSafe-zio-3b107c8 and zero restarts when inspected on November 6. Its capture directory contained only proof-0.cbor and proof-1.cbor. Remote SHA-256 checks matched the existing local files:

InputSHA-256
proof-0.cbor14f632982d9feb14edefe4afa64545ecc29d922da4be8374cfbd0b13e858dbb8
proof-1.cbor8755d96a42f9e05f6d98fac1730e84caea20f52687d8dbb317ef75e01f95a82b
shadow-proof.cbor309e3069eaf232399723d5125e46fe40bd92f29f6588ee65030f99f3e5ddf391
counterfactual.cborfeded48e09677c81a61b5e2482e98fc2e249f762df581147482d329e82a5a6a6

The existing zig build proof-replay -Doptimize=ReleaseSafe tool reproduced the original rejection reasons and separately verified all four signatures.

A small offline probe called zat's real verifyCommitCar, loadCommitFromCAR, Mst.loadFromBlocks, invertOp and rootCid functions. It retained zlay's required prev fields for update/delete and ignored prev on create, as zlay currently does. Instead of normalizeOps, it iterated the original operation array backwards. It checked the signed DID and signature before inversion. There were no substituted MST, CAR or signature types.

The source checkout was zat 6045225; git diff v0.6.0 showed no differences in src/internal/repo/mst.zig or src/internal/repo/repo.zig, the modules implementing these operations in zlay's pinned dependency. The scratch probe is /tmp/zlay-proof-probe/ordered.zig, SHA-256 4fc4ec12bf27033665ce094059673d58a915560e2cd71a31e88f15bfb7bb6b05. That path is temporary, not durable evidence storage. Raw production packets remain in /data/proof-captures-20261106; nothing there was changed.

Results

InputExisting verifierReverse-order inversionForward-order controlCorrupted prevData control
Production proof-0InvalidCommitDiffMissingPrevMissingPrevMissingPrev
Production proof-1DuplicatePathpassInversionMismatchPrevDataMismatch
Shadow duplicate-path frameDuplicatePathpassInversionMismatchPrevDataMismatch
Normalized shadow updatepasspasspassPrevDataMismatch

The corrupted-root control flips one byte in the expected prevData after signature verification. It demonstrates that reverse-order acceptance still depends on reconstructing the asserted previous root. It does not claim to be an independent test of the signature verifier.

Both duplicate-path frames contain delete followed by create at the same path. Their signed data roots differ from prevData. Both creates also carry prev; the experiment preserves the existing parser's treatment of that field rather than adopting Indigo's stricter create-envelope check.

Production proof-0 is a separate case. Its signed data root equals prevData, and its update CID matches the value at that path in the signed MST. It omits the operation's prev. Hydrant skips such an operation and still compares the root, explaining how this no-op can pass its inversion path. This observation does not qualify changed-root updates with missing prev.

Policy implications

The sync specification and repository specification, checked November 6, describe operation inversion without an explicit blanket duplicate-path prohibition. Hydrant's implementation iterates the array backwards. This supports investigating ordered inversion; it is not proof of universal compatibility or a qualified Hydrant pipeline run.

A candidate change should preserve signature and root checks and add regression coverage for repeated updates, delete/create, create/delete, incorrect intermediate CIDs, incorrect prior roots and partial-tree behavior. Distinct-path partial CARs also need coverage: these four frames do not establish that replacing the existing sort is harmless for every operation shape. Missing proof fields and signing-key cache misses remain separate decisions. No runtime policy, dependency pin, deployment, or production state was changed in this review.

Local candidate

An isolated zat worktree at ~/tangled.org/zat.dev/zat.ordered-proof on codex/ordered-commit-inversion contains a candidate replacing the verifier's sort with reverse traversal. normalizeOps remains available with its existing behavior for other callers. No zlay dependency pin was changed.

Two new regression tests fail with DuplicatePath against the unmodified verifier. With the candidate, just check and all 604 tests pass. Coverage adds the two captured partial CARs, repeated updates, delete/create, create/delete, create/update and update/delete. Controls reject reversed order, incorrect intermediate CIDs, incorrect prior roots and a different signing key. Existing interop coverage also passes, including the real @atproto partial-CAR fixture. The atomic candidate commit was checked with git rebase --force-rebase -x 'just check && zig build test --summary all' origin/main. This is local candidate evidence, not a release, rollout, or universal partial-CAR qualification. In particular, this does not resolve policy for unsigned intermediate operations that cancel out to no net tree change.

Grafana cross-check

Read-only queries used the public Grafana Prometheus datasource API at https://zlay-metrics.waow.tech/api/datasources/proxy/uid/prometheus/api/v1/. The range covered 20:00 UTC through approximately 23:02 UTC on November 6, with 60-second samples of the dashboard's five-minute rates.

Over the final approximately 30 minutes, mean received traffic was 491 frames/s, validated traffic 145/s, skipped traffic 344/s, and rate-limit waits 0.76/s. The database queue was zero throughout those sampled points. The resolver queue ranged from roughly 94,900 to its 100,000 cap. A subsequent direct 30-minute counter-increase query gave 30.15% validated coverage and zero Sync 1.1 failures; the earlier range included one nonzero five-minute failure sample at its boundary. These are different sliding windows.

The same-time previous-day queries gave 49.20% validated coverage and a 99,997-entry resolver queue. The backlog predates the migration. Today's diagnostic restarts confound coverage comparisons. At the later instant, the signing-key cache held 113,660 entries, below its 250,000 cap; it would be incorrect to infer current signing-key-cache eviction pressure from the full resolver queue alone.

Low recorded proof failures do not establish broad verification when most frames are skipped on signing-key cache misses. Host-authority rejections and rate-limit waits are separate counters. The two proof-failure reason series sync_1_1 and commit_integrity overlap and must not be added together.

Resolver progress

At approximately 23:30 UTC the signing-key cache held 164,938 entries and its net growth measured 30.04 entries/s over 15 minutes and 30.15/s over 30 minutes. Five-minute validated coverage was then 37.78%. The resolver queue and dedup set both remained at 100,000. These windows show continued cache population, not a stuck resolver. They do not measure total resolution attempts, errors, or unique incoming demand.

The running deployment has no explicit RESOLVER_THREADS, VALIDATOR_CACHE_SIZE, or RELAY_PLC_URL entries, so source defaults select four workers, a 250,000-key cache and https://plc.directory. The cache remains below its cap. Each worker processes one DID at a time. The queue stores DIDs, not deferred frames; queue-full rejection silently refuses an additional DID, while the requesting frame has already been classified as skipped. A queued resolution never retrospectively verifies that frame.

Miss counters count frames, including repeated DIDs; they cannot be compared directly with cache-growth rates as if every miss required a distinct network request. The next useful diagnostics are unique queue admissions, duplicate admissions avoided, queue-full refusals, and resolution latency/outcomes. Current metrics cannot distinguish those quantities. The source also discards signing keys on every restart, and the host-authority path does not retain signing keys from the DID documents it already fetches.

Reusing a successfully resolved document's key and preserving bounded key state across restarts are candidates to evaluate separately. Persistence needs an explicit freshness, identity-event invalidation, rotation and recovery policy; neither option replaces the need to defer or repair unverified events. Increasing worker count alone does not address that acceptance policy. No resolver configuration, cache size, worker count or validation policy was changed here.