Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module gunbc.recurring_failure_mode.a_string_literal_attests_an_emitted_reference

import std.types { NonEmptyStr }
import gunbc.recurring_failure_mode { RecurringFailureMode }

data a_string_literal_attests_an_emitted_reference: RecurringFailureMode = RecurringFailureMode {
identity: "a_string_literal_attests_an_emitted_reference" as NonEmptyStr,

receipts: [
"a string literal attests an emitted reference: a gate that must decide whether a name is SPELLED IN EMITTED CODE reads the emitted text whole, so a name that appears only inside a string literal -- prose the program carries as data -- passes as though the code paths into it. The Rust emitter's reference-derived use-line pass (v1.compiler.emit_rust reference_derived_use_line_plan) admits a proposed candidate only when its name is among the emitted source's identifier tokens; that attestation exists to reject misproposed candidates, and a prose mention defeated it.",

"SPECIMEN, found 2026-09-24 by the Pkg7e emitted-workspace plan (v2.workflow.emitted_crate_workspace), whose edge merge refused with EmitterReverseEdge std_content_hash -> v2_std_node. std.content_hash's grounding note names `v2.std.node.Hash`; a candidate `Hash` (v2.std.node declares `type Hash = Fnv1a64Structural`, an alias of std.content_hash's own type) passed the token gate on that prose, and std_content_hash.rs emitted `pub use crate::v2_std_node::\{Hash\};` -- used by nothing, harmless in one crate, and a reverse edge in any partition because v2.std.node imports std.content_hash.",

"REPAIR at the gate, the earliest link that could not be justified: rust_code_outside_string_literals removes escaped backslashes and quotes, splits on the remaining quote characters and keeps the segments outside literals, and the emitted-token set is built from that. Measured: over a closure entering at v2.std.node the use-line is present before and absent after; across the whole seed the second generation drops eleven use-lines from six mirrors (v1.compiler.emit, emit_rust, infer, trait_derive_emit, gunbc occurrence_binding_parser_walk, and one claim module), every one a name that occurs in that module only inside a string literal; the seed compiles without them, and the following generation is a fixed point.",

"SECOND ARM, same gate, found when the first repair did not clear the partition: over the full v2.compiler.compile closure std_content_hash still emitted the Hash use-line, because its code carries `#[derive(..., std::hash::Hash)]` and the tokenizer splits on colons, so a segment inside a qualified path attested the bare name. rust_qualified_segments_marked prefixes every segment after `::` with `@`, which no identifier carries; a path head stays a token, so `Parent::Variant` still attests Parent. Across the seed the next generations drop the remaining dead re-exports whose names occur only as qualified segments (v1_compiler_emit_rust, infer, infer_resolve, parse, trait_derive_emit), the seed compiles, and the third generation is a fixed point.",

"RUNG: mitigatable -- the partition's typed EmitterReverseEdge refusal is what exposed it, and the multi-crate build is what would fail. ATTAINABLE CEILING: structurally guaranteed. NEXT-RUNG TRIGGER, at capability grain: use-lines derived from the EMITTED REFERENCE SET the renderers return (the stall gunbc.guarantee_stall emitted_inline_crate_path_edges_unreturned_stall names that capability), sufficient for no text gate to exist at all.",
],

evidence: [],
}
30 changes: 29 additions & 1 deletion src/v1/05_emit_rust.dag
Original file line number Diff line number Diff line change
Expand Up @@ -4693,6 +4693,34 @@ fn reference_derived_candidate_authored(module_source: String, name: String, typ
// UNREFUTED rather than proven: the two-arm measurement below moved 20 use-lines and every one is
// explained by the GATE, so nothing in it exhibits a producer-side change -- but nothing in it
// positively rules one out either.
// THE EMITTED-TEXT ATTESTATION READS CODE, NOT STRING CONTENTS. A candidate use-line is admitted
// only when its name is spelled in the module's own emitted text, and that gate exists to reject a
// misproposed candidate -- but a name inside a string literal is prose the program carries as data,
// not a path the emitted code takes. Measured: std.content_hash's grounding note mentions
// `v2.std.node.Hash`, so a proposed `Hash` passed the gate and the module emitted
// `pub use crate::v2_std_node::{Hash};`, an import nothing uses and a reverse edge the crate
// partition refuses (v2.std.node imports std.content_hash). Escaped backslashes and quotes are
// removed first, so the quote characters left delimit literals; the odd segments are their bodies.
fn rust_code_outside_string_literals(s: String) -> String {
replace(replace(s, "\\\\", " "), "\\\"", " ")
|> split(delimiter: "\"")
|> enumerate
|> filter(pair => pair.first % 2 == 0)
|> map(pair => pair.second)
|> join(separator: " ")
}

// A SEGMENT AFTER `::` IS PART OF A PATH, NOT A BARE REFERENCE. The emitted-text attestation asks
// whether the code spells a name that a bare use-line would have to bind; `std::hash::Hash` in a
// derive attribute spells the std trait by full path and binds nothing, yet the tokenizer split it
// into `std`, `hash`, `Hash` and so attested a proposed `Hash`, emitting
// `pub use crate::v2_std_node::\{Hash\};` into std_content_hash over the v2.compiler.compile closure.
// Each segment that follows `::` is prefixed with `@`, which no identifier carries, so it never equals
// a candidate; a path HEAD stays a token, so `Parent::Variant` still attests `Parent`.
fn rust_qualified_segments_marked(s: String) -> String {
replace(s, "::", " @")
}

fn rust_identifier_tokens(s: String) -> List<String> {
let spaced = replace(replace(replace(replace(replace(replace(replace(replace(replace(s,
"<", " "), ">", " "), ",", " "), "(", " "), ")", " "), "[", " "), "]", " "), "&", " "), ":", " ")
Expand Down Expand Up @@ -5236,7 +5264,7 @@ fn reference_derived_use_line_plan(items: List<Node>, unlisted_type_names: List<
let variant_payload_structs = expand_variant_payload_struct_imports(names: type_surface_names, type_summaries: emit_info.type_summaries, variant_to_enum: emit_info.variant_to_enum)
let emitter_attested_anon_heads = unique_strings(items: items |> flat_map(item => collect_anonymous_record_lit_heads(n: item, source_indices: source_indices, type_summaries: emit_info.type_summaries)))
let realized_surface_names = unique_strings(items: items |> flat_map(item => collect_item_realized_surface_names(item: item, shared_types: shared_types, source_indices: source_indices, emit_info: emit_info)))
let emitted_source_tokens = rust_identifier_tokens(s: emitted_source)
let emitted_source_tokens = rust_identifier_tokens(s: rust_qualified_segments_marked(s: rust_code_outside_string_literals(s: emitted_source)))
let emitted_source_token_set = emitted_source_tokens
|> fold(init: empty_map(), f: (acc, t) => map_insert(acc, t, true))
let origin_candidates = repair_input_origin_candidates(
Expand Down
1 change: 0 additions & 1 deletion src/v1/stage0/src/v1_compiler_emit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use self::TransportBindingRefusal::*;
pub use crate::extdeps_languages_go_emit::go_method_templates_flat;
pub use crate::extdeps_languages_python_emit::python_method_templates_flat;
pub use crate::extdeps_languages_rust_emit::rust_method_templates;
pub use crate::std_coercion::TypeCheckpoint;
pub use crate::std_coercion::TypeDeclarationProvenance;
use crate::std_coercion::TypeDeclarationProvenance::DeclarationIdentityAbsent;
pub use crate::std_coercion::TypeRealizationDecision;
Expand Down
54 changes: 48 additions & 6 deletions src/v1/stage0/src/v1_compiler_emit_rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,18 @@ pub use crate::gunbc_structural_realization_bindings::{
structural_connective_rows, structural_ordering_rows,
};
pub use crate::std_algebra::AlgebraFieldTemplate;
pub use crate::std_algebra::FreeMonoid;
pub use crate::std_algebra::{is_collection_filter_template, trim};
pub use crate::std_coercion::TypeCheckpoint;
use crate::std_coercion::TypeDeclarationProvenance::{
CorpusDeclared, DeclarationIdentityAbsent, KernelMinted,
};
use crate::std_coercion::TypeRealizationDecision::*;
pub use crate::std_coercion::{TypeDeclarationProvenance, TypeRealizationDecision};
pub use crate::std_content_hash::Fnv1a64Structural;
pub use crate::std_decl_ref::decl_ref;
use crate::std_decl_ref::DeclField::WholeDeclaration;
pub use crate::std_decl_ref::{DeclField, DeclarationRef};
use crate::std_induction::SubValueRelation::SubValueUnknown;
pub use crate::std_induction::{InductiveField, SubValueRelation};
pub use crate::std_measure::millisecond_count;
pub use crate::std_nat::Nat;
pub use crate::std_occurrence_identity::NodeOccurrenceIdentity;
use crate::std_occurrence_identity::NodeOccurrenceIdentity::OccurrenceSynthetic;
use crate::std_operator_realization::HostRealizationReason::{
Expand Down Expand Up @@ -136,7 +132,6 @@ pub use crate::v1_compiler_coercion::{
};
pub use crate::v1_compiler_compiler_tests_rust::compiler_tests_source;
pub use crate::v1_compiler_dag_collect_support::connective_name;
pub use crate::v1_compiler_emit::render_target_name;
use crate::v1_compiler_emit::BoundOperation::{
BindingRefused, FileBound, LocalBound, RestBound, ShellBound,
};
Expand Down Expand Up @@ -9380,6 +9375,51 @@ pub fn reference_derived_candidate_authored(
))
}

pub fn rust_code_outside_string_literals(s: String) -> String {
Rc::new({
let mut __result = Vec::new();
for pair in Rc::new({
let mut __result = Vec::new();
for pair in Rc::new(
Rc::new(
v1_rt::replace(
v1_rt::replace(s.clone(), "\\\\".to_string(), " ".to_string()),
"\\\"".to_string(),
" ".to_string(),
)
.split(&"\"".to_string())
.map(|s| s.to_string())
.collect::<Vec<_>>(),
)
.iter()
.cloned()
.enumerate()
.map(|(i, v)| (i as i64, v))
.collect::<Vec<_>>(),
)
.iter()
.cloned()
{
if ((pair.0.clone() % 2) == 0) {
__result.push(pair);
}
}
__result
})
.iter()
.cloned()
{
__result.push(pair.1.clone());
}
__result
})
.join(&" ".to_string())
}

pub fn rust_qualified_segments_marked(s: String) -> String {
v1_rt::replace(s.clone(), "::".to_string(), " @".to_string())
}

pub fn rust_identifier_tokens(s: String) -> Rc<Vec<String>> {
{
let spaced = v1_rt::replace(
Expand Down Expand Up @@ -10062,7 +10102,9 @@ pub fn reference_derived_use_line_plan(
}
__result
}));
let emitted_source_tokens = rust_identifier_tokens(emitted_source.clone());
let emitted_source_tokens = rust_identifier_tokens(rust_qualified_segments_marked(
rust_code_outside_string_literals(emitted_source.clone()),
));
let emitted_source_token_set = emitted_source_tokens.iter().cloned().fold(
v1_rt::rc_empty_map::<String, bool>(),
|acc: Rc<HashMap<String, bool>>, t: String| v1_rt::rc_map_insert(acc, t.clone(), true),
Expand Down
9 changes: 0 additions & 9 deletions src/v1/stage0/src/v1_compiler_infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ pub use crate::extdeps_container_oci_digest::{
};
pub use crate::gunbc_structural_realization_bindings::literal_homomorphism_rows;
pub use crate::std_algebra::carrier_container_equality_rows;
pub use crate::std_algebra::AlgebraFieldTemplate;
use crate::std_algebra::CollectionSizeEffect::ShrinkEffect;
pub use crate::std_algebra::{CollectionSizeEffect, FreeMonoid};
pub use crate::std_coercion::{dag_can_cast, is_dag_cast_domain_type};
Expand Down Expand Up @@ -62,7 +61,6 @@ pub use crate::std_literal_elaboration::{
pub use crate::std_node::{compiler_inductive_fields, compiler_recursive_types};
pub use crate::std_occurrence_identity::NodeOccurrenceIdentity;
use crate::std_occurrence_identity::NodeOccurrenceIdentity::OccurrenceSynthetic;
pub use crate::std_occurrence_identity::OccurrenceId;
pub use crate::std_operator_realization::OperandDeclaration;
use crate::std_syntax::BinOp::{
Add, And, Div, Eq, Ge, Gt, Le, Lt, Mod, Mul, Ne, NullCoalesce, Or, Sub,
Expand Down Expand Up @@ -191,9 +189,6 @@ use crate::v1_compiler_infer_sigs::NoDerivableSigReason::{
use crate::v1_compiler_infer_sigs::ResolvedFormals::{
DeclarationBoundFormals, KernelGroundedFormals, LocalFormalsAwaitingModuleContext,
};
pub use crate::v1_compiler_infer_sigs::{
call_target_declared_sig, call_target_is_locally_bound, call_target_local_binding,
};
pub use crate::v1_compiler_infer_sigs::{
callable_candidate_labels, callable_identity_label, flatten_parent_envs,
func_sig_for_derivation, resolve_func_sigs,
Expand All @@ -215,7 +210,6 @@ pub use crate::v1_compiler_infer_types::{
structural_carrier_template_name, template_return_has_variables,
template_return_is_receiver_self,
};
pub use crate::v1_compiler_ownership::fold_terminal_expr;
pub use crate::v1_compiler_resolve::{ModuleGraph, ResolvedImport, ResolvedModule};
use crate::v1_compiler_type_head_exposure::TypeHeadExposure::{
ExposedTypeHead, MalformedApplicationHead, OpaqueTypeHead, StuckTypeHead,
Expand Down Expand Up @@ -309,9 +303,6 @@ pub use crate::v1_std_core::{
string_type, type_name_compatible, type_reference_provenance, unaryop_operand, unit_type,
with_optional_cardinality, with_required_cardinality,
};
pub use crate::v1_std_core::{
divergent_type, expr_is_any_literal, expr_literal_symbol_optional, module_path_segments,
};
pub use crate::v1_std_core::{
AdmitCallersEntry, CallSemantics, CallTargetIdentity, Cardinality, CompilerDiagnostic,
Connective, DeclRefCoords, DeclarationMarker, DeclaredCallableIdentity, DeclaredFuncEnv,
Expand Down
1 change: 0 additions & 1 deletion src/v1/stage0/src/v1_compiler_infer_resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ pub use crate::v1_compiler_infer_types::{
};
use crate::v1_rt;
use crate::v1_rt::{VecCompat, VecJoin};
pub use crate::v1_std_core::divergent_type;
use crate::v1_std_core::Cardinality::{CardOptional, Required};
use crate::v1_std_core::CompilerDiagnostic::{
ArityMismatch, InternalError, TypeArgumentKindMismatch, UnlistedImportUse, UnresolvedType,
Expand Down
1 change: 0 additions & 1 deletion src/v1/stage0/src/v1_compiler_parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ pub use crate::std_syntax::{
pub use crate::std_types::{NonEmptyStr, SourceSpan};
use crate::v1_rt;
use crate::v1_rt::{VecCompat, VecJoin};
pub use crate::v1_std_core::make_file_span;
use crate::v1_std_core::Cardinality::{CardOptional, Required};
use crate::v1_std_core::CompilerDiagnostic::{InternalError, ParseError};
use crate::v1_std_core::Connective::{Arrow, Conj, Disj, NoConnective};
Expand Down
3 changes: 0 additions & 3 deletions src/v1/stage0/src/v1_compiler_trait_derive_emit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ pub use crate::extdeps_languages_rust_emit::{
rust_supplemental_impls_bool_coproduct, rust_supplemental_impls_group_completion,
rust_trait_derive_attr_from_traits, rust_trait_derive_spelling,
};
pub use crate::std_content_hash::Fnv1a64Structural;
pub use crate::std_decl_ref::DeclarationRef;
pub use crate::std_dissolution::unbound_dissolution;
pub use crate::std_dissolution::DissolutionCondition;
use crate::std_dissolution::DissolutionCondition::*;
Expand All @@ -43,7 +41,6 @@ use crate::v1_compiler_artifact::RenderTarget::Rust;
pub use crate::v1_compiler_coercion::{declaration_realization, realized_checkpoint};
pub use crate::v1_compiler_emit::{emit_ident, to_pascal};
pub use crate::v1_compiler_emit_core_support::{is_type_alias_item, unique_strings};
pub use crate::v1_compiler_emit_rust::item_generic_param_names;
pub use crate::v1_compiler_infer_types::{child_type_node, is_coproduct_type, resolved_type};
use crate::v1_rt;
use crate::v1_rt::{VecCompat, VecJoin};
Expand Down
2 changes: 0 additions & 2 deletions src/v1/stage0/src/v1_gunbc_occurrence_binding_parser_walk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ pub use crate::std_occurrence_binding_candidates::{
AuthoredOrderRow, DeclarationExposureGrounding, DeclarationExposureRow,
OccurrenceBindingCandidateInputs, OccurrenceModulePathRow,
};
pub use crate::std_occurrence_identity::OccurrenceCategory;
use crate::std_occurrence_identity::OccurrenceCategory::*;
pub use crate::std_occurrence_identity::{
AuthoredTokenOrdinal, DeclarationOccurrence, OccurrenceId, OccurrenceIndexEntry,
OccurrenceTransport, ReferenceOccurrence,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::v1_rt::{VecCompat, VecJoin};
pub use crate::v1_std_core::ErrorNode;
use crate::v1_std_core::LeafOwner::*;
pub use crate::v1_std_core::{diagnostic_to_message, is_error_diagnostic, no_span};
pub use crate::v1_std_core::{FieldSummary, LeafOwner, NewlineIndex, Node};
pub use crate::v1_std_core::{FieldSummary, LeafOwner, NewlineIndex};
use crate::NonEmptyBTreeSet;
use crate::NonEmptyVec;
use im::{vector as vec, HashMap, OrdSet as BTreeSet, Vector as Vec};
Expand Down