-
Notifications
You must be signed in to change notification settings - Fork 0
Add curated Edict Rust facade #202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6696e2b
Add curated Edict Rust facade
flyingrobots 78f8c81
Document durable decision policy
flyingrobots 903014e
Merge main into curated Rust facade branch
flyingrobots 53be393
fix(release): advance facade versions during preparation
flyingrobots d56fce9
fix(api): export complete facade artifact value models
flyingrobots f9061bf
test(api): exercise facade operations and consumer boundary
flyingrobots 2134130
docs: give durable decisions a canonical policy owner
flyingrobots 2944cc6
docs: distinguish implemented decisions from planned targets
flyingrobots 735b645
docs: define durable decision relationship records
flyingrobots f9b8ce0
docs: record facade decision contract relationships
flyingrobots 75787a6
Merge main into public Rust facade boundary
flyingrobots e364ee8
fix(release): validate policy calendar dates
flyingrobots File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| [package] | ||
| name = "flyingrobots-edict" | ||
| version = "0.11.0-alpha.1" | ||
| description = "Curated public Rust facade for the Edict compiler and canonical artifacts" | ||
| readme = "README.md" | ||
| edition.workspace = true | ||
| rust-version.workspace = true | ||
| license.workspace = true | ||
| repository.workspace = true | ||
| publish = false | ||
| include = ["src/**", "tests/**", "README.md"] | ||
|
|
||
| [lib] | ||
| name = "edict" | ||
|
|
||
| [dependencies] | ||
| edict-syntax = { path = "../edict-syntax", version = "=0.11.0-alpha.1" } | ||
|
|
||
| [dev-dependencies] | ||
| serde_json = "1" | ||
|
|
||
| [lints] | ||
| workspace = true | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # Edict for Rust | ||
|
|
||
| `flyingrobots-edict` exposes the Rust library name `edict`. It is the curated | ||
| facade for Edict source checking, stable diagnostic classifications, and | ||
| canonical semantic-artifact identity operations. | ||
|
|
||
| The complete application-build boundary remains the JSONL `edict` CLI. This | ||
| facade deliberately does not expose the implementation crate's full module | ||
| tree. | ||
|
|
||
| ```rust | ||
| use edict::{check, CheckOutcome}; | ||
|
|
||
| assert_eq!( | ||
| check("package examples.public_facade@1;\n"), | ||
| CheckOutcome::Valid | ||
| ); | ||
| ``` | ||
|
|
||
| ## Publication status | ||
|
|
||
| This package currently has `publish = false`. Its archive and dependency | ||
| closure are under release-engineering review. Nothing in this package grants | ||
| permission to publish it to crates.io. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| //! Curated public Rust facade for Edict. | ||
| //! | ||
| //! The [`check`] entry point is the supported one-call source check. Stable | ||
| //! failure classifications are grouped under [`diagnostic`], while canonical | ||
| //! semantic-artifact identity operations are grouped under [`artifact`]. The | ||
| //! implementation crate's broad module tree is intentionally not re-exported. | ||
| //! | ||
| //! ``` | ||
| //! use edict::{check, CheckOutcome}; | ||
| //! | ||
| //! assert_eq!( | ||
| //! check("package examples.public_facade@1;\n"), | ||
| //! CheckOutcome::Valid | ||
| //! ); | ||
| //! ``` | ||
| //! | ||
| //! Implementation modules are not part of this facade: | ||
| //! | ||
| //! ```compile_fail | ||
| //! use edict::parser::parse_module; | ||
| //! ``` | ||
|
|
||
| pub use edict_syntax::{check, CheckOutcome}; | ||
|
|
||
| /// Stable machine-usable failure classifications exposed by the public | ||
| /// facade. | ||
| pub mod diagnostic { | ||
| pub use edict_syntax::{ | ||
| CanonicalError, CanonicalErrorKind, CompilerError, CompilerErrorKind, CompilerStage, | ||
| ParseError, ParseErrorKind, ResultProjectionFailure, ResultProjectionFailureKind, | ||
| SemanticError, SemanticErrorKind, Span, TargetLoweringFailure, TargetLoweringFailureKind, | ||
| }; | ||
| } | ||
|
|
||
| /// Canonical semantic-artifact values, encoders, and domain-framed identity | ||
| /// operations. Nested value models are exported so callers can construct | ||
| /// candidates and inspect results without importing implementation modules. | ||
| pub mod artifact { | ||
| pub use edict_syntax::{ | ||
| decode_canonical_cbor, decode_result_projection, digest_core_module, | ||
| digest_result_projection, digest_target_ir_artifact, encode_core_module, | ||
| encode_result_projection, encode_target_ir_artifact, verify_result_projection, | ||
|
flyingrobots marked this conversation as resolved.
|
||
| CanonicalError, CanonicalErrorKind, CanonicalValue, CompareOp, CoreBlock, CoreBound, | ||
| CoreBudget, CoreDigest, CoreExpr, CoreExternalActionBudget, CoreImport, CoreImportKind, | ||
| CoreIntent, CoreModule, CoreNode, CoreObstructionArm, CoreObstructionReason, CorePredicate, | ||
| CoreRequireFailureArm, CoreType, CoreValue, InputConstraint, InputConstraintSource, | ||
| LocalRef, ResourceRef, ResultProjection, ResultProjectionArtifact, ResultProjectionExpr, | ||
| ResultProjectionFailure, ResultProjectionFailureKind, ResultProjectionSource, | ||
| TargetIrArtifact, TargetIrExternalActionRequest, TargetIrIntent, TargetIrPureBinding, | ||
| TargetIrRequireFailure, TargetIrRequirement, TargetIrSemanticClosure, TargetIrStep, | ||
| VerifiedResultProjection, | ||
| }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| //! Separate consumer crate: every Edict name comes from the curated facade. | ||
| use std::collections::BTreeMap; | ||
|
|
||
| use edict::{ | ||
| artifact::{ | ||
| decode_canonical_cbor, decode_result_projection, digest_core_module, | ||
| digest_result_projection, digest_target_ir_artifact, encode_core_module, | ||
| encode_result_projection, encode_target_ir_artifact, verify_result_projection, | ||
| CanonicalValue, CoreBlock, CoreBudget, CoreExpr, CoreIntent, CoreModule, CoreType, | ||
| LocalRef, ResourceRef, ResultProjection, ResultProjectionExpr, ResultProjectionSource, | ||
| TargetIrArtifact, TargetIrIntent, TargetIrSemanticClosure, VerifiedResultProjection, | ||
| }, | ||
| check, | ||
| diagnostic::Span, | ||
| CheckOutcome, | ||
| }; | ||
|
|
||
| fn core_fixture() -> CoreModule { | ||
| let input = LocalRef { | ||
| id: "arg.0".to_owned(), | ||
| alpha_name: "input".to_owned(), | ||
| ty: "examples.facade@1.Input".to_owned(), | ||
| }; | ||
| let result = CoreExpr::Local { | ||
| reference: input.clone(), | ||
| }; | ||
| CoreModule { | ||
| api_version: "edict.core/v1".to_owned(), | ||
| coordinate: "examples.facade@1".to_owned(), | ||
| imports: Vec::new(), | ||
| types: BTreeMap::from([( | ||
| "Input".to_owned(), | ||
| CoreType::Record { | ||
| fields: BTreeMap::from([("ok".to_owned(), "Bool".to_owned())]), | ||
| }, | ||
| )]), | ||
| intents: BTreeMap::from([( | ||
| "echo".to_owned(), | ||
| CoreIntent { | ||
| input: input.ty.clone(), | ||
| output: input.ty.clone(), | ||
| required_operation_profile: "continuum.profile.read-only/v1".to_owned(), | ||
| basis: Some(result.clone()), | ||
| input_constraints: Vec::new(), | ||
| core_evaluation_budget: CoreBudget { | ||
| max_steps: 8, | ||
| max_allocated_bytes: 256, | ||
| max_output_bytes: 64, | ||
| }, | ||
| body: CoreBlock { | ||
| locals: vec![input], | ||
| nodes: Vec::new(), | ||
| result, | ||
| }, | ||
| }, | ||
| )]), | ||
| required_core_capabilities: Vec::new(), | ||
| } | ||
| } | ||
|
|
||
| fn target_fixture(core: &CoreModule) -> TargetIrArtifact { | ||
| let intent = &core.intents["echo"]; | ||
| TargetIrArtifact { | ||
| domain: "echo.span-ir/v1".to_owned(), | ||
| target_profile: ResourceRef { | ||
| coordinate: "echo.dpo@1".to_owned(), | ||
| digest: Some(format!("sha256:{}", "1".repeat(64))), | ||
| }, | ||
| source_core_coordinate: core.coordinate.clone(), | ||
| semantic_closure: Some(TargetIrSemanticClosure { | ||
| source_core: ResourceRef { | ||
| coordinate: core.coordinate.clone(), | ||
| digest: Some( | ||
| digest_core_module(core) | ||
| .expect("Core digest") | ||
| .to_review_string(), | ||
| ), | ||
| }, | ||
| lawpacks: Vec::new(), | ||
| capabilities: Vec::new(), | ||
| }), | ||
| intents: BTreeMap::from([( | ||
| "echo".to_owned(), | ||
| TargetIrIntent { | ||
| operation_profile: intent.required_operation_profile.clone(), | ||
| basis: intent.basis.clone(), | ||
| input_constraints: intent.input_constraints.clone(), | ||
| core_evaluation_budget: intent.core_evaluation_budget.clone(), | ||
| pure_bindings: Vec::new(), | ||
| requirements: Vec::new(), | ||
| steps: Vec::new(), | ||
| external_action_requests: Vec::new(), | ||
| result: intent.body.result.clone(), | ||
| }, | ||
| )]), | ||
| } | ||
| } | ||
|
|
||
| #[test] | ||
| fn facade_consumer_constructs_and_verifies_artifacts() { | ||
| let core = core_fixture(); | ||
| let target = target_fixture(&core); | ||
| let projection = ResultProjection { | ||
| api_version: "edict.result-projection/v1".to_owned(), | ||
| operation_coordinate: "examples.facade@1.echo".to_owned(), | ||
| output_type: "examples.facade@1.Input".to_owned(), | ||
| max_output_bytes: 64, | ||
| expression: ResultProjectionExpr::Source { | ||
| source: ResultProjectionSource::ApplicationInput, | ||
| path: Vec::new(), | ||
| }, | ||
| }; | ||
|
|
||
| let core_bytes = encode_core_module(&core).expect("encode consumer Core"); | ||
| let target_bytes = encode_target_ir_artifact(&target).expect("encode consumer Target IR"); | ||
| let projection_bytes = encode_result_projection(&projection).expect("encode projection"); | ||
| let decoded: CanonicalValue = decode_canonical_cbor(&core_bytes).expect("decode Core value"); | ||
| assert!(matches!(decoded, CanonicalValue::Map(_))); | ||
| assert!(matches!( | ||
| decode_canonical_cbor(&target_bytes).expect("decode Target IR value"), | ||
| CanonicalValue::Map(_) | ||
| )); | ||
| assert_eq!( | ||
| decode_result_projection(&projection_bytes).expect("decode projection"), | ||
| projection | ||
| ); | ||
| let projection_digest = digest_result_projection(&projection).expect("projection digest"); | ||
| let verified: VerifiedResultProjection = | ||
| verify_result_projection(&core, &target, "echo", &projection_bytes, projection_digest) | ||
| .expect("independently verify consumer projection"); | ||
| assert_eq!(verified.projection(), &projection); | ||
| assert_eq!(verified.digest(), projection_digest); | ||
| assert_ne!( | ||
| digest_core_module(&core).expect("Core identity"), | ||
| digest_target_ir_artifact(&target).expect("Target IR identity") | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn facade_consumer_names_diagnostic_spans() { | ||
| let CheckOutcome::ParseFailed(error) = check("package ;") else { | ||
| panic!("malformed package must fail parsing"); | ||
| }; | ||
| let span: Span = error.span; | ||
| assert_eq!(span, Span { start: 8, end: 9 }); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.