Skip to content

Commit 195c4c1

Browse files
authored
Consolidate typed execution, verification, and runtime ownership (#1276)
* refactor(operations): project typed outcomes at dispatch * refactor(verification): consolidate checker execution and identity * refactor(runtime): remove portfolio and storage facades * docs(architecture): codify the simplified ownership model
1 parent 1360962 commit 195c4c1

195 files changed

Lines changed: 5926 additions & 3654 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AGENTS.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,18 @@ publication binding only when inline transport is insufficient. Publication
113113
owns transport only; it does not own mathematical validation, applicability,
114114
provider selection, effects, parsing, or checker authority.
115115

116+
Do not introduce pass-through facades to make a dependency graph look cleaner.
117+
An aggregate may coordinate a public lifecycle or transaction, but it must not
118+
mirror every collaborator method, bounce callbacks back through itself, or keep
119+
private forwarding methods solely for tests. Call the concrete owner directly;
120+
extract a shared abstraction only when two production paths replace their older
121+
implementations in the same change.
122+
123+
Composition roots retain only resources needed after construction. Do not build
124+
or return nested installation reports, provider bags, or phase-result mirrors
125+
that production immediately discards. Keep an installation result only when a
126+
later production phase consumes that exact typed fact.
127+
116128
Construct wire envelopes only at the final capability or protocol projection.
117129
Mathematical functions, typed operation executors, artifact services, and
118130
checker services return their owned typed values or terminal states; they do
@@ -122,6 +134,11 @@ a domain-specific durable schema or parent closure, keep that publication in a
122134
narrow named domain publisher and pass its typed projection to the one final
123135
envelope constructor.
124136

137+
Measure expensive checker source and dependency identity at authorization and
138+
inside the bounded checker worker, not during catalog discovery, compatibility
139+
selection, or ordinary runtime startup. Registry reads validate persisted
140+
identity and authority; the execution boundary remeasures executable bytes.
141+
125142
At the MCP boundary, prefer MCP Python SDK 2.0 high-level typed returns. Return
126143
Pydantic result models directly and let the SDK derive the output schema,
127144
validate results, and populate `content` and `structured_content`. Use an

docs/explanation/architecture.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,10 @@ mathematical result and from verification authority.
180180

181181
`CapabilityResult` is a wire projection, not an in-process return type. Domain
182182
functions, operation executors, artifact services, and checker services return
183-
their owned typed values or terminal states. The final capability adapter
184-
constructs the wire envelope once, after publication has returned the complete
185-
artifact closure. Artifact-producing operations must not move storage writes
183+
their owned typed values or terminal states. The public dispatcher constructs
184+
the wire envelope once, after publication has returned the complete artifact
185+
closure; installed adapters return a typed projection rather than constructing
186+
the envelope themselves. Artifact-producing operations must not move storage writes
186187
into `OperationSpec.execute`; a domain-specific publisher may preserve an
187188
established durable schema and parent closure without expanding the generic
188189
publication policy.
@@ -214,6 +215,19 @@ subject, candidate, evidence, protocol, semantics, scope, certificate format,
214215
and checker identity. Independent checker execution does not import or call the
215216
producer, proposal, search, or evaluation path it certifies.
216217

218+
Checker identity comes from a versioned manifest for that checker, not from a
219+
digest of the whole Jacobian package. The manifest binds its exact entry point,
220+
separate checker and worker source closures, exact Python distributions, Python
221+
and provider runtime, passive contracts, and bounded-process policy. The worker
222+
admits only the declared first-party closure and manifest-bound third-party
223+
distributions, including imports requested dynamically during checker
224+
execution, and remeasures the complete
225+
manifest—including the current bytes of every indexed dependency file—around
226+
execution. Authorization performs the same measurement once; catalog and
227+
compatibility reads do not repeat that filesystem scan. A producer or unrelated
228+
checker edit therefore cannot change the identity, while a changed executable
229+
dependency cannot retain it.
230+
217231
`VerificationResult` is the internal typed outcome of that checker execution,
218232
not a generic mathematical result envelope. Capability adapters project it
219233
once into the ordinary operation response. Ordinary producers do not use it,
@@ -299,6 +313,13 @@ and checker authority. Remote authentication, tenants, admission, leases,
299313
eviction, and quarantine belong to a separate remote host and do not enter the
300314
local mathematical server.
301315

316+
Local artifact storage retains one concrete filesystem CAS with SQLite metadata.
317+
`ArtifactRepository` is its public aggregate; explicit transaction, blob, and
318+
metadata collaborators own the implementation. They are not interchangeable
319+
backend interfaces, and new storage abstractions require new workload evidence.
320+
The aggregate coordinates lifecycle and transactions; it does not mirror
321+
collaborator-private blob or recovery APIs.
322+
302323
MCP uses SDK-derived typed schemas and structured output. Pydantic result models
303324
are returned directly unless a genuine `ResourceLink`, custom metadata, or
304325
deliberate text projection requires an explicit MCP result. The two fixed tools

docs/how-to/deploy-remote-mcp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ is first used. This warms Lean and filesystem caches without delaying MCP
397397
startup.
398398

399399
Lean results are cached only for an exact content-addressed certificate and
400-
the currently active checker digest. The bounded in-memory cache holds 128
400+
the currently active checker implementation digest. The bounded in-memory cache holds 128
401401
entries; a changed proof, statement, environment, checker, or authorization
402402
state cannot reuse an entry. `math.find` for `lean.check` reports the
403403
cache policy and the MATHLIB warm-up state (`RUNNING`, `HEALTHY`, or

docs/reference/evaluations/evaluation-methods.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,11 @@ Representative groups include:
139139
- checker plan construction and bounded replay;
140140
- request-local and durable value transport;
141141
- MCP stdio and HTTP round trips; and
142-
- SQLite BLOB storage at 1 KiB, 100 KiB, 1 MiB, and 10 MiB with concurrency
143-
1, 4, and 16, including crash/restart and backup/restore.
142+
- retained filesystem-CAS storage at representative payload sizes and
143+
concurrency, including crash/restart, bounded reads, and backup/restore.
144+
145+
The disposable SQLite BLOB comparison is retained only as reproducible decision
146+
evidence. It is not a production backend or a routine benchmark dimension.
144147

145148
For Lean proof-state backend comparisons, run
146149
`benchmarks.tooling.lean_repl_backend_benchmark` as a pyperf cell for each

docs/reference/state-format.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Persistent state format
22

3-
The current and minimum supported state format is revision 8. Older stores are
3+
The current and minimum supported state format is revision 10. Older stores are
44
rejected before any migration code runs.
55

66
To recover data from an older store, keep that directory unchanged and open it
@@ -9,7 +9,10 @@ current version; Jacobian provides no cross-revision import bridge. Do not edit
99
`metadata.sqlite3` to change its revision—the migration ledger and state-format
1010
record are integrity boundaries.
1111

12-
Earlier migration definitions remain in source because existing revision-8
13-
ledgers bind their checksums. They do not define supported runtime services or
14-
an in-place upgrade path. New stores apply the complete ordered schema and
15-
record revision 8.
12+
Earlier migration definitions remain in source because migration ledgers bind
13+
their checksums. They do not define supported runtime services or an in-place
14+
upgrade path. Revisions 9 and 10 replace the broad checker-package digest with
15+
a versioned per-checker manifest that separates checker and worker source,
16+
records exact Python distributions, and produces one implementation digest;
17+
existing checker authorization rows are deliberately not reinterpreted. New
18+
stores apply the complete ordered schema and record revision 10.

docs/reference/testing-strategy.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,11 @@ Python identity, dependency files, native libraries/executables, and sandbox
218218
policy. Unrelated product changes must not alter checker identity; actual
219219
checker dependencies must.
220220

221-
Storage experiments remain an independent track. Compare SQLite BLOB behavior
222-
at 1 KiB, 100 KiB, 1 MiB, and 10 MiB with concurrency 1, 4, and 16, including
223-
crash/restart, backup/restore, and bounded reads. Performance evidence never
224-
substitutes for correctness.
221+
The completed storage experiment retained the filesystem CAS. Its disposable
222+
SQLite comparison remains reproducible evidence rather than a selectable
223+
backend. Storage regression tests therefore focus on the retained CAS's
224+
transaction coordination, quota recovery, bounded reads, crash/restart, and
225+
backup/restore behavior.
225226

226227
Run the disposable carrier comparison with:
227228

@@ -230,9 +231,9 @@ uv run python tools/benchmark_storage_blobs.py --iterations 16 \
230231
--output storage-blob-benchmark.json
231232
```
232233

233-
The spike is decision evidence, not a selectable runtime backend. Its rollback,
234-
restart, bounded-read, and backup/restore checks must all pass before latency or
235-
throughput can justify replacing the current two-store recovery protocol.
234+
The spike is historical decision evidence, not a selectable runtime backend or
235+
a second production abstraction. Re-run it only when new workload evidence
236+
justifies reopening the storage decision.
236237

237238
Hosting tests keep local and remote ownership separate. Remote authentication,
238239
tenants, admission, leases, eviction, and quarantine must not enter the local

pyproject.toml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
55
[project]
66
name = "jacobian"
77
version = "0.11.0"
8-
description = "A capability-first MCP workbench for executable mathematics"
8+
description = "Atomic mathematical tools for agents over MCP and Python"
99
readme = "README.md"
1010
requires-python = ">=3.12,<3.14"
1111
license = { text = "MIT" }
@@ -184,6 +184,26 @@ forbidden_modules = [
184184
"jacobian.value_references",
185185
]
186186

187+
[[tool.importlinter.contracts]]
188+
name = "Semantic operations do not depend on installed layers"
189+
type = "forbidden"
190+
source_modules = ["jacobian.operations"]
191+
forbidden_modules = [
192+
"jacobian.adapters",
193+
"jacobian.checker_operations",
194+
"jacobian.installation",
195+
"jacobian.operation_bindings",
196+
"jacobian.operation_installation",
197+
"jacobian.operation_projection",
198+
"jacobian.operation_publication",
199+
"jacobian.operation_runtime",
200+
"jacobian.persistence",
201+
"jacobian.portfolio",
202+
"jacobian.runtime",
203+
"jacobian.storage",
204+
"jacobian.verification",
205+
]
206+
187207
[[tool.importlinter.contracts]]
188208
name = "Finite-field values do not import private backends"
189209
type = "forbidden"

0 commit comments

Comments
 (0)