refactor(iteration): Phase B language-advantage pass — dichotomy wave
CI Pipeline / best-practices (push) Successful in 7s
CI Pipeline / documentation (push) Successful in 5s
CI Pipeline / rust-surface (push) Failing after 18s
CI Pipeline / go-surface (push) Failing after 23s
CI Pipeline / required-checks (push) Canceled after 0s
CI Pipeline / CI Pipeline / notify-event-bridge (push) Canceled after 0s
CI Pipeline / canary (push) Canceled after 36s
Auto-version and Release / release (push) Canceled after 50s
CI Pipeline / type-check (push) Canceled after 20s
CI Pipeline / gitea-offline (push) Canceled after 21s
deploy / deploy (push) Canceled after 51s
CI Pipeline / lint (push) Canceled after 40s
CI Pipeline / unit-tests (push) Canceled after 40s
CI Pipeline / best-practices (push) Successful in 7s
CI Pipeline / documentation (push) Successful in 5s
CI Pipeline / rust-surface (push) Failing after 18s
CI Pipeline / go-surface (push) Failing after 23s
CI Pipeline / required-checks (push) Canceled after 0s
CI Pipeline / CI Pipeline / notify-event-bridge (push) Canceled after 0s
CI Pipeline / canary (push) Canceled after 36s
Auto-version and Release / release (push) Canceled after 50s
CI Pipeline / type-check (push) Canceled after 20s
CI Pipeline / gitea-offline (push) Canceled after 21s
deploy / deploy (push) Canceled after 51s
CI Pipeline / lint (push) Canceled after 40s
CI Pipeline / unit-tests (push) Canceled after 40s
This commit is contained in:
1 parent
8baf8b9845
commit
a5656587c4
1 file changed
+80
-49
@@ -82,9 +82,42 @@ fn entities(doc: &Json) -> Vec<&Json> {
|
||||
}
|
||||
}
|
||||
|
||||
fn relationships(doc: &Json) -> Vec<Json> {
|
||||
/// Language advantage: the relationship vocabulary iteration queries is a
|
||||
/// closed lattice — `RelType::of` returns None for the open-world tail
|
||||
/// (calls/reads/writes/...) that the oracle simply ignores, and every
|
||||
/// query matches EXHAUSTIVELY over the lattice (a new queryable edge kind
|
||||
/// is a compiler-checked variant, not another wire string). The wire
|
||||
/// spelling lives in exactly one place per variant.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
enum RelType {
|
||||
BelongsTo,
|
||||
Owns,
|
||||
DependsOn,
|
||||
Provides,
|
||||
Consumes,
|
||||
VerifiedBy,
|
||||
DeployedBy,
|
||||
}
|
||||
|
||||
impl RelType {
|
||||
fn of(r: &Json) -> Option<RelType> {
|
||||
match s(r, "type").as_str() {
|
||||
"belongs_to" => Some(RelType::BelongsTo),
|
||||
"owns" => Some(RelType::Owns),
|
||||
"depends_on" => Some(RelType::DependsOn),
|
||||
"provides" => Some(RelType::Provides),
|
||||
"consumes" => Some(RelType::Consumes),
|
||||
"verified_by" => Some(RelType::VerifiedBy),
|
||||
"deployed_by" => Some(RelType::DeployedBy),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Zero-copy: relationships are BORROWED from the input doc, never cloned.
|
||||
fn relationships(doc: &Json) -> Vec<&Json> {
|
||||
match doc.get("relationships") {
|
||||
Some(Json::Arr(items)) => items.clone(),
|
||||
Some(Json::Arr(items)) => items.iter().collect(),
|
||||
_ => Vec::new(),
|
||||
}
|
||||
}
|
||||
@@ -93,12 +126,30 @@ fn get_entity<'a>(doc: &'a Json, eid: &str) -> Option<&'a Json> {
|
||||
entities(doc).into_iter().find(|e| s(e, "id") == eid)
|
||||
}
|
||||
|
||||
/// model.children: belongs_to edges reversed, relationship order kept.
|
||||
/// Outgoing edges of `eid` with the given type, sorted+deduped (the
|
||||
/// oracle's `sorted(r["to"] ...)` law).
|
||||
fn edges_from(doc: &Json, eid: &str, ty: RelType) -> Vec<String> {
|
||||
let mut v: Vec<String> = relationships(doc)
|
||||
.into_iter()
|
||||
.filter(|r| RelType::of(r) == Some(ty) && s(r, "from") == eid)
|
||||
.map(|r| s(r, "to"))
|
||||
.collect();
|
||||
v.sort();
|
||||
v.dedup();
|
||||
v
|
||||
}
|
||||
|
||||
fn stale(r: &Json) -> bool {
|
||||
s(r, "status") == "stale"
|
||||
}
|
||||
|
||||
/// model.children: belongs_to edges reversed, relationship order kept
|
||||
/// (NOT sorted — the oracle preserves document order here).
|
||||
fn children(doc: &Json, eid: &str) -> Vec<String> {
|
||||
relationships(doc)
|
||||
.iter()
|
||||
.into_iter()
|
||||
.filter(|r| {
|
||||
s(r, "type") == "belongs_to"
|
||||
RelType::of(r) == Some(RelType::BelongsTo)
|
||||
&& s(r, "to") == eid
|
||||
&& s(r, "from") != eid
|
||||
})
|
||||
@@ -132,8 +183,11 @@ fn owning_domain(doc: &Json, eid: &str) -> Json {
|
||||
return Json::Str(cur);
|
||||
}
|
||||
let parents: Vec<String> = relationships(doc)
|
||||
.iter()
|
||||
.filter(|r| s(r, "type") == "belongs_to" && s(r, "from") == cur)
|
||||
.into_iter()
|
||||
.filter(|r| {
|
||||
RelType::of(r) == Some(RelType::BelongsTo)
|
||||
&& s(r, "from") == cur
|
||||
})
|
||||
.map(|r| s(r, "to"))
|
||||
.collect();
|
||||
match parents.into_iter().next() {
|
||||
@@ -147,11 +201,11 @@ fn owning_domain(doc: &Json, eid: &str) -> Json {
|
||||
|
||||
fn dependencies(doc: &Json, eid: &str) -> Vec<String> {
|
||||
let mut v: Vec<String> = relationships(doc)
|
||||
.iter()
|
||||
.into_iter()
|
||||
.filter(|r| {
|
||||
s(r, "type") == "depends_on"
|
||||
RelType::of(r) == Some(RelType::DependsOn)
|
||||
&& s(r, "from") == eid
|
||||
&& s(r, "status") != "stale"
|
||||
&& !stale(r)
|
||||
})
|
||||
.map(|r| s(r, "to"))
|
||||
.collect();
|
||||
@@ -160,14 +214,16 @@ fn dependencies(doc: &Json, eid: &str) -> Vec<String> {
|
||||
v
|
||||
}
|
||||
|
||||
/// Who depends on OR consumes this entity (interfaces are consumed;
|
||||
/// components are depended on — Backstage relation pairs).
|
||||
fn consumers(doc: &Json, eid: &str) -> Vec<String> {
|
||||
let mut v: Vec<String> = relationships(doc)
|
||||
.iter()
|
||||
.into_iter()
|
||||
.filter(|r| {
|
||||
let t = s(r, "type");
|
||||
(t == "depends_on" || t == "consumes")
|
||||
let ty = RelType::of(r);
|
||||
(ty == Some(RelType::DependsOn) || ty == Some(RelType::Consumes))
|
||||
&& s(r, "to") == eid
|
||||
&& s(r, "status") != "stale"
|
||||
&& !stale(r)
|
||||
})
|
||||
.map(|r| s(r, "from"))
|
||||
.collect();
|
||||
@@ -177,36 +233,11 @@ fn consumers(doc: &Json, eid: &str) -> Vec<String> {
|
||||
}
|
||||
|
||||
fn interfaces_for(doc: &Json, eid: &str) -> Vec<String> {
|
||||
let mut v: Vec<String> = relationships(doc)
|
||||
.iter()
|
||||
.filter(|r| s(r, "type") == "provides" && s(r, "from") == eid)
|
||||
.map(|r| s(r, "to"))
|
||||
.collect();
|
||||
v.sort();
|
||||
v.dedup();
|
||||
v
|
||||
edges_from(doc, eid, RelType::Provides)
|
||||
}
|
||||
|
||||
fn consumes_of(doc: &Json, eid: &str) -> Vec<String> {
|
||||
let mut v: Vec<String> = relationships(doc)
|
||||
.iter()
|
||||
.filter(|r| s(r, "type") == "consumes" && s(r, "from") == eid)
|
||||
.map(|r| s(r, "to"))
|
||||
.collect();
|
||||
v.sort();
|
||||
v.dedup();
|
||||
v
|
||||
}
|
||||
|
||||
fn edges_from(doc: &Json, eid: &str, ty: &str) -> Vec<String> {
|
||||
let mut v: Vec<String> = relationships(doc)
|
||||
.iter()
|
||||
.filter(|r| s(r, "type") == ty && s(r, "from") == eid)
|
||||
.map(|r| s(r, "to"))
|
||||
.collect();
|
||||
v.sort();
|
||||
v.dedup();
|
||||
v
|
||||
edges_from(doc, eid, RelType::Consumes)
|
||||
}
|
||||
|
||||
/// impact_closure — the structurally bounded scope (rule J), oracle-identical
|
||||
@@ -251,13 +282,13 @@ fn impact_closure(doc: &Json, eid: &str) -> Json {
|
||||
let mut verification_scope: BTreeSet<String> = BTreeSet::new();
|
||||
let mut deployment_scope: BTreeSet<String> = BTreeSet::new();
|
||||
for e in std::iter::once(eid.to_string()).chain(consumers_set.iter().cloned()) {
|
||||
for x in edges_from(doc, &e, "owns") {
|
||||
for x in edges_from(doc, &e, RelType::Owns) {
|
||||
state_surfaces.insert(x);
|
||||
}
|
||||
for x in edges_from(doc, &e, "verified_by") {
|
||||
for x in edges_from(doc, &e, RelType::VerifiedBy) {
|
||||
verification_scope.insert(x);
|
||||
}
|
||||
for x in edges_from(doc, &e, "deployed_by") {
|
||||
for x in edges_from(doc, &e, RelType::DeployedBy) {
|
||||
deployment_scope.insert(x);
|
||||
}
|
||||
}
|
||||
@@ -474,12 +505,12 @@ pub fn context_packet(
|
||||
arr(iface_consumers.into_iter().collect::<Vec<_>>()),
|
||||
),
|
||||
("interfaces_provided", arr(interfaces_for(model, target))),
|
||||
("state_owned", arr(edges_from(model, target, "owns"))),
|
||||
("state_owned", arr(edges_from(model, target, RelType::Owns))),
|
||||
(
|
||||
"verification",
|
||||
arr(edges_from(model, target, "verified_by")),
|
||||
arr(edges_from(model, target, RelType::VerifiedBy)),
|
||||
),
|
||||
("deployment", arr(edges_from(model, target, "deployed_by"))),
|
||||
("deployment", arr(edges_from(model, target, RelType::DeployedBy))),
|
||||
("uncertainty", uncertainty),
|
||||
]);
|
||||
let target_kind = match entity.get("kind") {
|
||||
@@ -642,7 +673,7 @@ pub fn post_change_obligations(
|
||||
);
|
||||
}
|
||||
}
|
||||
for store in edges_from(model, eid, "owns") {
|
||||
for store in edges_from(model, eid, RelType::Owns) {
|
||||
add(
|
||||
"check_state_compatibility",
|
||||
&store,
|
||||
@@ -660,7 +691,7 @@ pub fn post_change_obligations(
|
||||
&mut seen,
|
||||
);
|
||||
}
|
||||
for dep in edges_from(model, eid, "deployed_by") {
|
||||
for dep in edges_from(model, eid, RelType::DeployedBy) {
|
||||
add(
|
||||
"verify_deployment",
|
||||
&dep,
|
||||
|
||||
Reference in new issue
Block a user