diff --git a/.github/lexlean-revision b/.github/lexlean-revision index 954a4a8..016afb7 100644 --- a/.github/lexlean-revision +++ b/.github/lexlean-revision @@ -1 +1 @@ -2aced32e0f9c1ca0cf160f150a04819dedb4fc04 +b0e40add3b573a7040d27a6dd67858db89838199 diff --git a/AGENTS.md b/AGENTS.md index 3df1efb..edcf65c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -130,7 +130,13 @@ command/attestation reads. Its accepted outcome is validated report data; `ResearchProof` promotes it only after `CandidateBinding` recomputes the candidate semantic identity and compares the audited declaration's actual type with the requested contextual goal. `ResearchRunner.Event.reviewed` refuses checked -answers; submit proof jobs through `Event.proof`. The binding schema encodes the +answers; submit constructed candidates through `Event.candidate`. +`ResearchCandidate` owns the local `lexlean snapshot` process and output read, +reconstructs the full compiler IR with `CompilerSnapshot`, derives verification +pins and preflights the exact goal before entering `ResearchProof`. Snapshot +metadata is not a proof. Its caller still owns candidate construction, the +isolated project and imported library snapshot. `Event.proof` remains the +internal typed entry for already-owned candidate data. The binding schema encodes the inspected source type and closed target as core arenas in the sequent; source inspection must establish their origin and snapshot before dispatch. Maintenance reports have a separate result kind. Cancellation consumes the diff --git a/README.md b/README.md index f54fd02..af6d9c4 100644 --- a/README.md +++ b/README.md @@ -298,11 +298,12 @@ step roots can export a generated executable with explicit file/process effects and child cleanup; pure roots remain libraries. The API imports `LexLeanStd.Host` from the pinned source package; its local `Host` module contains only the application harness. The attention catalog -covers all 60 application and library modules. `ResearchRunner` connects the +covers all 64 application and library modules. `ResearchRunner` connects the controller to the local-tool supervisor in `ResearchExecution`: it binds each job to the outstanding request, drains cancelled host requests, preserves child ownership on cleanup failure, and requires report review after a successful process exit. External checked answers are refused: proof jobs use the owned +`ResearchCandidate` lifecycle, which obtains an owned local compiler snapshot before starting the `ResearchProof` verifier. Maintenance reports must cover the requested sources. Dependency changes invalidate both active work and remembered evidence. @@ -311,7 +312,14 @@ resource limits, exact tool identities, declaration axiom checks and module kernel-replay records. The decoder recomputes the attestation content identity; `ResearchVerification` owns the fixed local verify job, reads its command output before the matching attestation, and returns a receipt only after decoding it. -Cancellation drains pending reads; failed process cleanup retains ownership. +Cancellation drains pending reads; unexpected replies halt dispatch with ownership +retained, as do failed process cleanups. +`CompilerSnapshot` reconstructs the full linked IR and exact lexicon closure from +`lexlean snapshot`, checks the compiler and recomputes its semantic identity. +`ResearchCandidate` owns that command and output read, derives the verification +pins, checks the requested contextual goal, and starts verification in the same +isolated project. A snapshot alone is metadata; only the subsequent verifier can +produce proof evidence. Cancellation cannot cross the handoff into verification. `ResearchProof` then binds the receipt to the candidate's actual native declaration. `ArtifactIdentity` recomputes the semantic identity from canonical linked IR and lexicon closure; `CandidateBinding` selects the unique audited theorem and @@ -324,6 +332,9 @@ UTF-8 chunk, parser-state and SHA-256 block facts keep the complete report acceptance proof compositional; lifecycle traces reuse that checked receipt and verify rejection, cancellation, ownership and terminal behavior. +`rule30-api/production/research-request.json` exports the research controller, +catalog initializer, and runner `begin`/`step` component libraries. + Native application wiring, source inspection into the binding schema, strategy candidate construction and durable publication are still required for the new runner to replace the legacy engine. CI and runtime diff --git a/Rule30-Core.pdf b/Rule30-Core.pdf index 3ec8bc1..b156e22 100644 Binary files a/Rule30-Core.pdf and b/Rule30-Core.pdf differ diff --git a/Rule30-Observations.pdf b/Rule30-Observations.pdf index 222151e..2ffd21a 100644 Binary files a/Rule30-Observations.pdf and b/Rule30-Observations.pdf differ diff --git a/Rule30-Paper.pdf b/Rule30-Paper.pdf index fb007df..52502b5 100644 Binary files a/Rule30-Paper.pdf and b/Rule30-Paper.pdf differ diff --git a/pdf-manifest.json b/pdf-manifest.json index 5dd0e77..80b38d2 100644 --- a/pdf-manifest.json +++ b/pdf-manifest.json @@ -1,18 +1,18 @@ { "documents": { "Core": { - "pdf_sha256": "f479fa1dbee863116bb577217ebbc22429bca7e117d25ae1d47188d6080ff122", + "pdf_sha256": "d9c44a5241f29408df06c5cc3c2c8b3a3f873f1e7408b87d9066b3b63bc9e147", "tex_sha256": "a7cd1807077baa1d1ca34015faf500a24477991859427f4db646e5f230fe54e2" }, "Observations": { - "pdf_sha256": "de987d0c3a8eea79bbfe5c95b8254eeb1b65f1b5218ff7f6a54096ac719f3f45", + "pdf_sha256": "ca4906ef5921402090a9530bb4c32048d156ab63a4ab128d774c36d6fa9ccc1f", "tex_sha256": "056820f37ac40133e341f46ad6c81125e35981150a1cc86f2063faad3f26fbd4" }, "Paper": { - "pdf_sha256": "dba47573d0d811503185ba2b379a3e6de85e4d403ddae126643c2e408d0e6e28", + "pdf_sha256": "8dac918f7fe4faed24c3a2815097e36c13b37d9ba2b66fcd4ff9b84f902d318c", "tex_sha256": "000f988561d9621f9ba2f9a99aba971670864367ebd336e6fbad0e1f71da01cb" } }, - "generated_at_utc": "2026-11-04T20:49:52.508527+00:00", - "source_digest": "499bcf9d5fb81dcc7379fb536b87ae6caf13f9ac89db23f3996934a9bc5ca816" + "generated_at_utc": "2026-11-04T23:37:57.002459+00:00", + "source_digest": "ee78d0baa7a86567d7f9fdfa5ddd2893f4641cfe14bee69bdaaa4e4c6c5f9d47" } diff --git a/rule30-api/lexlean.lock b/rule30-api/lexlean.lock index 39dd991..2724b38 100644 --- a/rule30-api/lexlean.lock +++ b/rule30-api/lexlean.lock @@ -1,7 +1,7 @@ spec = "lexlean/lock/2" language = "1.2" compiler_semantics = "b9816b388a3eb1800179f96aa9bc789620a46d7a7132f1b52ee9fa404c2092f7" -project_config_sha256 = "f051b3f72b219df5ee4ee3276311bb8dd0e4211878f6904aa411974333c29226" +project_config_sha256 = "f0d83d368ddcf856d8997e460d5c121390f8118cef37f56e18c5a2e68996beb1" lean_toolchain = "leanprover/lean4:v4.32.1" [[workspace_file]] diff --git a/rule30-api/lexlean.toml b/rule30-api/lexlean.toml index 0cd27cc..f379419 100644 --- a/rule30-api/lexlean.toml +++ b/rule30-api/lexlean.toml @@ -3,7 +3,7 @@ name = "rule30-api" language = "1.2" module_prefix = "Rule30Api" source_roots = ["src", "stdlib"] -entrypoints = ["src/Api.lex.tex", "src/Application.lex.tex", "src/Architecture.lex.tex", "src/ArtifactIdentity.lex.tex", "src/ArtifactIdentityTraces.lex.tex", "src/Audit.lex.tex", "src/BindingFixture.lex.tex", "src/CandidateBinding.lex.tex", "src/CandidateBindingTraces.lex.tex", "src/Convert.lex.tex", "src/CoreBinding.lex.tex", "src/CoreBindingTraces.lex.tex", "src/Discovery.lex.tex", "src/Engine.lex.tex", "src/Host.lex.tex", "src/Hypotheses.lex.tex", "src/Json.lex.tex", "src/JsonCanonical.lex.tex", "src/JsonCanonicalTraces.lex.tex", "src/JsonTraces.lex.tex", "src/Observer.lex.tex", "src/Presentation.lex.tex", "src/R30.lex.tex", "src/R30Traces.lex.tex", "src/R30TracesClaims.lex.tex", "src/R30TracesForms.lex.tex", "src/R30TracesRegister.lex.tex", "src/Register.lex.tex", "src/Research.lex.tex", "src/ResearchCatalog.lex.tex", "src/ResearchExecution.lex.tex", "src/ResearchExecutionTraces.lex.tex", "src/ResearchProof.lex.tex", "src/ResearchProofTraces.lex.tex", "src/ResearchRunner.lex.tex", "src/ResearchRunnerTraces.lex.tex", "src/ResearchTraces.lex.tex", "src/ResearchVerification.lex.tex", "src/ResearchVerificationTraces.lex.tex", "src/Rule30Core.lex.tex", "src/Sequences.lex.tex", "src/Standards.lex.tex", "src/Toml.lex.tex", "src/VerificationCommandFixtures.lex.tex", "src/VerificationHashFixtures.lex.tex", "src/VerificationJsonData.lex.tex", "src/VerificationJsonFixtures.lex.tex", "src/VerificationJsonSteps0.lex.tex", "src/VerificationJsonSteps1.lex.tex", "src/VerificationJsonSteps2.lex.tex", "src/VerificationJsonSteps3.lex.tex", "src/VerificationReport.lex.tex", "src/VerificationReportTraces.lex.tex", "src/VerificationUtf8Fixtures.lex.tex"] +entrypoints = ["src/Api.lex.tex", "src/Application.lex.tex", "src/Architecture.lex.tex", "src/ArtifactIdentity.lex.tex", "src/ArtifactIdentityTraces.lex.tex", "src/Audit.lex.tex", "src/BindingFixture.lex.tex", "src/CandidateBinding.lex.tex", "src/CandidateBindingTraces.lex.tex", "src/CompilerSnapshot.lex.tex", "src/CompilerSnapshotTraces.lex.tex", "src/Convert.lex.tex", "src/CoreBinding.lex.tex", "src/CoreBindingTraces.lex.tex", "src/Discovery.lex.tex", "src/Engine.lex.tex", "src/Host.lex.tex", "src/Hypotheses.lex.tex", "src/Json.lex.tex", "src/JsonCanonical.lex.tex", "src/JsonCanonicalTraces.lex.tex", "src/JsonTraces.lex.tex", "src/Observer.lex.tex", "src/Presentation.lex.tex", "src/R30.lex.tex", "src/R30Traces.lex.tex", "src/R30TracesClaims.lex.tex", "src/R30TracesForms.lex.tex", "src/R30TracesRegister.lex.tex", "src/Register.lex.tex", "src/Research.lex.tex", "src/ResearchCandidate.lex.tex", "src/ResearchCandidateTraces.lex.tex", "src/ResearchCatalog.lex.tex", "src/ResearchExecution.lex.tex", "src/ResearchExecutionTraces.lex.tex", "src/ResearchProof.lex.tex", "src/ResearchProofTraces.lex.tex", "src/ResearchRunner.lex.tex", "src/ResearchRunnerTraces.lex.tex", "src/ResearchTraces.lex.tex", "src/ResearchVerification.lex.tex", "src/ResearchVerificationTraces.lex.tex", "src/Rule30Core.lex.tex", "src/Sequences.lex.tex", "src/Standards.lex.tex", "src/Toml.lex.tex", "src/VerificationCommandFixtures.lex.tex", "src/VerificationHashFixtures.lex.tex", "src/VerificationJsonData.lex.tex", "src/VerificationJsonFixtures.lex.tex", "src/VerificationJsonSteps0.lex.tex", "src/VerificationJsonSteps1.lex.tex", "src/VerificationJsonSteps2.lex.tex", "src/VerificationJsonSteps3.lex.tex", "src/VerificationReport.lex.tex", "src/VerificationReportTraces.lex.tex", "src/VerificationUtf8Fixtures.lex.tex"] build_root = ".lexlean" lockfile = "lexlean.lock" lean_workspace = "." @@ -34,7 +34,7 @@ kind = "path" path = "lexlean-stdlib" [limits] -max_file_bytes = 6291456 +max_file_bytes = 8388608 max_total_source_bytes = 67108864 max_primitive_atoms = 2000000 max_token_lattice_edges = 4000000 diff --git a/rule30-api/production/research-request.json b/rule30-api/production/research-request.json index 6dbd0cb..ac83e04 100644 --- a/rule30-api/production/research-request.json +++ b/rule30-api/production/research-request.json @@ -14,6 +14,16 @@ "package": {"name": "rule30_research_initial", "version": "0.1.0"}, "root": "Rule30Api.ResearchCatalog.initial", "targets": [{"digest": "0f5802ea18121b6a7a0d03e999589ce4e5ae812dc2a358432c1bf024a8e53f9f", "id": "rust-std"}] + }, + { + "package": {"name": "rule30_research_runner_begin", "version": "0.1.0"}, + "root": "Rule30Api.ResearchRunner.begin", + "targets": [{"digest": "0f5802ea18121b6a7a0d03e999589ce4e5ae812dc2a358432c1bf024a8e53f9f", "id": "rust-std"}] + }, + { + "package": {"name": "rule30_research_runner_step", "version": "0.1.0"}, + "root": "Rule30Api.ResearchRunner.step", + "targets": [{"digest": "0f5802ea18121b6a7a0d03e999589ce4e5ae812dc2a358432c1bf024a8e53f9f", "id": "rust-std"}] } ], "spec": "lexlean/production-request/1" diff --git a/rule30-api/src/CompilerSnapshot.lex.tex b/rule30-api/src/CompilerSnapshot.lex.tex new file mode 100644 index 0000000..c58831c --- /dev/null +++ b/rule30-api/src/CompilerSnapshot.lex.tex @@ -0,0 +1,84 @@ +\begin{lexlean}{CompilerSnapshot} +\useglossary{lexlean.std.bool@1.2.0} +\useglossary{lexlean.std.nat@1.2.0} +\importmodule{Json} +\importmodule{Toml} +\importmodule{CoreBinding} +\importmodule{ArtifactIdentity} +\importmodule{CandidateBinding} +\importmodule{VerificationReport} +\title{Boolean} +\begin{semanticmodule} + +definition{ + name: contract, + parameters: [], + result: String, + body: "A local lexlean snapshot exposes the public semantic snapshot, not the linked IR itself. Reconstruct linked IR from each module's full linked_ir value in snapshot order and retain the exact envelope lexicon_closure. Recompute the language 1.2 semantic identity against the expected compiler before deriving verification pins. A decoded snapshot is candidate metadata, never proof evidence. Its authority requires the caller to own the local snapshot invocation and subsequent verification in the same isolated project; the verified report must match the derived source and semantic identities. Imported library ownership remains part of the research snapshot boundary.", + axioms: [], + executable: true +} + +structure{ + name: Metadata, + type_parameters: [], + parameters: [], + fields: [{name: source, type: Bytes}, {name: semantic, type: Bytes}, {name: binding, type: CandidateBinding::Input}] +} + +definition{ + name: modules, + parameters: [rows : (List Json::Value), fuel : Nat], + result: (Option (List Json::Value)), + body: (match rows | List.nil => (ctor Option.some [(List Json::Value)] (nil Json::Value)) | List.cons head tail => (match fuel | Nat.zero => (ctor Option.none [(List Json::Value)]) | Nat.succ more => (match (CoreBinding::get head 0x6c696e6b65645f6972) | Json::Value.object entries => (match (modules tail more) | Option.none => (ctor Option.none [(List Json::Value)]) | Option.some rest => (ctor Option.some [(List Json::Value)] (cons (ctor Json::Value.object entries) rest))) | Json::Value.null => (ctor Option.none [(List Json::Value)]) | Json::Value.boolean b => (ctor Option.none [(List Json::Value)]) | Json::Value.number n => (ctor Option.none [(List Json::Value)]) | Json::Value.string s => (ctor Option.none [(List Json::Value)]) | Json::Value.array a => (ctor Option.none [(List Json::Value)])))), + axioms: [], + recursive_argument: rows, + executable: true +} + +definition{ + name: linked, + parameters: [rows : (List Json::Value)], + result: Json::Value, + body: (ctor Json::Value.object (cons (0x73706563, (ctor Json::Value.string 0x6c65786c65616e2f6c696e6b65642d69722f31)) (cons (0x6d6f64756c6573, (ctor Json::Value.array rows)) (nil (Bytes * Json::Value))))), + axioms: [], + executable: true +} + +definition{ + name: bind, + parameters: [value : Json::Value, compiler : Bytes, rows : (List Json::Value), maxBytes : Nat, maxSteps : Nat], + result: (Option Metadata), + body: (match (modules rows maxSteps) | Option.none => (ctor Option.none [Metadata]) | Option.some content => (let input : CandidateBinding::Input := (record CandidateBinding::Input {linked := (linked content), lexicon := (CoreBinding::get value 0x6c657869636f6e5f636c6f73757265)}); (match (ArtifactIdentity::semantic compiler (project input linked) (project input lexicon) maxBytes maxSteps) | Option.none => (ctor Option.none [Metadata]) | Option.some meaning => (if (Toml::sameBytes meaning (VerificationReport::bytes (CoreBinding::get value 0x73656d616e7469635f6964))) then (ctor Option.some [Metadata] (record Metadata {source := (VerificationReport::bytes (CoreBinding::get value 0x736f757263655f6964)), semantic := meaning, binding := input})) else (ctor Option.none [Metadata]))))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: metadata, + parameters: [value : Json::Value, compiler : Bytes, maxBytes : Nat, maxSteps : Nat], + result: (Option Metadata), + body: (if ((Toml::sameBytes (VerificationReport::bytes (CoreBinding::get value 0x73706563)) 0x6c65786c65616e2f73656d616e7469632d736e617073686f742f32) && ((Toml::sameBytes (VerificationReport::bytes (CoreBinding::get value 0x6c616e6775616765)) 0x312e32) && ((Toml::sameBytes (VerificationReport::bytes (CoreBinding::get value 0x636f6d70696c65725f73656d616e746963735f6964)) compiler) && (VerificationReport::digest (VerificationReport::bytes (CoreBinding::get value 0x736f757263655f6964)))))) then (match (CandidateBinding::array (CoreBinding::get value 0x6d6f64756c6573)) | Option.none => (ctor Option.none [Metadata]) | Option.some rows => (bind value compiler rows maxBytes maxSteps)) else (ctor Option.none [Metadata])), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: decode, + parameters: [source : Bytes, compiler : Bytes, maxBytes : Nat, maxDepth : Nat, maxSteps : Nat], + result: (Option Metadata), + body: (match (Json::parse source maxBytes maxDepth) | Result.error problem => (ctor Option.none [Metadata]) | Result.ok value => (metadata value compiler maxBytes maxSteps)), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: features, + parameters: [], + result: (List String), + body: (cons "local-compiler-snapshot-decoding" (cons "full-linked-ir-reconstruction" (cons "exact-lexicon-closure" (cons "compiler-and-semantic-identity" (cons "bounded-module-decoding" (cons "metadata-is-not-proof" (nil String))))))), + axioms: [], + executable: true +} +\end{semanticmodule} +\end{lexlean} diff --git a/rule30-api/src/CompilerSnapshotTraces.lex.tex b/rule30-api/src/CompilerSnapshotTraces.lex.tex new file mode 100644 index 0000000..78044ac --- /dev/null +++ b/rule30-api/src/CompilerSnapshotTraces.lex.tex @@ -0,0 +1,92 @@ +\begin{lexlean}{CompilerSnapshotTraces} +\useglossary{lexlean.std.bool@1.2.0} +\useglossary{lexlean.std.nat@1.2.0} +\importmodule{Json} +\importmodule{Toml} +\importmodule{CoreBinding} +\importmodule{CandidateBinding} +\importmodule{CompilerSnapshot} +\title{Boolean} +\begin{semanticmodule} + +definition{ + name: compiler, + parameters: [], + result: Bytes, + body: 0x31313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131, + axioms: [] +} + +definition{ + name: snapshot, + parameters: [], + result: Bytes, + body: 0x7b22636f6d70696c65725f73656d616e746963735f6964223a2231313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131222c226c616e6775616765223a22312e32222c226c657869636f6e5f636c6f73757265223a7b7d2c226d6f64756c6573223a5b5d2c2273656d616e7469635f6964223a2231323832343634323638663461333466653233396462666237636236643864366436633235316234346639643865373738316635643862343532353432633039222c22736f757263655f6964223a2232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232222c2273706563223a226c65786c65616e2f73656d616e7469632d736e617073686f742f32227d0a, + axioms: [] +} + +definition{ + name: row, + parameters: [name : Bytes], + result: Json::Value, + body: (ctor Json::Value.object (cons (0x6e616d65, (ctor Json::Value.string 0x646973706c6179)) (cons (0x6c696e6b65645f6972, (ctor Json::Value.object (cons (0x6e616d65, (ctor Json::Value.string name)) (cons (0x7469746c65, (ctor Json::Value.string 0x6b657074)) (nil (Bytes * Json::Value)))))) (nil (Bytes * Json::Value))))), + axioms: [] +} + +theorem{ + name: fullLinkedValuesKeepTheirOrder, + parameters: [], + statement: ((match (CompilerSnapshot::modules (cons (row 0x61) (cons (row 0x62) (nil Json::Value))) 2) | Option.none => false | Option.some rows => (match rows | List.nil => false | List.cons a rest => (match rest | List.nil => false | List.cons b others => ((Toml::sameBytes (match (CoreBinding::get a 0x6e616d65) | Json::Value.string s => s | Json::Value.null => 0x | Json::Value.boolean v => 0x | Json::Value.number n => 0x | Json::Value.array x => 0x | Json::Value.object o => 0x) 0x61) && ((Toml::sameBytes (match (CoreBinding::get b 0x6e616d65) | Json::Value.string s => s | Json::Value.null => 0x | Json::Value.boolean v => 0x | Json::Value.number n => 0x | Json::Value.array x => 0x | Json::Value.object o => 0x) 0x62) && (match (CoreBinding::get a 0x7469746c65) | Json::Value.string title => (Toml::sameBytes title 0x6b657074) | Json::Value.null => false | Json::Value.boolean v => false | Json::Value.number n => false | Json::Value.array x => false | Json::Value.object o => false)))))) = true), + proof: decide{}, + axioms: [] +} + +theorem{ + name: missingLinkedValueIsRefused, + parameters: [], + statement: ((CompilerSnapshot::modules (cons (ctor Json::Value.object (cons (0x6e616d65, (ctor Json::Value.string 0x61)) (nil (Bytes * Json::Value)))) (nil Json::Value)) 1) = (ctor Option.none [(List Json::Value)])), + proof: decide{}, + axioms: [] +} + +theorem{ + name: moduleBudgetStopsBeforeReadingTheNextRow, + parameters: [next : Json::Value], + statement: ((CompilerSnapshot::modules (cons (row 0x61) (cons next (nil Json::Value))) 1) = (ctor Option.none [(List Json::Value)])), + proof: reflexivity{}, + axioms: [] +} + +theorem{ + name: emptyModulesNeedNoTraversalBudget, + parameters: [], + statement: ((CompilerSnapshot::modules (nil Json::Value) 0) = (ctor Option.some [(List Json::Value)] (nil Json::Value))), + proof: reflexivity{}, + axioms: [] +} + +theorem{ + name: metadataDoesNotSupplyAProofDeclaration, + parameters: [], + statement: ((match (CompilerSnapshot::decode (snapshot) (compiler) 1024 16 256) | Option.none => false | Option.some data => ((Toml::sameBytes (project data semantic) 0x31323832343634323638663461333466653233396462666237636236643864366436633235316234346639643865373738316635643862343532353432633039) && (match (CandidateBinding::candidate (project data binding) 0x46697874757265 0x466978747572652e70726f6f66 1024 16) | Option.none => true | Option.some proof => false))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: aDifferentCompilerIsRefused, + parameters: [], + statement: ((CompilerSnapshot::decode (snapshot) 0x626164 1024 16 256) = (ctor Option.none [CompilerSnapshot::Metadata])), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: oversizedSnapshotIsRefused, + parameters: [], + statement: ((CompilerSnapshot::decode (snapshot) (compiler) 10 16 256) = (ctor Option.none [CompilerSnapshot::Metadata])), + proof: decide{}, + axioms: [Quot.sound, propext] +} +\end{semanticmodule} +\end{lexlean} diff --git a/rule30-api/src/ResearchCandidate.lex.tex b/rule30-api/src/ResearchCandidate.lex.tex new file mode 100644 index 0000000..6e11812 --- /dev/null +++ b/rule30-api/src/ResearchCandidate.lex.tex @@ -0,0 +1,243 @@ +\begin{lexlean}{ResearchCandidate} +\useglossary{lexlean.std.bool@1.2.0} +\useglossary{lexlean.std.nat@1.2.0} +\importmodule{LexLeanStd.Host} +\importmodule{Research} +\importmodule{ResearchExecution} +\importmodule{ResearchVerification} +\importmodule{ResearchProof} +\importmodule{VerificationReport} +\importmodule{CandidateBinding} +\importmodule{CompilerSnapshot} +\title{Boolean} +\begin{semanticmodule} + +definition{ + name: contract, + parameters: [], + result: String, + body: "Own the local candidate snapshot process, its output read, and the subsequent proof verifier as one lifecycle. Source and semantic pins come from the owned snapshot; the caller cannot submit candidate IR or a receipt as an event. Before verification starts the reconstructed candidate must match the inspected contextual goal. Verification then binds the report to the same source, semantics, tools, declaration and request. Cancellation drains an outstanding reply before cleanup and cannot cross from snapshot reading into verification; failed cleanup retains ownership and blocks dispatch. The caller owns candidate construction, the isolated project and pinned imported library. Snapshot metadata alone creates no proof evidence.", + axioms: [], + executable: true +} + +structure{ + name: Tools, + type_parameters: [], + parameters: [], + fields: [{name: lexlean, type: Bytes}, {name: lean, type: Bytes}, {name: lake, type: Bytes}, {name: checker, type: Bytes}] +} +structure{ + name: Context, + type_parameters: [], + parameters: [], + fields: [{name: request, type: Research::Request}, {name: config, type: ResearchVerification::Config}, {name: tools, type: Tools}, {name: module, type: Bytes}, {name: theorem, type: Bytes}, {name: maxDepth, type: Nat}, {name: maxSteps, type: Nat}] +} +inductive{ + name: Phase, + type_parameters: [], + parameters: [], + constructors: [{name: running, fields: []}, {name: reading, fields: []}, {name: verifying, fields: []}, {name: ended, fields: []}] +} +structure{ + name: State, + type_parameters: [], + parameters: [], + fields: [{name: context, type: Context}, {name: execution, type: (Option ResearchExecution::State)}, {name: proof, type: (Option ResearchProof::State)}, {name: phase, type: Phase}, {name: cancelled, type: Bool}] +} + +definition{ + name: arguments, + parameters: [config : ResearchVerification::Config], + result: (List String), + body: (cons (ResearchVerification::concat "--project=" (project config project)) (cons "--diagnostic-format=json" (cons "snapshot" (cons "--" (cons (project config moduleSource) (nil String)))))), + axioms: [propext], + executable: true +} + +definition{ + name: job, + parameters: [context : Context], + result: ResearchExecution::Job, + body: (let config : ResearchVerification::Config := (project context config); (record ResearchExecution::Job {request := (project context request), tool := (ctor ResearchExecution::Tool.lexlean), arguments := (arguments config), directory := (project config directory), environment := (project config environment), output := (project config output), errors := (project config errors), allowance := (project config allowance), quantum := (project config quantum), polls := (project config polls)})), + axioms: [propext], + executable: true +} + +definition{ + name: valid, + parameters: [context : Context], + result: Bool, + body: (let config : ResearchVerification::Config := (project context config); (let tools : Tools := (project context tools); ((ResearchExecution::validJob (job context)) && ((ResearchVerification::nonempty (project config project)) && ((ResearchVerification::nonempty (project config moduleSource)) && ((ResearchVerification::nonempty (project config verifiedRoot)) && ((0 ((withPhase state (ctor Phase.reading)), (ctor ResearchProof::Emission.host (ctor LexLeanStd.Host::Request.read (project (project (project state context) config) output)))) + | ResearchExecution::EndKind.cut => (answer state (ctor Research::ResultKind.cut)) + | ResearchExecution::EndKind.unavailable => (answer state (ctor Research::ResultKind.unavailable)) + | ResearchExecution::EndKind.failed => (failed state "candidate snapshot failed") + | ResearchExecution::EndKind.protocol => (finish state (ctor ResearchProof::Emission.blocked completion)) + | ResearchExecution::EndKind.cleanupFailed => (finish state (ctor ResearchProof::Emission.blocked completion)) + | ResearchExecution::EndKind.refused => (finish state (ctor ResearchProof::Emission.blocked completion))))), + axioms: [], + executable: true +} + +definition{ + name: executionResult, + parameters: [state : State, result : (ResearchExecution::State * ResearchExecution::Emission)], + result: (State * ResearchProof::Emission), + body: (let next : State := (record State {context := (project state context), execution := (ctor Option.some [ResearchExecution::State] (first result)), proof := (project state proof), phase := (ctor Phase.running), cancelled := (project state cancelled)}); (match (second result) | ResearchExecution::Emission.host request => (next, (ctor ResearchProof::Emission.host request)) | ResearchExecution::Emission.awaiting => (next, (ctor ResearchProof::Emission.awaiting)) | ResearchExecution::Emission.complete completion => (completed next completion))), + axioms: [], + executable: true +} + +definition{ + name: pins, + parameters: [context : Context, metadata : CompilerSnapshot::Metadata], + result: VerificationReport::Pins, + body: (let tools : Tools := (project context tools); (record VerificationReport::Pins {request := (project context request), source := (project metadata source), semantic := (project metadata semantic), compiler := (project (project (project context request) snapshot) compiler), lexlean := (project tools lexlean), lean := (project tools lean), lake := (project tools lake), checker := (project tools checker), theorem := (project context theorem), module := (project context module)})), + axioms: [], + executable: true +} + +definition{ + name: proofResult, + parameters: [state : State, result : (ResearchProof::State * ResearchProof::Emission)], + result: (State * ResearchProof::Emission), + body: (let next : State := (record State {context := (project state context), execution := (project state execution), proof := (ctor Option.some [ResearchProof::State] (first result)), phase := (ctor Phase.verifying), cancelled := (project state cancelled)}); (match (second result) | ResearchProof::Emission.host request => (next, (ctor ResearchProof::Emission.host request)) | ResearchProof::Emission.awaiting => (next, (ctor ResearchProof::Emission.awaiting)) | ResearchProof::Emission.complete receipt => (finish next (ctor ResearchProof::Emission.complete receipt)) | ResearchProof::Emission.blocked completion => (finish next (ctor ResearchProof::Emission.blocked completion)))), + axioms: [], + executable: true +} + +definition{ + name: snapshotRead, + parameters: [state : State, source : Bytes], + result: (State * ResearchProof::Emission), + body: (let context : Context := (project state context); (let config : ResearchVerification::Config := (project context config); (match (CompilerSnapshot::decode source (project (project (project context request) snapshot) compiler) (project config maxBytes) (project context maxDepth) (project context maxSteps)) | Option.none => (failed state "candidate snapshot identity is invalid") | Option.some metadata => (let bound : VerificationReport::Pins := (pins context metadata); (if (CandidateBinding::matches bound (project metadata binding) (project config maxBytes) (project context maxDepth) (project context maxSteps)) then (proofResult state (ResearchProof::begin bound config (project metadata binding) (project context maxDepth) (project context maxSteps))) else (failed state "candidate snapshot does not match the requested goal")))))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: protocol, + parameters: [state : State, reason : String], + result: (State * ResearchProof::Emission), + body: (let context : Context := (project state context); (let config : ResearchVerification::Config := (project context config); (finish state (ctor ResearchProof::Emission.blocked (record ResearchExecution::Completion {request := (project context request), kind := (ctor ResearchExecution::EndKind.protocol), code := (ctor Option.none [Int32]), clock := 0, output := (project config output), errors := (project config errors), detail := (prim utf8_encode reason : Bytes)}))))), + axioms: [], + executable: true +} + +definition{ + name: reading, + parameters: [state : State, response : LexLeanStd.Host::Event], + result: (State * ResearchProof::Emission), + body: (match (ResearchVerification::readResponse response) | Option.none => (protocol state "unexpected candidate snapshot response") | Option.some result => (if (project state cancelled) then (answer state (ctor Research::ResultKind.cut)) else (match result | Result.error problem => (failed state "candidate snapshot read failed") | Result.ok source => (snapshotRead state source)))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: begin, + parameters: [context : Context], + result: (State * ResearchProof::Emission), + body: (let state : State := (record State {context := context, execution := (ctor Option.none [ResearchExecution::State]), proof := (ctor Option.none [ResearchProof::State]), phase := (ctor Phase.running), cancelled := false}); (if (valid context) then (executionResult state (ResearchExecution::begin (job context))) else (failed state "invalid candidate snapshot configuration"))), + axioms: [propext], + executable: true +} + +definition{ + name: cancel, + parameters: [state : State], + result: (State * ResearchProof::Emission), + body: (let next : State := (record State {context := (project state context), execution := (project state execution), proof := (project state proof), phase := (project state phase), cancelled := true}); (match (project state phase) + | Phase.ended => (state, (ctor ResearchProof::Emission.awaiting)) + | Phase.reading => (next, (ctor ResearchProof::Emission.awaiting)) + | Phase.running => (match (project state execution) | Option.none => (protocol next "candidate snapshot has no execution owner") | Option.some execution => (executionResult next (ResearchExecution::cancel execution))) + | Phase.verifying => (match (project state proof) | Option.none => (protocol next "candidate has no proof owner") | Option.some proof => (proofResult next (ResearchProof::step proof (ctor ResearchVerification::Event.cancel)))))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: host, + parameters: [state : State, response : LexLeanStd.Host::Event], + result: (State * ResearchProof::Emission), + body: (match (project state phase) + | Phase.ended => (state, (ctor ResearchProof::Emission.awaiting)) + | Phase.reading => (reading state response) + | Phase.running => (match (project state execution) | Option.none => (protocol state "candidate snapshot has no execution owner") | Option.some execution => (executionResult state (ResearchExecution::step execution response))) + | Phase.verifying => (match (project state proof) | Option.none => (protocol state "candidate has no proof owner") | Option.some proof => (proofResult state (ResearchProof::step proof (ctor ResearchVerification::Event.host response))))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: step, + parameters: [state : State, event : ResearchVerification::Event], + result: (State * ResearchProof::Emission), + body: (match (project state phase) | Phase.ended => (state, (ctor ResearchProof::Emission.awaiting)) | Phase.running => (match event | ResearchVerification::Event.host response => (host state response) | ResearchVerification::Event.cancel => (cancel state) | ResearchVerification::Event.changed snapshot => (if (Research::sameSnapshot snapshot (project (project (project state context) request) snapshot)) then (state, (ctor ResearchProof::Emission.awaiting)) else (cancel state))) | Phase.reading => (match event | ResearchVerification::Event.host response => (host state response) | ResearchVerification::Event.cancel => (cancel state) | ResearchVerification::Event.changed snapshot => (if (Research::sameSnapshot snapshot (project (project (project state context) request) snapshot)) then (state, (ctor ResearchProof::Emission.awaiting)) else (cancel state))) | Phase.verifying => (match event | ResearchVerification::Event.host response => (host state response) | ResearchVerification::Event.cancel => (cancel state) | ResearchVerification::Event.changed snapshot => (if (Research::sameSnapshot snapshot (project (project (project state context) request) snapshot)) then (state, (ctor ResearchProof::Emission.awaiting)) else (cancel state)))), + axioms: [Quot.sound, propext], + executable: true +} + +theorem{ + name: endedCandidateIsSilent, + parameters: [state : State, emission : ResearchProof::Emission, event : ResearchVerification::Event], + statement: ((step (first (finish state emission)) event) = ((first (finish state emission)), (ctor ResearchProof::Emission.awaiting))), + proof: reflexivity{}, + axioms: [Quot.sound, propext] +} + +definition{ + name: features, + parameters: [], + result: (List String), + body: (cons "owned-local-candidate-snapshot" (cons "derive-verification-pins" (cons "preflight-exact-candidate-goal" (cons "snapshot-to-proof-ownership" (cons "cancel-before-verification" (cons "retain-failed-cleanup-owner" (nil String))))))), + axioms: [], + executable: true +} +\end{semanticmodule} +\end{lexlean} diff --git a/rule30-api/src/ResearchCandidateTraces.lex.tex b/rule30-api/src/ResearchCandidateTraces.lex.tex new file mode 100644 index 0000000..409d079 --- /dev/null +++ b/rule30-api/src/ResearchCandidateTraces.lex.tex @@ -0,0 +1,300 @@ +\begin{lexlean}{ResearchCandidateTraces} +\useglossary{lexlean.std.bool@1.2.0} +\useglossary{lexlean.std.nat@1.2.0} +\importmodule{LexLeanStd.Host} +\importmodule{Json} +\importmodule{CandidateBinding} +\importmodule{Research} +\importmodule{ResearchTraces} +\importmodule{ResearchExecution} +\importmodule{ResearchExecutionTraces} +\importmodule{ResearchVerification} +\importmodule{ResearchVerificationTraces} +\importmodule{VerificationReport} +\importmodule{VerificationReportTraces} +\importmodule{ResearchProof} +\importmodule{ResearchCandidate} +\importmodule{ResearchRunner} +\importmodule{ResearchRunnerTraces} +\title{Boolean} +\begin{semanticmodule} + +definition{ + name: context, + parameters: [config : ResearchVerification::Config], + result: ResearchCandidate::Context, + body: (let pins : VerificationReport::Pins := (VerificationReportTraces::pins); (record ResearchCandidate::Context {request := (project pins request), config := config, tools := (record ResearchCandidate::Tools {lexlean := (project pins lexlean), lean := (project pins lean), lake := (project pins lake), checker := (project pins checker)}), module := (project pins module), theorem := (project pins theorem), maxDepth := 32, maxSteps := 1024})), + axioms: [] +} + +definition{ + name: began, + parameters: [], + result: (ResearchCandidate::State * ResearchProof::Emission), + body: (ResearchCandidate::begin (context (ResearchVerificationTraces::settings))), + axioms: [propext] +} + +definition{ + name: active, + parameters: [], + result: (ResearchCandidate::State * ResearchProof::Emission), + body: (ResearchCandidate::step (first (began)) (ctor ResearchVerification::Event.host (ResearchVerificationTraces::spawned))), + axioms: [Quot.sound, propext] +} + +definition{ + name: reading, + parameters: [], + result: (ResearchCandidate::State * ResearchProof::Emission), + body: (ResearchCandidate::step (first (active)) (ctor ResearchVerification::Event.host (ResearchVerificationTraces::exited))), + axioms: [Quot.sound, propext] +} + +definition{ + name: kind, + parameters: [result : (ResearchCandidate::State * ResearchProof::Emission)], + result: Nat, + body: (match (second result) | ResearchProof::Emission.host request => 0 | ResearchProof::Emission.awaiting => 1 | ResearchProof::Emission.complete answer => 2 | ResearchProof::Emission.blocked completion => 3), + axioms: [] +} + +definition{ + name: failed, + parameters: [result : (ResearchCandidate::State * ResearchProof::Emission)], + result: Bool, + body: (match (second result) | ResearchProof::Emission.host request => false | ResearchProof::Emission.awaiting => false | ResearchProof::Emission.blocked completion => false | ResearchProof::Emission.complete answer => (match (project answer result) | Research::ResultKind.failed reason => true | Research::ResultKind.checked goal theorem axioms => false | Research::ResultKind.inspected goal => false | Research::ResultKind.maintained sources evidence => false | Research::ResultKind.cut => false | Research::ResultKind.unavailable => false)), + axioms: [] +} + +definition{ + name: readPath, + parameters: [result : (ResearchCandidate::State * ResearchProof::Emission)], + result: String, + body: (match (second result) | ResearchProof::Emission.awaiting => "" | ResearchProof::Emission.complete outcome => "" | ResearchProof::Emission.blocked completion => "" | ResearchProof::Emission.host request => (match request | LexLeanStd.Host::Request.read path => path | LexLeanStd.Host::Request.write path contents => "" | LexLeanStd.Host::Request.list path => "" | LexLeanStd.Host::Request.stat path => "" | LexLeanStd.Host::Request.createDir path => "" | LexLeanStd.Host::Request.removeFile path => "" | LexLeanStd.Host::Request.removeTree path => "" | LexLeanStd.Host::Request.rename source target => "" | LexLeanStd.Host::Request.canonical path => "" | LexLeanStd.Host::Request.lock path => "" | LexLeanStd.Host::Request.spawn child => "" | LexLeanStd.Host::Request.wait children duration => "" | LexLeanStd.Host::Request.stop child => "" | LexLeanStd.Host::Request.exit status output errors => "")), + axioms: [] +} + +definition{ + name: cut, + parameters: [result : (ResearchCandidate::State * ResearchProof::Emission)], + result: Bool, + body: (match (second result) | ResearchProof::Emission.host request => false | ResearchProof::Emission.awaiting => false | ResearchProof::Emission.blocked completion => false | ResearchProof::Emission.complete answer => (match (project answer result) | Research::ResultKind.cut => true | Research::ResultKind.checked goal theorem axioms => false | Research::ResultKind.inspected goal => false | Research::ResultKind.maintained sources evidence => false | Research::ResultKind.failed reason => false | Research::ResultKind.unavailable => false)), + axioms: [] +} + +theorem{ + name: snapshotUsesTheFixedCompilerCommand, + parameters: [], + statement: ((match (prim index (ResearchCandidate::arguments (ResearchVerificationTraces::settings)) 2 : (Option String)) | Option.none => false | Option.some command => (prim equal command "snapshot" : Bool)) = true), + proof: decide{}, + axioms: [propext] +} + +theorem{ + name: invalidDecoderBudgetLaunchesNothing, + parameters: [], + statement: ((failed (ResearchCandidate::begin (context (ResearchVerificationTraces::config 0 "/research/lexlean.toml" "/research/attempt.out" "/research/attempt.err")))) = true), + proof: decide{}, + axioms: [propext] +} + +theorem{ + name: snapshotExitOnlyRequestsARead, + parameters: [], + statement: ((prim equal (readPath (reading)) "/research/attempt.out" : Bool) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: snapshotExitDoesNotCreateAProofOwner, + parameters: [], + statement: ((match (project (first (reading)) proof) | Option.none => true | Option.some owner => false) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +definition{ + name: cancelReading, + parameters: [], + result: (ResearchCandidate::State * ResearchProof::Emission), + body: (ResearchCandidate::step (first (reading)) (ctor ResearchVerification::Event.cancel)), + axioms: [Quot.sound, propext] +} + +theorem{ + name: cancellationWaitsForTheOutstandingSnapshotRead, + parameters: [], + statement: ((kind (cancelReading)) = 1), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: cancelledSnapshotBytesCannotStartVerification, + parameters: [source : Bytes], + statement: ((cut (ResearchCandidate::step (first (cancelReading)) (ctor ResearchVerification::Event.host (ctor LexLeanStd.Host::Event.read (ctor Result.ok [Bytes, LexLeanStd.Host::Failure] source))))) = true), + proof: reflexivity{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: cancelledReadFailureStillCompletesCancellation, + parameters: [], + statement: ((cut (ResearchCandidate::step (first (cancelReading)) (ctor ResearchVerification::Event.host (ctor LexLeanStd.Host::Event.read (ctor Result.error [Bytes, LexLeanStd.Host::Failure] (ResearchExecutionTraces::failedHost)))))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: unexpectedReadReplyBlocksDispatch, + parameters: [], + statement: ((kind (ResearchCandidate::step (first (reading)) (ctor ResearchVerification::Event.host (ResearchVerificationTraces::spawned)))) = 3), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: malformedSnapshotNeverStartsVerification, + parameters: [], + statement: ((failed (ResearchCandidate::step (first (reading)) (ctor ResearchVerification::Event.host (ctor LexLeanStd.Host::Event.read (ctor Result.ok [Bytes, LexLeanStd.Host::Failure] 0x7b7d))))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +definition{ + name: cancelledSpawn, + parameters: [], + result: (ResearchCandidate::State * ResearchProof::Emission), + body: (ResearchCandidate::step (first (began)) (ctor ResearchVerification::Event.cancel)), + axioms: [Quot.sound, propext] +} + +definition{ + name: stopping, + parameters: [], + result: (ResearchCandidate::State * ResearchProof::Emission), + body: (ResearchCandidate::step (first (cancelledSpawn)) (ctor ResearchVerification::Event.host (ResearchVerificationTraces::spawned))), + axioms: [Quot.sound, propext] +} + +definition{ + name: failedStop, + parameters: [], + result: (ResearchCandidate::State * ResearchProof::Emission), + body: (ResearchCandidate::step (first (stopping)) (ctor ResearchVerification::Event.host (ctor LexLeanStd.Host::Event.finished (ctor Result.error [Unit, LexLeanStd.Host::Failure] (ResearchExecutionTraces::failedHost))))), + axioms: [Quot.sound, propext] +} + +theorem{ + name: cancelDuringSpawnDrainsBeforeStopping, + parameters: [], + statement: ((kind (cancelledSpawn)) = 1), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: failedCleanupBlocksDispatch, + parameters: [], + statement: ((kind (failedStop)) = 3), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: failedCleanupRetainsTheSnapshotChild, + parameters: [], + statement: ((match (project (first (failedStop)) execution) | Option.none => (ctor Option.none [Nat]) | Option.some execution => (project execution owner)) = (ctor Option.some [Nat] 7)), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: changedSnapshotCancelsThePendingRead, + parameters: [], + statement: ((project (first (ResearchCandidate::step (first (reading)) (ctor ResearchVerification::Event.changed (ResearchTraces::otherSnapshot)))) cancelled) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} +definition{ + name: research, + parameters: [], + result: Research::State, + body: (record Research::State {snapshot := (project (VerificationReportTraces::request) snapshot), components := (ResearchTraces::components), tasks := (cons (project (VerificationReportTraces::request) task) (nil Research::Task)), pending := (ctor Option.none [Research::Request]), next := 1, history := (nil Research::Answer)}), + axioms: [] +} + +definition{ + name: runnerStarted, + parameters: [], + result: (ResearchRunner::State * ResearchRunner::Action), + body: (ResearchRunner::step (first (ResearchRunner::begin (research))) (ctor ResearchRunner::Event.candidate (context (ResearchVerificationTraces::settings)))), + axioms: [Quot.sound, propext] +} + +theorem{ + name: runnerOwnsTheCandidateSnapshot, + parameters: [], + statement: ((match (project (first (runnerStarted)) candidate) | Option.none => false | Option.some owner => true) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: runnerRefusesOverlappingSnapshotStrategyAndReview, + parameters: [], + statement: ((((ResearchRunnerTraces::kindOf (ResearchRunner::step (first (runnerStarted)) (ctor ResearchRunner::Event.candidate (context (ResearchVerificationTraces::settings))))) =? 6) && (((ResearchRunnerTraces::kindOf (ResearchRunner::step (first (runnerStarted)) (ctor ResearchRunner::Event.job (ResearchExecutionTraces::job 10 4 3)))) =? 6) && ((ResearchRunnerTraces::kindOf (ResearchRunner::step (first (runnerStarted)) (ctor ResearchRunner::Event.reviewed (ResearchRunnerTraces::checkedAnswer 0x4861)))) =? 6))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +definition{ + name: runnerStopping, + parameters: [], + result: (ResearchRunner::State * ResearchRunner::Action), + body: (ResearchRunner::step (first (ResearchRunner::step (first (runnerStarted)) (ctor ResearchRunner::Event.cancel))) (ctor ResearchRunner::Event.host (ResearchVerificationTraces::spawned))), + axioms: [Quot.sound, propext] +} + +definition{ + name: runnerFailedStop, + parameters: [], + result: (ResearchRunner::State * ResearchRunner::Action), + body: (ResearchRunner::step (first (runnerStopping)) (ctor ResearchRunner::Event.host (ctor LexLeanStd.Host::Event.finished (ctor Result.error [Unit, LexLeanStd.Host::Failure] (ResearchExecutionTraces::failedHost))))), + axioms: [Quot.sound, propext] +} + +theorem{ + name: runnerRetainsTheFailedCandidateCleanup, + parameters: [], + statement: (((project (first (runnerFailedStop)) halted) && (match (project (first (runnerFailedStop)) candidate) | Option.none => false | Option.some owner => (match (project owner execution) | Option.none => false | Option.some execution => (match (project execution owner) | Option.none => false | Option.some child => (child =? 7))))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: candidateCleanupFailureCannotPublishEvidence, + parameters: [], + statement: ((ResearchRunnerTraces::historySize (runnerFailedStop)) = 0), + proof: decide{}, + axioms: [Quot.sound, propext] +} +theorem{ + name: missingOwnerBlocksInsteadOfLearningACandidateFailure, + parameters: [], + statement: ((kind (ResearchCandidate::step (record ResearchCandidate::State {context := (context (ResearchVerificationTraces::settings)), execution := (ctor Option.none [ResearchExecution::State]), proof := (ctor Option.none [ResearchProof::State]), phase := (ctor ResearchCandidate::Phase.running), cancelled := false}) (ctor ResearchVerification::Event.host (ResearchVerificationTraces::spawned)))) = 3), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: aRawProofEventCannotStartASecondVerifier, + parameters: [], + statement: ((ResearchRunnerTraces::kindOf (ResearchRunner::step (first (runnerStarted)) (ctor ResearchRunner::Event.proof (VerificationReportTraces::pins) (ResearchVerificationTraces::settings) (record CandidateBinding::Input {linked := (ctor Json::Value.null), lexicon := (ctor Json::Value.null)}) 32 1024))) = 6), + proof: decide{}, + axioms: [Quot.sound, propext] +} +\end{semanticmodule} +\end{lexlean} diff --git a/rule30-api/src/ResearchCatalog.lex.tex b/rule30-api/src/ResearchCatalog.lex.tex index a0bbd5f..214b235 100644 --- a/rule30-api/src/ResearchCatalog.lex.tex +++ b/rule30-api/src/ResearchCatalog.lex.tex @@ -17,6 +17,8 @@ \importmodule{CoreBinding} \importmodule{ArtifactIdentity} \importmodule{ResearchProof} +\importmodule{ResearchCandidate} +\importmodule{CompilerSnapshot} \importmodule{CandidateBinding} \importmodule{VerificationReport} \importmodule{ResearchVerification} @@ -40,7 +42,7 @@ name: moduleScopes, parameters: [], result: (List Scope), - body: (cons (unitScope 0x6d6f64756c652f526573656172636850726f6f66547261636573 "ResearchProofTraces") (cons (unitScope 0x6d6f64756c652f43616e64696461746542696e64696e67547261636573 "CandidateBindingTraces") (cons (unitScope 0x6d6f64756c652f42696e64696e6746697874757265 "BindingFixture") (cons (unitScope 0x6d6f64756c652f526573656172636850726f6f66 "ResearchProof") (cons (unitScope 0x6d6f64756c652f43616e64696461746542696e64696e67 "CandidateBinding") (cons (unitScope 0x6d6f64756c652f41727469666163744964656e74697479547261636573 "ArtifactIdentityTraces") (cons (unitScope 0x6d6f64756c652f41727469666163744964656e74697479 "ArtifactIdentity") (cons (unitScope 0x6d6f64756c652f436f726542696e64696e67547261636573 "CoreBindingTraces") (cons (unitScope 0x6d6f64756c652f436f726542696e64696e67 "CoreBinding") (cons (unitScope 0x6d6f64756c652f4a736f6e43616e6f6e6963616c547261636573 "JsonCanonicalTraces") (cons (unitScope 0x6d6f64756c652f4a736f6e43616e6f6e6963616c "JsonCanonical") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e557466384669787475726573 "VerificationUtf8Fixtures") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e436f6d6d616e644669787475726573 "VerificationCommandFixtures") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e4a736f6e44617461 "VerificationJsonData") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e4a736f6e537465707330 "VerificationJsonSteps0") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e4a736f6e537465707331 "VerificationJsonSteps1") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e4a736f6e537465707332 "VerificationJsonSteps2") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e4a736f6e537465707333 "VerificationJsonSteps3") (cons (unitScope 0x6d6f64756c652f417069 "Api") (cons (unitScope 0x6d6f64756c652f4170706c69636174696f6e "Application") (cons (unitScope 0x6d6f64756c652f417263686974656374757265 "Architecture") (cons (unitScope 0x6d6f64756c652f4175646974 "Audit") (cons (unitScope 0x6d6f64756c652f436f6e76657274 "Convert") (cons (unitScope 0x6d6f64756c652f446973636f76657279 "Discovery") (cons (unitScope 0x6d6f64756c652f456e67696e65 "Engine") (cons (unitScope 0x6d6f64756c652f486f7374 "Host") (cons (unitScope 0x6d6f64756c652f4879706f746865736573 "Hypotheses") (cons (unitScope 0x6d6f64756c652f4f62736572766572 "Observer") (cons (unitScope 0x6d6f64756c652f50726573656e746174696f6e "Presentation") (cons (unitScope 0x6d6f64756c652f523330 "R30") (cons (unitScope 0x6d6f64756c652f523330547261636573 "R30Traces") (cons (unitScope 0x6d6f64756c652f523330547261636573436c61696d73 "R30TracesClaims") (cons (unitScope 0x6d6f64756c652f523330547261636573466f726d73 "R30TracesForms") (cons (unitScope 0x6d6f64756c652f5233305472616365735265676973746572 "R30TracesRegister") (cons (unitScope 0x6d6f64756c652f5265676973746572 "Register") (cons (unitScope 0x6d6f64756c652f5265736561726368 "Research") (cons (unitScope 0x6d6f64756c652f5265736561726368436174616c6f67 "ResearchCatalog") (cons (unitScope 0x6d6f64756c652f5265736561726368547261636573 "ResearchTraces") (cons (unitScope 0x6d6f64756c652f52756c653330436f7265 "Rule30Core") (cons (unitScope 0x6d6f64756c652f53657175656e636573 "Sequences") (cons (unitScope 0x6d6f64756c652f5374616e6461726473 "Standards") (cons (unitScope 0x6d6f64756c652f546f6d6c "Toml") (cons (unitScope 0x6d6f64756c652f466f756e646174696f6e2e41726368 "Foundation.Arch") (cons (unitScope 0x6d6f64756c652f466f756e646174696f6e2e5175616c "Foundation.Qual") (cons (unitScope 0x6d6f64756c652f4c65784c65616e5374642e427566666572 "LexLeanStd.Buffer") (cons (unitScope 0x6d6f64756c652f4c65784c65616e5374642e54657874 "LexLeanStd.Text") (cons (unitScope 0x6d6f64756c652f4c65784c65616e5374642e536861323536 "LexLeanStd.Sha256") (cons (unitScope 0x6d6f64756c652f4c65784c65616e5374642e486f7374 "LexLeanStd.Host") (cons (unitScope 0x6d6f64756c652f5265736561726368457865637574696f6e "ResearchExecution") (cons (unitScope 0x6d6f64756c652f5265736561726368457865637574696f6e547261636573 "ResearchExecutionTraces") (cons (unitScope 0x6d6f64756c652f526573656172636852756e6e6572 "ResearchRunner") (cons (unitScope 0x6d6f64756c652f526573656172636852756e6e6572547261636573 "ResearchRunnerTraces") (cons (unitScope 0x6d6f64756c652f4a736f6e "Json") (cons (unitScope 0x6d6f64756c652f4a736f6e547261636573 "JsonTraces") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e5265706f7274 "VerificationReport") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e5265706f7274547261636573 "VerificationReportTraces") (cons (unitScope 0x6d6f64756c652f5265736561726368566572696669636174696f6e "ResearchVerification") (cons (unitScope 0x6d6f64756c652f5265736561726368566572696669636174696f6e547261636573 "ResearchVerificationTraces") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e4a736f6e4669787475726573 "VerificationJsonFixtures") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e486173684669787475726573 "VerificationHashFixtures") (nil Scope))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))), + body: (cons (unitScope 0x6d6f64756c652f436f6d70696c6572536e617073686f74 "CompilerSnapshot") (cons (unitScope 0x6d6f64756c652f436f6d70696c6572536e617073686f74547261636573 "CompilerSnapshotTraces") (cons (unitScope 0x6d6f64756c652f526573656172636843616e646964617465 "ResearchCandidate") (cons (unitScope 0x6d6f64756c652f526573656172636843616e646964617465547261636573 "ResearchCandidateTraces") (cons (unitScope 0x6d6f64756c652f526573656172636850726f6f66547261636573 "ResearchProofTraces") (cons (unitScope 0x6d6f64756c652f43616e64696461746542696e64696e67547261636573 "CandidateBindingTraces") (cons (unitScope 0x6d6f64756c652f42696e64696e6746697874757265 "BindingFixture") (cons (unitScope 0x6d6f64756c652f526573656172636850726f6f66 "ResearchProof") (cons (unitScope 0x6d6f64756c652f43616e64696461746542696e64696e67 "CandidateBinding") (cons (unitScope 0x6d6f64756c652f41727469666163744964656e74697479547261636573 "ArtifactIdentityTraces") (cons (unitScope 0x6d6f64756c652f41727469666163744964656e74697479 "ArtifactIdentity") (cons (unitScope 0x6d6f64756c652f436f726542696e64696e67547261636573 "CoreBindingTraces") (cons (unitScope 0x6d6f64756c652f436f726542696e64696e67 "CoreBinding") (cons (unitScope 0x6d6f64756c652f4a736f6e43616e6f6e6963616c547261636573 "JsonCanonicalTraces") (cons (unitScope 0x6d6f64756c652f4a736f6e43616e6f6e6963616c "JsonCanonical") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e557466384669787475726573 "VerificationUtf8Fixtures") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e436f6d6d616e644669787475726573 "VerificationCommandFixtures") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e4a736f6e44617461 "VerificationJsonData") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e4a736f6e537465707330 "VerificationJsonSteps0") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e4a736f6e537465707331 "VerificationJsonSteps1") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e4a736f6e537465707332 "VerificationJsonSteps2") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e4a736f6e537465707333 "VerificationJsonSteps3") (cons (unitScope 0x6d6f64756c652f417069 "Api") (cons (unitScope 0x6d6f64756c652f4170706c69636174696f6e "Application") (cons (unitScope 0x6d6f64756c652f417263686974656374757265 "Architecture") (cons (unitScope 0x6d6f64756c652f4175646974 "Audit") (cons (unitScope 0x6d6f64756c652f436f6e76657274 "Convert") (cons (unitScope 0x6d6f64756c652f446973636f76657279 "Discovery") (cons (unitScope 0x6d6f64756c652f456e67696e65 "Engine") (cons (unitScope 0x6d6f64756c652f486f7374 "Host") (cons (unitScope 0x6d6f64756c652f4879706f746865736573 "Hypotheses") (cons (unitScope 0x6d6f64756c652f4f62736572766572 "Observer") (cons (unitScope 0x6d6f64756c652f50726573656e746174696f6e "Presentation") (cons (unitScope 0x6d6f64756c652f523330 "R30") (cons (unitScope 0x6d6f64756c652f523330547261636573 "R30Traces") (cons (unitScope 0x6d6f64756c652f523330547261636573436c61696d73 "R30TracesClaims") (cons (unitScope 0x6d6f64756c652f523330547261636573466f726d73 "R30TracesForms") (cons (unitScope 0x6d6f64756c652f5233305472616365735265676973746572 "R30TracesRegister") (cons (unitScope 0x6d6f64756c652f5265676973746572 "Register") (cons (unitScope 0x6d6f64756c652f5265736561726368 "Research") (cons (unitScope 0x6d6f64756c652f5265736561726368436174616c6f67 "ResearchCatalog") (cons (unitScope 0x6d6f64756c652f5265736561726368547261636573 "ResearchTraces") (cons (unitScope 0x6d6f64756c652f52756c653330436f7265 "Rule30Core") (cons (unitScope 0x6d6f64756c652f53657175656e636573 "Sequences") (cons (unitScope 0x6d6f64756c652f5374616e6461726473 "Standards") (cons (unitScope 0x6d6f64756c652f546f6d6c "Toml") (cons (unitScope 0x6d6f64756c652f466f756e646174696f6e2e41726368 "Foundation.Arch") (cons (unitScope 0x6d6f64756c652f466f756e646174696f6e2e5175616c "Foundation.Qual") (cons (unitScope 0x6d6f64756c652f4c65784c65616e5374642e427566666572 "LexLeanStd.Buffer") (cons (unitScope 0x6d6f64756c652f4c65784c65616e5374642e54657874 "LexLeanStd.Text") (cons (unitScope 0x6d6f64756c652f4c65784c65616e5374642e536861323536 "LexLeanStd.Sha256") (cons (unitScope 0x6d6f64756c652f4c65784c65616e5374642e486f7374 "LexLeanStd.Host") (cons (unitScope 0x6d6f64756c652f5265736561726368457865637574696f6e "ResearchExecution") (cons (unitScope 0x6d6f64756c652f5265736561726368457865637574696f6e547261636573 "ResearchExecutionTraces") (cons (unitScope 0x6d6f64756c652f526573656172636852756e6e6572 "ResearchRunner") (cons (unitScope 0x6d6f64756c652f526573656172636852756e6e6572547261636573 "ResearchRunnerTraces") (cons (unitScope 0x6d6f64756c652f4a736f6e "Json") (cons (unitScope 0x6d6f64756c652f4a736f6e547261636573 "JsonTraces") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e5265706f7274 "VerificationReport") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e5265706f7274547261636573 "VerificationReportTraces") (cons (unitScope 0x6d6f64756c652f5265736561726368566572696669636174696f6e "ResearchVerification") (cons (unitScope 0x6d6f64756c652f5265736561726368566572696669636174696f6e547261636573 "ResearchVerificationTraces") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e4a736f6e4669787475726573 "VerificationJsonFixtures") (cons (unitScope 0x6d6f64756c652f566572696669636174696f6e486173684669787475726573 "VerificationHashFixtures") (nil Scope))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))), axioms: [] } @@ -48,7 +50,7 @@ name: facetScopes, parameters: [], result: (List Scope), - body: (cons (record Scope {id := 0x70726f6f662d766572696669636174696f6e, module := "ResearchProof", features := (ResearchProof::features)}) (cons (record Scope {id := 0x63616e6469646174652d62696e64696e67, module := "CandidateBinding", features := (CandidateBinding::features)}) (cons (record Scope {id := 0x61727469666163742d6964656e74697479, module := "ArtifactIdentity", features := (ArtifactIdentity::features)}) (cons (record Scope {id := 0x636f72652d62696e64696e67, module := "CoreBinding", features := (CoreBinding::features)}) (cons (record Scope {id := 0x63616e6f6e6963616c2d6a736f6e, module := "JsonCanonical", features := (JsonCanonical::features)}) (cons (record Scope {id := 0x617069, module := "Api", features := (Architecture::commandNames (Api::commands))}) + body: (cons (record Scope {id := 0x636f6d70696c65722d736e617073686f74, module := "CompilerSnapshot", features := (CompilerSnapshot::features)}) (cons (record Scope {id := 0x72657365617263682d63616e646964617465, module := "ResearchCandidate", features := (ResearchCandidate::features)}) (cons (record Scope {id := 0x70726f6f662d766572696669636174696f6e, module := "ResearchProof", features := (ResearchProof::features)}) (cons (record Scope {id := 0x63616e6469646174652d62696e64696e67, module := "CandidateBinding", features := (CandidateBinding::features)}) (cons (record Scope {id := 0x61727469666163742d6964656e74697479, module := "ArtifactIdentity", features := (ArtifactIdentity::features)}) (cons (record Scope {id := 0x636f72652d62696e64696e67, module := "CoreBinding", features := (CoreBinding::features)}) (cons (record Scope {id := 0x63616e6f6e6963616c2d6a736f6e, module := "JsonCanonical", features := (JsonCanonical::features)}) (cons (record Scope {id := 0x617069, module := "Api", features := (Architecture::commandNames (Api::commands))}) (cons (record Scope {id := 0x636c61696d73, module := "Register", features := (Register::idsOf (Register::claims))}) (cons (record Scope {id := 0x7374616b65686f6c64657273, module := "Architecture", features := (Architecture::stakeholderIds (Architecture::stakeholders))}) (cons (record Scope {id := 0x636f6e6365726e73, module := "Architecture", features := (Architecture::concernIds (Architecture::concerns))}) @@ -67,7 +69,7 @@ (cons (record Scope {id := 0x706f7274666f6c696f, module := "Engine", features := (Engine::strategyIdsOf (Engine::portfolio))}) (cons (record Scope {id := 0x7265616c697a657273, module := "Standards", features := (Standards::declaredIds)}) (cons (record Scope {id := 0x7374646c6962, module := "Research", features := (cons "Foundation.Arch" (cons "Foundation.Qual" (cons "LexLeanStd.Buffer" (cons "LexLeanStd.Text" (cons "LexLeanStd.Sha256" (cons "LexLeanStd.Host" (nil String)))))))}) - (cons (record Scope {id := 0x6a736f6e, module := "Json", features := (Json::features)}) (cons (record Scope {id := 0x766572696669636174696f6e2d7265706f727473, module := "VerificationReport", features := (VerificationReport::features)}) (cons (record Scope {id := 0x766572696669636174696f6e2d657865637574696f6e, module := "ResearchVerification", features := (ResearchVerification::features)}) (nil Scope)))))))))))))))))))))))))))), + (cons (record Scope {id := 0x6a736f6e, module := "Json", features := (Json::features)}) (cons (record Scope {id := 0x766572696669636174696f6e2d7265706f727473, module := "VerificationReport", features := (VerificationReport::features)}) (cons (record Scope {id := 0x766572696669636174696f6e2d657865637574696f6e, module := "ResearchVerification", features := (ResearchVerification::features)}) (nil Scope)))))))))))))))))))))))))))))), axioms: [] } diff --git a/rule30-api/src/ResearchProofTraces.lex.tex b/rule30-api/src/ResearchProofTraces.lex.tex index d633b55..d3abae1 100644 --- a/rule30-api/src/ResearchProofTraces.lex.tex +++ b/rule30-api/src/ResearchProofTraces.lex.tex @@ -193,5 +193,29 @@ proof: decide{}, axioms: [Quot.sound, propext] } + +definition{ + name: wrongReportReply, + parameters: [], + result: (ResearchProof::State * ResearchProof::Emission), + body: (ResearchProof::step (record ResearchProof::State {verification := (ResearchVerificationTraces::commandPending), binding := (input), maxDepth := 32, maxSteps := 1024}) (ctor ResearchVerification::Event.host (ResearchVerificationTraces::spawned))), + axioms: [Quot.sound, propext] +} + +theorem{ + name: unexpectedReportReplyBlocksProofDispatch, + parameters: [], + statement: ((match (second (wrongReportReply)) | ResearchProof::Emission.blocked completion => true | ResearchProof::Emission.complete answer => false | ResearchProof::Emission.host request => false | ResearchProof::Emission.awaiting => false) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} + +theorem{ + name: unexpectedReportReplyHaltsRunnerAndRetainsOwner, + parameters: [], + statement: ((let result : (ResearchRunner::State * ResearchRunner::Action) := (ResearchRunner::proofResult (research) (wrongReportReply)); ((project (first result) halted) && (match (project (first result) proof) | Option.none => false | Option.some owner => true))) = true), + proof: decide{}, + axioms: [Quot.sound, propext] +} \end{semanticmodule} \end{lexlean} diff --git a/rule30-api/src/ResearchRunner.lex.tex b/rule30-api/src/ResearchRunner.lex.tex index 020cb9c..5c81fe1 100644 --- a/rule30-api/src/ResearchRunner.lex.tex +++ b/rule30-api/src/ResearchRunner.lex.tex @@ -5,6 +5,7 @@ \importmodule{Research} \importmodule{ResearchExecution} \importmodule{ResearchProof} +\importmodule{ResearchCandidate} \importmodule{ResearchVerification} \importmodule{VerificationReport} \importmodule{CandidateBinding} @@ -15,7 +16,7 @@ name: boundary, parameters: [], result: String, - body: "The runner composes research attention with local process supervision. A work action requests a concrete strategy job; a review action requires the verified report of a successful process. Inspection and maintenance reports remain distinct from proof verification. A checked proof answer is produced only by the owned ResearchProof verifier after its report is bound to the exact candidate type; the reviewed event refuses externally supplied checked answers. Successful exit alone cannot establish a task. Changed dependencies cancel the active job and discard stale review evidence. A host protocol or cleanup failure halts the runner while preserving its outstanding request for recovery. The generated driver, strategy job construction, source inspection and durable publication remain separate execution-boundary responsibilities.", + body: "The runner composes research attention with local process supervision. A work action requests a concrete strategy job; a review action requires the verified report of a successful process. Inspection and maintenance reports remain distinct from proof verification. Event.candidate owns the local compiler snapshot, derives candidate identities, checks the contextual type and transfers ownership to proof verification. A checked proof answer is produced only by the owned ResearchProof verifier after its report is bound to the exact candidate type; the reviewed event refuses externally supplied checked answers. Successful exit alone cannot establish a task. Changed dependencies cancel the active job and discard stale review evidence. A host protocol or cleanup failure halts the runner while preserving its outstanding request for recovery. The generated driver, strategy job construction, source inspection and durable publication remain separate execution-boundary responsibilities.", executable: true } @@ -23,7 +24,7 @@ name: State, type_parameters: [], parameters: [], - fields: [{name: research, type: Research::State}, {name: execution, type: (Option ResearchExecution::State)}, {name: review, type: (Option ResearchExecution::Completion)}, {name: proof, type: (Option ResearchProof::State)}, {name: halted, type: Bool}] + fields: [{name: research, type: Research::State}, {name: execution, type: (Option ResearchExecution::State)}, {name: review, type: (Option ResearchExecution::Completion)}, {name: proof, type: (Option ResearchProof::State)}, {name: candidate, type: (Option ResearchCandidate::State)}, {name: halted, type: Bool}] } inductive{ @@ -37,7 +38,7 @@ name: Event, type_parameters: [], parameters: [], - constructors: [{name: tick, fields: []}, {name: ingest, fields: [(List Hypotheses::Hypothesis)]}, {name: job, fields: [ResearchExecution::Job]}, {name: proof, fields: [VerificationReport::Pins, ResearchVerification::Config, CandidateBinding::Input, Nat, Nat]}, {name: host, fields: [LexLeanStd.Host::Event]}, {name: reviewed, fields: [Research::Answer]}, {name: changed, fields: [Research::Snapshot, (List Research::Component), (List String)]}, {name: cancel, fields: []}] + constructors: [{name: tick, fields: []}, {name: ingest, fields: [(List Hypotheses::Hypothesis)]}, {name: job, fields: [ResearchExecution::Job]}, {name: proof, fields: [VerificationReport::Pins, ResearchVerification::Config, CandidateBinding::Input, Nat, Nat]}, {name: candidate, fields: [ResearchCandidate::Context]}, {name: host, fields: [LexLeanStd.Host::Event]}, {name: reviewed, fields: [Research::Answer]}, {name: changed, fields: [Research::Snapshot, (List Research::Component), (List String)]}, {name: cancel, fields: []}] } definition{ @@ -52,7 +53,7 @@ name: forward, parameters: [state : State, result : (Research::State * Research::Action)], result: (State * Action), - body: ((record State {research := (first result), execution := (project state execution), review := (project state review), proof := (project state proof), halted := (project state halted)}), (match (second result) + body: ((record State {research := (first result), execution := (project state execution), review := (project state review), proof := (project state proof), candidate := (project state candidate), halted := (project state halted)}), (match (second result) | Research::Action.run request => (ctor Action.work request) | Research::Action.wait => (ctor Action.wait) | Research::Action.idle => (ctor Action.idle) @@ -65,7 +66,7 @@ name: clear, parameters: [research : Research::State, halted : Bool], result: State, - body: (record State {research := research, execution := (ctor Option.none [ResearchExecution::State]), review := (ctor Option.none [ResearchExecution::Completion]), proof := (ctor Option.none [ResearchProof::State]), halted := halted}), + body: (record State {research := research, execution := (ctor Option.none [ResearchExecution::State]), review := (ctor Option.none [ResearchExecution::Completion]), proof := (ctor Option.none [ResearchProof::State]), candidate := (ctor Option.none [ResearchCandidate::State]), halted := halted}), executable: true } @@ -81,14 +82,14 @@ name: completed, parameters: [research : Research::State, execution : ResearchExecution::State, completion : ResearchExecution::Completion], result: (State * Action), - body: (let request : Research::Request := (project completion request); (if (not (ResearchExecution::resumeAllowed completion)) then ((record State {research := research, execution := (ctor Option.some [ResearchExecution::State] execution), review := (ctor Option.none [ResearchExecution::Completion]), proof := (ctor Option.none [ResearchProof::State]), halted := true}), (ctor Action.blocked)) else (if (not (current research request)) then (answer research request (ctor Research::ResultKind.unavailable)) else (match (project completion kind) - | ResearchExecution::EndKind.succeeded => ((record State {research := research, execution := (ctor Option.none [ResearchExecution::State]), review := (ctor Option.some [ResearchExecution::Completion] completion), proof := (ctor Option.none [ResearchProof::State]), halted := false}), (ctor Action.review completion)) + body: (let request : Research::Request := (project completion request); (if (not (ResearchExecution::resumeAllowed completion)) then ((record State {research := research, execution := (ctor Option.some [ResearchExecution::State] execution), review := (ctor Option.none [ResearchExecution::Completion]), proof := (ctor Option.none [ResearchProof::State]), candidate := (ctor Option.none [ResearchCandidate::State]), halted := true}), (ctor Action.blocked)) else (if (not (current research request)) then (answer research request (ctor Research::ResultKind.unavailable)) else (match (project completion kind) + | ResearchExecution::EndKind.succeeded => ((record State {research := research, execution := (ctor Option.none [ResearchExecution::State]), review := (ctor Option.some [ResearchExecution::Completion] completion), proof := (ctor Option.none [ResearchProof::State]), candidate := (ctor Option.none [ResearchCandidate::State]), halted := false}), (ctor Action.review completion)) | ResearchExecution::EndKind.failed => (answer research request (ctor Research::ResultKind.failed (prim utf8_encode (project completion errors) : Bytes))) | ResearchExecution::EndKind.cut => (answer research request (ctor Research::ResultKind.cut)) | ResearchExecution::EndKind.unavailable => (answer research request (ctor Research::ResultKind.unavailable)) - | ResearchExecution::EndKind.protocol => ((record State {research := research, execution := (ctor Option.some [ResearchExecution::State] execution), review := (ctor Option.none [ResearchExecution::Completion]), proof := (ctor Option.none [ResearchProof::State]), halted := true}), (ctor Action.blocked)) - | ResearchExecution::EndKind.cleanupFailed => ((record State {research := research, execution := (ctor Option.some [ResearchExecution::State] execution), review := (ctor Option.none [ResearchExecution::Completion]), proof := (ctor Option.none [ResearchProof::State]), halted := true}), (ctor Action.blocked)) - | ResearchExecution::EndKind.refused => ((record State {research := research, execution := (ctor Option.some [ResearchExecution::State] execution), review := (ctor Option.none [ResearchExecution::Completion]), proof := (ctor Option.none [ResearchProof::State]), halted := true}), (ctor Action.blocked)))))), + | ResearchExecution::EndKind.protocol => ((record State {research := research, execution := (ctor Option.some [ResearchExecution::State] execution), review := (ctor Option.none [ResearchExecution::Completion]), proof := (ctor Option.none [ResearchProof::State]), candidate := (ctor Option.none [ResearchCandidate::State]), halted := true}), (ctor Action.blocked)) + | ResearchExecution::EndKind.cleanupFailed => ((record State {research := research, execution := (ctor Option.some [ResearchExecution::State] execution), review := (ctor Option.none [ResearchExecution::Completion]), proof := (ctor Option.none [ResearchProof::State]), candidate := (ctor Option.none [ResearchCandidate::State]), halted := true}), (ctor Action.blocked)) + | ResearchExecution::EndKind.refused => ((record State {research := research, execution := (ctor Option.some [ResearchExecution::State] execution), review := (ctor Option.none [ResearchExecution::Completion]), proof := (ctor Option.none [ResearchProof::State]), candidate := (ctor Option.none [ResearchCandidate::State]), halted := true}), (ctor Action.blocked)))))), executable: true } @@ -98,8 +99,8 @@ result: (State * Action), body: (match (second result) | ResearchExecution::Emission.complete completion => (completed research (first result) completion) - | ResearchExecution::Emission.awaiting => ((record State {research := research, execution := (ctor Option.some [ResearchExecution::State] (first result)), review := (ctor Option.none [ResearchExecution::Completion]), proof := (ctor Option.none [ResearchProof::State]), halted := false}), (ctor Action.wait)) - | ResearchExecution::Emission.host request => ((record State {research := research, execution := (ctor Option.some [ResearchExecution::State] (first result)), review := (ctor Option.none [ResearchExecution::Completion]), proof := (ctor Option.none [ResearchProof::State]), halted := false}), (ctor Action.host request))), + | ResearchExecution::Emission.awaiting => ((record State {research := research, execution := (ctor Option.some [ResearchExecution::State] (first result)), review := (ctor Option.none [ResearchExecution::Completion]), proof := (ctor Option.none [ResearchProof::State]), candidate := (ctor Option.none [ResearchCandidate::State]), halted := false}), (ctor Action.wait)) + | ResearchExecution::Emission.host request => ((record State {research := research, execution := (ctor Option.some [ResearchExecution::State] (first result)), review := (ctor Option.none [ResearchExecution::Completion]), proof := (ctor Option.none [ResearchProof::State]), candidate := (ctor Option.none [ResearchCandidate::State]), halted := false}), (ctor Action.host request))), executable: true } @@ -150,9 +151,9 @@ parameters: [state : State, result : (Research::State * Research::Action)], result: (State * Action), body: (let research : Research::State := (first result); (match (project state execution) - | Option.some execution => (if (current research (project (project execution job) request)) then ((record State {research := research, execution := (project state execution), review := (project state review), proof := (project state proof), halted := false}), (ctor Action.wait)) else (executionResult research (ResearchExecution::cancel execution))) + | Option.some execution => (if (current research (project (project execution job) request)) then ((record State {research := research, execution := (project state execution), review := (project state review), proof := (project state proof), candidate := (project state candidate), halted := false}), (ctor Action.wait)) else (executionResult research (ResearchExecution::cancel execution))) | Option.none => (match (project state review) - | Option.some completion => (if (current research (project completion request)) then ((record State {research := research, execution := (project state execution), review := (project state review), proof := (project state proof), halted := false}), (ctor Action.review completion)) else (answer research (project completion request) (ctor Research::ResultKind.unavailable))) + | Option.some completion => (if (current research (project completion request)) then ((record State {research := research, execution := (project state execution), review := (project state review), proof := (project state proof), candidate := (project state candidate), halted := false}), (ctor Action.review completion)) else (answer research (project completion request) (ctor Research::ResultKind.unavailable))) | Option.none => (forward state result)))), executable: true } @@ -161,11 +162,11 @@ name: proofResult, parameters: [research : Research::State, result : (ResearchProof::State * ResearchProof::Emission)], result: (State * Action), - body: (let active : State := (record State {research := research, execution := (ctor Option.none [ResearchExecution::State]), review := (ctor Option.none [ResearchExecution::Completion]), proof := (ctor Option.some [ResearchProof::State] (first result)), halted := false}); (match (second result) + body: (let active : State := (record State {research := research, execution := (ctor Option.none [ResearchExecution::State]), review := (ctor Option.none [ResearchExecution::Completion]), proof := (ctor Option.some [ResearchProof::State] (first result)), candidate := (ctor Option.none [ResearchCandidate::State]), halted := false}); (match (second result) | ResearchProof::Emission.host request => (active, (ctor Action.host request)) | ResearchProof::Emission.awaiting => (active, (ctor Action.wait)) | ResearchProof::Emission.complete receipt => (if (current research (project receipt request)) then (forward (clear research false) (Research::receive research receipt)) else (answer research (project receipt request) (ctor Research::ResultKind.unavailable))) - | ResearchProof::Emission.blocked completion => ((record State {research := research, execution := (ctor Option.none [ResearchExecution::State]), review := (ctor Option.none [ResearchExecution::Completion]), proof := (ctor Option.some [ResearchProof::State] (first result)), halted := true}), (ctor Action.blocked)))), + | ResearchProof::Emission.blocked completion => ((record State {research := research, execution := (ctor Option.none [ResearchExecution::State]), review := (ctor Option.none [ResearchExecution::Completion]), proof := (ctor Option.some [ResearchProof::State] (first result)), candidate := (ctor Option.none [ResearchCandidate::State]), halted := true}), (ctor Action.blocked)))), axioms: [], executable: true } @@ -183,13 +184,35 @@ executable: true } +definition{ + name: candidateResult, + parameters: [research : Research::State, result : (ResearchCandidate::State * ResearchProof::Emission)], + result: (State * Action), + body: (let active : State := (record State {research := research, execution := (ctor Option.none [ResearchExecution::State]), review := (ctor Option.none [ResearchExecution::Completion]), proof := (ctor Option.none [ResearchProof::State]), candidate := (ctor Option.some [ResearchCandidate::State] (first result)), halted := false}); (match (second result) + | ResearchProof::Emission.host request => (active, (ctor Action.host request)) + | ResearchProof::Emission.awaiting => (active, (ctor Action.wait)) + | ResearchProof::Emission.complete receipt => (if (current research (project receipt request)) then (forward (clear research false) (Research::receive research receipt)) else (answer research (project receipt request) (ctor Research::ResultKind.unavailable))) + | ResearchProof::Emission.blocked completion => ((record State {research := research, execution := (ctor Option.none [ResearchExecution::State]), review := (ctor Option.none [ResearchExecution::Completion]), proof := (ctor Option.none [ResearchProof::State]), candidate := (ctor Option.some [ResearchCandidate::State] (first result)), halted := true}), (ctor Action.blocked)))), + axioms: [], + executable: true +} + +definition{ + name: startCandidate, + parameters: [state : State, context : ResearchCandidate::Context], + result: (State * Action), + body: (match (project state candidate) | Option.some active => (state, (ctor Action.refused)) | Option.none => (match (project state proof) | Option.some active => (state, (ctor Action.refused)) | Option.none => (match (project state execution) | Option.some active => (state, (ctor Action.refused)) | Option.none => (if ((current (project state research) (project context request)) && (match (project state review) | Option.none => true | Option.some completion => (Research::sameRequest (project completion request) (project context request)))) then (candidateResult (project state research) (ResearchCandidate::begin context)) else (state, (ctor Action.refused)))))), + axioms: [propext], + executable: true +} + definition{ name: reconcile, parameters: [state : State, result : (Research::State * Research::Action)], result: (State * Action), - body: (match (project state proof) + body: (match (project state candidate) | Option.none => (match (project state proof) | Option.none => (reconcileOther state result) - | Option.some proof => (if (current (first result) (project (project (project proof verification) pins) request)) then ((record State {research := (first result), execution := (project state execution), review := (project state review), proof := (project state proof), halted := false}), (ctor Action.wait)) else (proofResult (first result) (ResearchProof::step proof (ctor ResearchVerification::Event.cancel))))), + | Option.some proof => (if (current (first result) (project (project (project proof verification) pins) request)) then ((record State {research := (first result), execution := (project state execution), review := (project state review), proof := (project state proof), candidate := (project state candidate), halted := false}), (ctor Action.wait)) else (proofResult (first result) (ResearchProof::step proof (ctor ResearchVerification::Event.cancel))))) | Option.some candidate => (if (current (first result) (project (project candidate context) request)) then ((record State {research := (first result), execution := (project state execution), review := (project state review), proof := (project state proof), candidate := (project state candidate), halted := false}), (ctor Action.wait)) else (candidateResult (first result) (ResearchCandidate::step candidate (ctor ResearchVerification::Event.cancel))))), axioms: [Quot.sound, propext], executable: true } @@ -198,7 +221,18 @@ name: step, parameters: [state : State, event : Event], result: (State * Action), - body: (if (project state halted) then (state, (ctor Action.blocked)) else (match (project state proof) + body: (if (project state halted) then (state, (ctor Action.blocked)) else (match (project state candidate) + | Option.some candidate => (match event + | Event.host response => (candidateResult (project state research) (ResearchCandidate::step candidate (ctor ResearchVerification::Event.host response))) + | Event.cancel => (candidateResult (project state research) (ResearchCandidate::step candidate (ctor ResearchVerification::Event.cancel))) + | Event.changed snapshot components affected => (reconcile state (Research::step (project state research) (ctor Research::Event.changed snapshot components affected))) + | Event.ingest hypotheses => (reconcile state (Research::step (project state research) (ctor Research::Event.ingest hypotheses))) + | Event.tick => (state, (ctor Action.wait)) + | Event.job job => (state, (ctor Action.refused)) + | Event.proof pins config binding maxDepth maxSteps => (state, (ctor Action.refused)) + | Event.candidate context => (state, (ctor Action.refused)) + | Event.reviewed receipt => (state, (ctor Action.refused))) + | Option.none => (match (project state proof) | Option.some proof => (match event | Event.host response => (proofResult (project state research) (ResearchProof::step proof (ctor ResearchVerification::Event.host response))) | Event.cancel => (proofResult (project state research) (ResearchProof::step proof (ctor ResearchVerification::Event.cancel))) @@ -207,9 +241,11 @@ | Event.tick => (state, (ctor Action.wait)) | Event.job job => (state, (ctor Action.refused)) | Event.proof pins config binding maxDepth maxSteps => (state, (ctor Action.refused)) + | Event.candidate context => (state, (ctor Action.refused)) | Event.reviewed receipt => (state, (ctor Action.refused))) | Option.none => (match event | Event.proof pins config binding maxDepth maxSteps => (startProof state pins config binding maxDepth maxSteps) + | Event.candidate context => (startCandidate state context) | Event.job job => (startJob state job) | Event.reviewed receipt => (reviewed state receipt) | Event.changed snapshot components affected => (reconcile state (Research::step (project state research) (ctor Research::Event.changed snapshot components affected))) @@ -226,7 +262,7 @@ | Option.some execution => (executionResult (project state research) (ResearchExecution::cancel execution)) | Option.none => (match (project state review) | Option.some completion => (answer (project state research) (project completion request) (ctor Research::ResultKind.cut)) - | Option.none => (state, (ctor Action.refused))))))), + | Option.none => (state, (ctor Action.refused)))))))), axioms: [Quot.sound, propext], executable: true, production: {effects: [allocation, files, overflow, process, recursion], targets: [rust-std]} @@ -234,8 +270,8 @@ theorem{ name: haltedRunnerNeverDispatches, - parameters: [research : Research::State, execution : (Option ResearchExecution::State), review : (Option ResearchExecution::Completion), proof : (Option ResearchProof::State), event : Event], - statement: ((step (record State {research := research, execution := execution, review := review, proof := proof, halted := true}) event) = ((record State {research := research, execution := execution, review := review, proof := proof, halted := true}), (ctor Action.blocked))), + parameters: [research : Research::State, execution : (Option ResearchExecution::State), review : (Option ResearchExecution::Completion), proof : (Option ResearchProof::State), candidate : (Option ResearchCandidate::State), event : Event], + statement: ((step (record State {research := research, execution := execution, review := review, proof := proof, candidate := candidate, halted := true}) event) = ((record State {research := research, execution := execution, review := review, proof := proof, candidate := candidate, halted := true}), (ctor Action.blocked))), proof: reflexivity{}, axioms: [Quot.sound, propext] } diff --git a/rule30-api/src/ResearchTraces.lex.tex b/rule30-api/src/ResearchTraces.lex.tex index 2f8bd0a..43a9bf4 100644 --- a/rule30-api/src/ResearchTraces.lex.tex +++ b/rule30-api/src/ResearchTraces.lex.tex @@ -345,7 +345,7 @@ theorem{ name: everyApplicationAndLibraryModuleGetsOneMaintenanceTask, parameters: [], - statement: ((prim length (ResearchCatalog::maintenanceTasks (ResearchCatalog::registeredScopes)) : Nat) = 60), + statement: ((prim length (ResearchCatalog::maintenanceTasks (ResearchCatalog::registeredScopes)) : Nat) = 64), proof: decide{} } definition{ diff --git a/rule30-api/src/ResearchVerification.lex.tex b/rule30-api/src/ResearchVerification.lex.tex index b6e75b0..88e99ca 100644 --- a/rule30-api/src/ResearchVerification.lex.tex +++ b/rule30-api/src/ResearchVerification.lex.tex @@ -267,18 +267,27 @@ executable: true } +definition{ + name: protocol, + parameters: [state : State, reason : String], + result: (State * Emission), + body: (let config : Config := (project state config); (finish state (ctor Outcome.terminated (record ResearchExecution::Completion {request := (project (project state pins) request), kind := (ctor ResearchExecution::EndKind.protocol), code := (ctor Option.none [Int32]), clock := 0, output := (project config output), errors := (project config errors), detail := (prim utf8_encode reason : Bytes)})))), + axioms: [], + executable: true +} + definition{ name: reading, parameters: [state : State, event : LexLeanStd.Host::Event], result: (State * Emission), body: (match (readResponse event) - | Option.none => (finish state (ctor Outcome.rejected "unexpected verification host response")) + | Option.none => (protocol state "unexpected verification host response") | Option.some response => (match (project state cancelled) | Bool.true => (finish state (ctor Outcome.cancelled)) | Bool.false => (match response | Result.error problem => (finish state (ctor Outcome.rejected "verification report read failed")) | Result.ok source => (match (project state phase) | Phase.command => (commandRead state source) | Phase.attestation command => (attestationRead state command source) - | Phase.running => (finish state (ctor Outcome.rejected "no pending verification read")) + | Phase.running => (protocol state "no pending verification read") | Phase.ended => (state, (ctor Emission.awaiting)))))), axioms: [Quot.sound, propext], executable: true diff --git a/rule30-api/src/ResearchVerificationTraces.lex.tex b/rule30-api/src/ResearchVerificationTraces.lex.tex index 4bf003a..efeecd8 100644 --- a/rule30-api/src/ResearchVerificationTraces.lex.tex +++ b/rule30-api/src/ResearchVerificationTraces.lex.tex @@ -401,9 +401,9 @@ } theorem{ - name: outOfOrderHostReplyIsRejected, + name: outOfOrderHostReplyTerminatesProtocol, parameters: [], - statement: ((kind (ResearchVerification::step (commandPending) (ctor ResearchVerification::Event.host (spawned)))) = 3), + statement: ((kind (ResearchVerification::step (commandPending) (ctor ResearchVerification::Event.host (spawned)))) = 5), proof: decide{}, axioms: [Quot.sound, propext] } diff --git a/rule30-lexlean/Core.pdf b/rule30-lexlean/Core.pdf index 3ec8bc1..b156e22 100644 Binary files a/rule30-lexlean/Core.pdf and b/rule30-lexlean/Core.pdf differ diff --git a/rule30-lexlean/pdf/Core.pdf b/rule30-lexlean/pdf/Core.pdf index 3ec8bc1..b156e22 100644 Binary files a/rule30-lexlean/pdf/Core.pdf and b/rule30-lexlean/pdf/Core.pdf differ diff --git a/rule30-paper/Observations.pdf b/rule30-paper/Observations.pdf index 222151e..2ffd21a 100644 Binary files a/rule30-paper/Observations.pdf and b/rule30-paper/Observations.pdf differ diff --git a/rule30-paper/Paper.pdf b/rule30-paper/Paper.pdf index fb007df..52502b5 100644 Binary files a/rule30-paper/Paper.pdf and b/rule30-paper/Paper.pdf differ diff --git a/rule30-paper/pdf/Observations.pdf b/rule30-paper/pdf/Observations.pdf index 222151e..2ffd21a 100644 Binary files a/rule30-paper/pdf/Observations.pdf and b/rule30-paper/pdf/Observations.pdf differ diff --git a/rule30-paper/pdf/Paper.pdf b/rule30-paper/pdf/Paper.pdf index fb007df..52502b5 100644 Binary files a/rule30-paper/pdf/Paper.pdf and b/rule30-paper/pdf/Paper.pdf differ