Repository navigation
Wave 1B: Post-v0.16.0 reader diagnostics, recall schema retention, & derivation privacy floors - #88
Merged
Merged
Conversation
Keep Process-based entry points out of the iOS memory-core module while retaining shared command, admission, and resource helpers on every platform. The launch implementations are unchanged on macOS and Linux. Co-Authored-By: Codex <noreply@openai.com>
Identify the required schema or decoded field that fails compatibility without logging stored values. Preserve reader errors, admission order and public APIs, and cover refusal categories and reads with retained writers. Co-Authored-By: Codex <noreply@openai.com>
Make the task-local closure infer its throwing behavior before Swift Testing expands the value assertions. Keep the same decode calls, expected values and empty-diagnostic check. Co-Authored-By: Codex <noreply@openai.com>
Exercise vector and full-text recall through real memory stores, then verify that independent readers retain the complete schema, saved rows and edges. Keep dedicated access-stat connection ownership and timeout assertions. Co-Authored-By: Codex <noreply@openai.com>
Open the dedicated access-stat connection with the owning store model list so recall does not replace dynamic-reader metadata with a Memory-only schema. Retain its short busy timeout and independent, transport-free connection. Co-Authored-By: Codex <noreply@openai.com>
Exercise real checked-BEGIN contention with the interactive timeout and a short-timeout control. Advance logical time from actual failure callbacks so the admission assertions do not depend on scheduler timing, and verify that a refused write leaves no row and the same handle recovers afterward. Co-Authored-By: Codex <noreply@openai.com>
Reduce the default BEGIN retry-admission budget to 4.5 seconds so the interactive two-second timeout cannot admit a third full wait. Preserve short-timeout retries, custom budgets and the no-replay transaction fence. Co-Authored-By: Codex <noreply@openai.com>
Retain a duplicate through successful preflight preparation to expose a lock surviving into resource sampling and final admission. Keep a separate control for the final worker lease until its retained duplicate closes. Co-Authored-By: Codex <noreply@openai.com>
Explicitly release the successful preflight lock before closing its file descriptor, so retained references cannot block final admission. Refuse admission if unlocking fails. Preserve the worker lease lifetime. Co-Authored-By: Codex <noreply@openai.com>
Each cross-process notification makes every Lattice instance run `SELECT ... FROM AuditLog WHERE id > ? ORDER BY id`. On a hub whose sqlite_stat1 was written while AuditLog was tiny, the planner believes the table holds 1 row and picks a full scan instead of a rowid seek. With a 2.77M-row AuditLog each notification cost 4-22 s, and a dozen MCP servers rescanning in turn held about 9 cores and 1 GB of RAM each. LatticeCore no longer runs ANALYZE at open, its close-time PRAGMA optimize does not repair these statistics, and an ANALYZE from another connection does not reach a connection that is already open. So the server now runs the bounded all-tables `PRAGMA optimize=0x10002` on a short-lived connection before Lattice opens the hub and the synced store. It costs about 30 ms on fresh statistics and a few seconds once on a stale hub. It takes the writer lock with BEGIN IMMEDIATE, so a concurrent commit costs at most the existing 2 s busy timeout, and a busy hub is skipped until the next start.
Review follow-up to the planner statistics refresh. - PRAGMA optimize's 0x10000 (all tables) bit arrived in SQLite 3.46. Older libraries ignore it and analyze nothing, which the refresh used to log as success. It now checks sqlite3_libversion_number() and reports unsupportedSQLite(version:) without touching the store. - refresh returns an Outcome (refreshed, skippedMissingFile, unsupportedSQLite, failed(code:message:)) so the startup log carries the SQLite error message. - Documented the real startup cost (busy wait plus a few seconds of analysis once on a stale hub, per store) and the one-time writer-lock hold. - Softened the close-time optimize claim: in practice it does not repair AuditLog (servers usually exit through _exit, and the cursor query uses no index). - Tests: remove temp databases, use #require for setup, rename the no-op test to refreshIsIdempotent and assert the statistics stay unchanged, add a test for the unsupported path, and skip plan assertions on old SQLite. Correction to the previous commit message: the ~1 GB RSS per server was the cache and mmap baseline, not a measured effect of the rescanning.
This was referenced Nov 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Consolidates the 8 post-
v0.16.0runtime diagnostic, schema retention, write-budget, lock-hygiene, and derivation privacy PRs (#14,#71,#73,#83,#84,#85,#86,#87) cleanly ontomain(26d8949->e2ca6987,22 files changed, +2,335 / -92) while preservingEngramModels/Memory.swiftwire compatibility at schema v3.Consolidated Fixes (8 PRs)
#14(PlannerStatistics.swift,Engram/main.swift): Runs boundedPRAGMA optimize=0x10002before the MCP server opens Lattice connections so multi-million-rowAuditLogcursor scans never degrade into full table scans, explicitly reporting SQLite< 3.46.#71+#73(Sources/EngramLattice/MemoryTools+DerivationPrivacy.swift,Clustering,Core,Episodes,Organize): Enforces derivation privacy floors andprivateGraphOnlywrite-target isolation acrosslocalLattice,syncedLattice, and all configuredgroupSpokesduringconsolidate,merge,organize, andend_episodeso private or narrower-audience replica memories are never leaked through a public handle — while keepingMemory.swiftwire-compatible at schema v3.#83(EngramMemoryCore/SubprocessSpawner.swift): GuardsFoundation.Processlaunch helpers behind#if os(macOS) || os(Linux)for clean iOS 18 compilation.#84(AgentMemoryReader.swift): Emits structured, content-free table/column reader compatibility diagnostics without leaking memory text.#85(MemoryTools+AccessStats.swift): Opens independent recall access-statistic handles withfor: localLattice.modelTypesrather thanMemory.selfalone so reader schemas remain intact acrossrecallupdates.#86(LatticeBeginRetry.swift): CapsdefaultTotalCapSecondsat4.5sto reserve response headroom within the6sinteractive busy-write budget.#87(SpawnAdmission.swift): Explicitly unlocks (flock(lease.fd, LOCK_UN)) completed preflight admission leases beforeclose(lease.fd)prior to resource sampling.Verification Gates
swift test --scratch-path /Users/jason/localdev/.build-cache/engram --jobs 4): 60/60 tests passed across 9 suites (0 failed) —PlannerStatisticsTests,DerivationPrivacyTests,DerivationReplicaPrivacyTests,EpisodePrivacyTests(44/44),SpawnAdmissionPreflightLeaseTests(2/2),AgentMemoryReaderDiagnosticTests,RecallReaderSchemaTests,AgentMemoryStoreTests, andInteractiveBusyBudgetTests(14/14).EngramModels/Memory.swiftpreserved at wire-compatible schema v3; zero.package(path:)overrides or.buildartifacts.Consolidates and supersedes
#14,#71,#73,#83,#84,#85,#86, and#87.