Repository navigation
Emitted-closure artifact: five typed name projections, library identifier collapsed, guard over the derived population #12358
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| module gunbc.emitted_closure_artifact | ||
|
|
||
| import std.types { NonEmptyStr } | ||
| import v2.std.text { String } | ||
|
|
||
| // ONE ARTIFACT, FIVE PROJECTIONS, AND THEY ARE SEPARATELY TYPED BECAUSE THEY ARE SEPARATELY | ||
| // CHOSEN. An emitted closure is one artifact, but the names around it answer different questions to | ||
| // different readers: Cargo resolves a PACKAGE, rustc and every `use` line resolve a LIBRARY | ||
| // IDENTIFIER, a build produces a BINARY TARGET, the route addresses a content SLUG, and authored | ||
| // Rust spells an IMPORT ALIAS. Collapsing them into one `String` is what let two sites author the | ||
| // same fact independently while each looked locally reasonable, and it is why a census over textual | ||
| // mentions could not tell a package name from a library name. Distinct types make the confusion | ||
| // unrepresentable rather than merely discouraged. | ||
| type CargoPackageName { name: NonEmptyStr } | ||
|
|
||
| type RustLibraryIdentifier { identifier: NonEmptyStr } | ||
|
|
||
| type BinaryTargetName { name: NonEmptyStr } | ||
|
|
||
| type EmittedArtifactSlug { slug: NonEmptyStr } | ||
|
|
||
| type SourceVisibleImportAlias { alias: NonEmptyStr } | ||
|
|
||
| type EmittedClosureArtifact { | ||
| slug: EmittedArtifactSlug | ||
| cargo_package: CargoPackageName | ||
| rust_library: RustLibraryIdentifier | ||
| binary_target: BinaryTargetName | ||
| import_alias: SourceVisibleImportAlias | ||
| } | ||
|
|
||
| // THE LIBRARY IDENTIFIER IS THE LOAD-BEARING ONE, AND IT IS THE ONLY ONE AUTHORED RUST DEPENDS ON. | ||
| // Every `use <name>::…` in a hand-authored shim resolves this and nothing else, so it is the fact a | ||
| // rename must move and the fact a drift check must compare against. The other four are derived, | ||
| // addressed or chosen per artifact: the route's own package is `gunbc-emitted-closure-<slug>` while | ||
| // the curated probe's package is chosen differently, and neither of those choices changes what a | ||
| // `use` line resolves. | ||
| data emitted_closure_rust_library: RustLibraryIdentifier = RustLibraryIdentifier { | ||
| identifier: "v1_compiled" as NonEmptyStr | ||
| } | ||
|
|
||
| fn emitted_closure_rust_library_text() -> String { | ||
| emitted_closure_rust_library.identifier | ||
| } | ||
|
|
||
| // THE SOURCE-VISIBLE ALIAS EQUALS THE LIBRARY IDENTIFIER TODAY, AND THAT COINCIDENCE IS THE WHOLE | ||
| // REASON THE RENAME IS NOT CHEAP YET. Authored Rust names the physical library directly rather than | ||
| // an alias the build could redirect, so the physical name appears in every shim body and a rename | ||
| // has to edit them all. When the artifact owner lands a generated stable alias -- through Cargo, a | ||
| // shared adapter or a generated prelude -- this projection stops equalling the one below it, the | ||
| // shim bodies name the alias, and renaming the physical library becomes one authority edit plus | ||
| // regenerated projections. | ||
| fn emitted_closure_import_alias() -> SourceVisibleImportAlias { | ||
| SourceVisibleImportAlias { alias: emitted_closure_rust_library.identifier } | ||
| } | ||
|
|
||
| // THE CURATED PROBE'S PACKAGE NAME IS DERIVED FROM THE LIBRARY IDENTIFIER, NOT CHOSEN BESIDE IT, and | ||
| // stating the direction is the point. Cargo derives a package's default library name from the | ||
| // package name, and the curated probe's shims `use` the library -- so that probe's package name is | ||
| // a MEANS of fixing the library identifier the shims resolve. Authoring it as its own literal made | ||
| // it look like an independent choice, which is exactly how it drifted out of reach of the emitter's | ||
| // own home for the same fact. | ||
| fn curated_probe_cargo_package() -> CargoPackageName { | ||
| CargoPackageName { name: emitted_closure_rust_library.identifier } | ||
| } | ||
|
|
||
| fn curated_probe_cargo_package_text() -> String { | ||
| curated_probe_cargo_package().name | ||
| } | ||
|
|
||
| // THE ROUTE'S PACKAGE AND BINARY TARGET ARE SLUG-DERIVED, and they are modeled here so that a reader | ||
| // asking "what is this artifact called" finds one place carrying all five answers rather than | ||
| // discovering a second naming scheme in host Rust. The slug itself is produced by the emitting host | ||
| // from the entry path; this projection states the SHAPE the host renders, and a future consolidation | ||
| // of that host site consumes it rather than respelling the prefix. | ||
| data emitted_closure_package_prefix: String = "gunbc-emitted-closure-" | ||
|
|
||
| fn emitted_closure_cargo_package(slug: EmittedArtifactSlug) -> CargoPackageName { | ||
| CargoPackageName { name: concat(emitted_closure_package_prefix, slug.slug) as NonEmptyStr } | ||
| } | ||
|
|
||
| fn emitted_closure_binary_target(slug: EmittedArtifactSlug) -> BinaryTargetName { | ||
| BinaryTargetName { name: concat(emitted_closure_package_prefix, slug.slug) as NonEmptyStr } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| module test.claim.emitted_closure_artifact_witness_test | ||
|
|
||
| import gunbc.emitted_closure_artifact { | ||
| emitted_closure_rust_library_text, | ||
| emitted_closure_cargo_package, | ||
| emitted_closure_binary_target, | ||
| curated_probe_cargo_package_text, | ||
| emitted_closure_import_alias, | ||
| EmittedArtifactSlug | ||
| } | ||
| import tools.self_host_curated_seed_linked_harness { cssl_v1_compiled_cargo_package_header } | ||
| import std.types { Bool, NonEmptyStr, String } | ||
| import v2.std.live_tree { LiveTreeDisposition, SubstrateInputsOnly } | ||
|
|
||
| data live_tree_disposition: LiveTreeDisposition = SubstrateInputsOnly | ||
|
|
||
| // THE COLLAPSE PRESERVED GENERATED BYTES, AND THIS IS THE ORACLE THAT SAYS SO RATHER THAN AN | ||
| // ARGUMENT THAT IT MUST HAVE. The curated probe's manifest header used to carry the library | ||
| // identifier as its own literal; it now renders that identifier from the single authority. Those are | ||
| // two different constructions of one string, so the only honest check is that the string did not | ||
| // move. The expected value here is a controlled literal -- the bytes as they stood before the | ||
| // collapse -- which is what makes this a pin and not a measurement compared against itself. | ||
| data expected_probe_manifest_header: String = "[package]\nname = \"v1_compiled\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n[features]\ntext_lookup_work_counter = []\n\n" | ||
|
|
||
| test fn the_collapsed_manifest_header_renders_the_same_bytes_holds() -> Bool { | ||
| cssl_v1_compiled_cargo_package_header() == expected_probe_manifest_header | ||
| } | ||
|
|
||
| // THE CURATED PROBE'S PACKAGE NAME IS DERIVED FROM THE LIBRARY IDENTIFIER, and asserting the | ||
| // equality states the DIRECTION the model now carries: Cargo derives a package's default library | ||
| // name from its package name, and the probe's shims resolve the library, so that package name is a | ||
| // means of fixing the identifier rather than an independent choice beside it. | ||
| test fn the_curated_probe_package_is_the_library_identifier_holds() -> Bool { | ||
| curated_probe_cargo_package_text() == emitted_closure_rust_library_text() | ||
| } | ||
|
|
||
| // THE ROUTE'S PACKAGE AND BINARY TARGET ARE SLUG-DERIVED AND ARE NOT THE LIBRARY IDENTIFIER. This is | ||
| // the second naming scheme the census found, modeled here so a reader finds both answers in one | ||
| // place; the claim keeps them separable, so a later consolidation that accidentally collapsed the two | ||
| // schemes into one string would go red here rather than silently rename a `use` line's target. | ||
| test fn the_route_package_and_binary_are_slug_derived_holds() -> Bool { | ||
| let s = EmittedArtifactSlug { slug: "src-v2-cli-compile-cli-dag" as NonEmptyStr } | ||
| (emitted_closure_cargo_package(slug: s).name != emitted_closure_rust_library_text()) | ||
| && (emitted_closure_binary_target(slug: s).name == emitted_closure_cargo_package(slug: s).name) | ||
| } | ||
|
|
||
| // THE IMPORT ALIAS STILL EQUALS THE PHYSICAL LIBRARY, AND THAT IS THE RENAME PRECONDITION STATED AS | ||
| // AN EXECUTING CLAIM RATHER THAN A PLAN. While this holds, authored Rust names the physical library | ||
| // directly, so renaming it edits every shim body. When the artifact owner lands a generated stable | ||
| // alias, this claim is the one that must be INVERTED -- and its inversion is the mechanical signal | ||
| // that the cheap rename has become available, which is a better trigger than a human remembering. | ||
| test fn the_import_alias_still_equals_the_physical_library_holds() -> Bool { | ||
| emitted_closure_import_alias().alias == emitted_closure_rust_library_text() | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,14 @@ | ||
| module test.claim.rust_item_host_observation_witness_test | ||
|
|
||
| import gunbc.emitted_closure_artifact { | ||
| emitted_closure_rust_library_text, | ||
| emitted_closure_cargo_package, | ||
| EmittedArtifactSlug | ||
| } | ||
| import gunbc.rust_item_host_observation { | ||
| rust_source_namespace_rows, | ||
| rust_source_prefix_tooling, | ||
| RustSourceNamespaceRow, | ||
| RustObservedTree, | ||
| HunkRangeParsed, | ||
| HunkRangeRefused, | ||
|
|
@@ -51,7 +59,7 @@ import gunbc.capability_origin { | |
| } | ||
| import std.decl_ref { DeclarationRef, WholeDeclaration } | ||
| import std.types { Bool, Int, List, NonEmptyStr, String } | ||
| import v2.std.algebra { any, length, list_map } | ||
| import v2.std.algebra { any, fold_list, length, list_map } | ||
| import v2.std.live_tree { LiveTreeDisposition, SubstrateInputsOnly } | ||
|
|
||
| data planted_observed_tree: RustObservedTree = RustObservedTree { revision: "0000000000000000000000000000000000000001", tree: "0000000000000000000000000000000000000002" } | ||
|
|
@@ -731,3 +739,46 @@ test fn the_reference_population_is_empty_under_an_empty_token_list() -> Bool { | |
| RustReferenceHostRefused { detail: _ } => false | ||
| } | ||
| } | ||
|
|
||
|
|
||
| // TRANSITIONAL GUARD OVER THE STRUCTURALLY DERIVED SHIM POPULATION, AND EVERY WORD OF THAT IS LOAD | ||
| // BEARING. The population is the tooling PREFIX, not a hand list of shim directories, so a shim | ||
| // added tomorrow is covered without anybody enrolling it -- which is the property a per-file roster | ||
| // could not have. It reads MODELED ROWS and never file text, so prose mentioning the name cannot | ||
| // make it red and cannot make it green. And it compares against the LIBRARY IDENTIFIER rather than | ||
| // any package name, because a `use` line resolves the library and nothing else. | ||
| // WHY IT IS TRANSITIONAL: it does not remove the restatements in authored shim bodies, it only makes | ||
| // their drift unlandable. DISSOLUTION: it dissolves when authored Rust no longer spells the physical | ||
| // library name at all -- when the artifact owner lands a generated stable alias through Cargo, a | ||
| // shared adapter or a generated prelude -- because at that point no authored body carries the name | ||
| // and there is nothing left to drift. The decisive witness for that state is that a second planted | ||
| // rename touches one authority and its generated projections while requiring ZERO hand-authored Rust | ||
| // edits; until that witness exists this guard stays enrolled. | ||
| fn g_tooling_namespace_prefix() -> String { | ||
| fold_list( | ||
| xs: rust_source_namespace_rows, | ||
| empty: "", | ||
| cons: fn(acc, row) { | ||
| if row.repo_prefix == rust_source_prefix_tooling { row.namespace_prefix } else { acc } | ||
| } | ||
|
Comment on lines
+757
to
+763
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a shim under Useful? React with 👍 / 👎. |
||
| ) | ||
| } | ||
|
|
||
| test fn the_tooling_rust_namespace_derives_from_the_library_identifier_holds() -> Bool { | ||
| g_tooling_namespace_prefix() == concat(emitted_closure_rust_library_text(), ".") | ||
| } | ||
|
|
||
| // THE POPULATION MUST NOT BE EMPTY OR UNRESOLVED, because an empty fold above returns "" and an | ||
| // equality against "" would make this suite green precisely when the row it guards had been deleted. | ||
| test fn an_absent_tooling_namespace_row_is_refused_holds() -> Bool { | ||
| (g_tooling_namespace_prefix() != "") && (emitted_closure_rust_library_text() != "") | ||
| } | ||
|
|
||
| // THE GUARD COMPARES A LIBRARY IDENTIFIER AND NOT A PACKAGE NAME, and this is the discriminator that | ||
| // says so rather than a comment claiming it. The route's package name is slug-derived and is a | ||
| // DIFFERENT string from the library identifier, so a guard that had reached for a package name would | ||
| // fail this claim instead of quietly comparing the wrong fact. | ||
| test fn the_route_package_name_is_not_the_library_identifier_holds() -> Bool { | ||
| emitted_closure_cargo_package(slug: EmittedArtifactSlug { slug: "src-v2-cli-compile-cli-dag" as NonEmptyStr }).name | ||
| != emitted_closure_rust_library_text() | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When this new authority is changed for a rename, only the curated harness manifest changes:
emit_rust_selectedstill selects the literalv1_compiledinsrc/v1/05_emit_rust.dag:3553, andprobe_manifeststill renders that literal insrc/v1/stage0/src/emitted_closure_compile_host.rs:619. The resulting crates and generated self-references therefore disagree with the purported canonical value, so the advertised one-authority rename breaks emission/native probes unless those independent literals are also edited. Wire these producers to the same projection, or avoid presenting this value as the canonical library identifier.Useful? React with 👍 / 👎.