Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
3095fd7
fix(gsd): no asset names a key of the Not applicable table, and one g…
leaderiop Nov 21, 2026
8b231b8
fix(xtask): absorb titles a phase by its name, and the spec's thirtee…
leaderiop Nov 21, 2026
e7b88fc
fix(gsd): a phase's new name retitles it, so its title and name never…
leaderiop Nov 21, 2026
f5e8ae0
fix(gsd): plan-phase and autonomous say where a phase's number and na…
leaderiop Nov 21, 2026
9ef4d61
build(blobs): re-vendor @gsd/core on linux/amd64 for the settings swe…
leaderiop Nov 21, 2026
8383b88
test(gsd): the phase label test leaves ported_text, which shares its …
leaderiop Nov 21, 2026
922b8d6
fix(xtask): absorb ledgers the number a phase's title drops, and its …
leaderiop Nov 21, 2026
3155536
fix(gsd): every asset that prints a phase label defines its placeholders
leaderiop Nov 21, 2026
2e07b39
fix(gsd): a phase's new name rewrites its slug as --add derives it, s…
leaderiop Nov 21, 2026
df18296
docs(gsd): the executor's hash is for its checks, and added prose wra…
leaderiop Nov 21, 2026
c305afa
test(gsd): the settings guard reads a family's bare object key and it…
leaderiop Nov 21, 2026
c2815ac
build(gsd): re-vendor @gsd/core for the phase-label definitions and t…
leaderiop Nov 22, 2026
ca84d2f
docs(adr): a code may be settled later, and a write that creates its …
leaderiop Nov 22, 2026
a82f1a2
feat(protocol): a code entry may declare settled_later, and the code …
leaderiop Nov 22, 2026
7e6e84f
feat(ops): a settled-later finding on what a write creates is no erro…
leaderiop Nov 22, 2026
c5a950a
feat(gsd): an open question, a phase's plan coverage and a plan's mus…
leaderiop Nov 22, 2026
88fe3d7
fix(gsd): the researcher records every open question open, and the us…
leaderiop Nov 22, 2026
8112e11
fix(gsd): a phase's plans may be written one at a time; the planner's…
leaderiop Nov 22, 2026
e974b19
feat(gsd): execute_phase refuses a half-planned phase (gsd/E301, gsd/…
leaderiop Nov 22, 2026
ec5aebe
docs(adr): @gsd/core's settled-later codes close ADR 0384's Limits; t…
leaderiop Nov 22, 2026
dd4d6d4
chore(blobs): re-vendor every blob for settled_later and @gsd/core's …
leaderiop Nov 22, 2026
e092f1b
fix(ops): a settled-later finding is counted when the write also alte…
leaderiop Nov 22, 2026
f93142c
fix(gsd): an open question is answered at its own id; settled-later t…
leaderiop Nov 22, 2026
fdd0702
chore(blobs): re-vendor every blob for the narrowed settled-later rul…
leaderiop Nov 22, 2026
a531e90
docs(adr): a context pack serves its core whole, and a route's budget…
leaderiop Nov 22, 2026
d8ccac1
feat(context)!: a pack serves its core whole, and E062 is a stated ca…
leaderiop Nov 22, 2026
31cb07b
feat(gsd)!: the plan check reads the decisions its plan answers to, a…
leaderiop Nov 22, 2026
8ac3809
docs(evaluation): the plan checker's budget refusal is fixed, and the…
leaderiop Nov 22, 2026
061e923
chore(blobs): re-vendor every blob for the enrich allowances and the …
leaderiop Nov 22, 2026
bbd06ca
fix(context)!: a record keeps the budget its read had, so only a stat…
leaderiop Nov 22, 2026
b294968
feat(gsd)!: the plan check reads the decisions its tasks name as sett…
leaderiop Nov 22, 2026
323892e
docs(adr): a context record keeps the budget its read had, and a core…
leaderiop Nov 22, 2026
5ebc278
build(blobs): re-vendor every blob on linux/amd64 for the record's bu…
leaderiop Nov 22, 2026
18a4d35
docs(adr): a phase is named by its title alone, and a pass reads each…
leaderiop Nov 22, 2026
dc9a975
feat(protocol): a pass entity carries the title its header writes
leaderiop Nov 22, 2026
85a7c03
feat(gsd)!: a phase and a milestone are named by their title, and a n…
leaderiop Nov 22, 2026
2a41fc2
feat(absorb): a converted milestone and phase are named by their titl…
leaderiop Nov 22, 2026
def7474
chore(blobs): re-vendor every blob for the pass entity's title and th…
leaderiop Nov 22, 2026
c79afa5
fix(gsd): every line a person reads names a phase by its title, and W…
leaderiop Nov 22, 2026
95adcd2
fix(absorb): a converted phase title drops every number gsd/W109 flags
leaderiop Nov 22, 2026
359d651
docs(adr): the title decision states its boundary, its digests and a …
leaderiop Nov 22, 2026
3d87dd5
chore(blobs): re-vendor every blob for the phase labels that read the…
leaderiop Nov 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
36 changes: 25 additions & 11 deletions CONTEXT.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,16 @@ Terms the code, the specs and the docs use with one meaning. Architecture decisi
for, or whose lines differ from that block's: what a migration lays out (`specforge_migrate`'s `layout::lay_out`,
ADR 0235). A file with none is skipped as it is.
- **Added error**: an error the edited compile reports that the checked report has no diagnostic left to pair, by code,
severity, file and message with its digits collapsed (ADR 0211), less a judged rule's finding (ADR 0297); the one rule behind E080 and a migration's refusal.
severity, file and message with its digits collapsed (ADR 0211), less a judged rule's finding (ADR 0297), a finding
the write revealed by moving its entity's owner state (ADR 0363) and a **settled-later** finding on an entity the
write creates or creates something under, altering nothing held there (ADR 0385); the one rule behind E080 and a
migration's refusal.
- **Settled later**: a code whose finding names a state a later step of the authoring settles (an open question a
later answer resolves, a phase's requirement the rest of its plans hold), declared by the extension that owns it
(`CodeDescriptor.settled_later`, SDK `CodeBuilder::settled_later()`, ADR 0385). E080 excuses its finding only on a
write whose plan creates the finding's subject or an entity under it and alters nothing the project held there (no
set, unset, link, unlink, delete or move at or under the subject); its severity, `check` and every gate are
unchanged.
- **Migration verdict**: whether a planned migration is kept, decided before anything is written: its hooks pass, and
the edited compile of its planned texts adds no **added error** and has the graph the project has, less the steps' declared changes
(`specforge_ops::authoring::migrate::{judge, Verdict}`, ADR 0186). A dry run reports it; a refused migration writes
Expand Down Expand Up @@ -732,6 +741,7 @@ Terms the code, the specs and the docs use with one meaning. Architecture decisi
- **Entity snapshot**: every entity of one built graph as every check after the build reads it, taken
once per compile and per session check (`specforge_registry::EntitySnapshot`, ADR 0019), taken of a graph build made in its Registry build, and of no other (ADR 0115, ADR 0123).
Each entity's record holds:
- the title its header writes, absent for a fact written without one; a pass is sent it as `title` (ADR 0387);
- what it writes, as field text, with each value's shape (quoted, bare, a number, a list of
strings or references, …) and span beside it for the host's own checks
(`specforge_graph::ValueShape`);
Expand Down Expand Up @@ -1903,20 +1913,24 @@ Terms the code, the specs and the docs use with one meaning. Architecture decisi
scope holds at any depth, and every entity one reference away from one of those, either way; a named route keeps
those of its start kind (ADR 0355).
- **Context route**: what an extension declares (the `contexts` category) for a role to read one entity of a subject
kind: ordered sections of named selectors, each core or enrich, the settings it carries, a default budget and an
optional agent. One the registry can't serve is E123; an agent binding that can't hold is E124 (ADR 0356).
kind: ordered sections of named selectors, each core or enrich, the settings it carries, its enrich allowance (its
`budget`: the tokens of enrich sections a pack may add beyond its core, 0 for a route of core sections only) and an
optional agent. The host does not bound its core: a read that states no cap serves it whatever it costs. One the
registry can't serve is E123; an agent binding that can't hold is E124 (ADR 0356, ADR 0386).
- **Context pack**: one context route served for one entity: its sections as served, the subject and the served
entities as an export, the budget and what was cut, and the pack digest; `specforge context`, `specforge.context`
and `specforge://context/{+entity_id}?role=` answer the same bytes (ADR 0356).
- **Core section** / **Enrich section**: a context route's section a budget never cuts (core; below them the read is
E062), or one served whole in declared order while it fits, the first that does not fit keeping its most connected
entities and every later one dropped (enrich) (ADR 0356).
entities as an export, the cap it was fitted to and what was cut, and the pack digest; `specforge context`,
`specforge.context` and `specforge://context/{+entity_id}?role=` answer the same bytes (ADR 0356).
- **Core section** / **Enrich section**: a context route's section always served whole (core; only a cap a read states
below them is E062), or one served whole in declared order within the route's allowance or the stated cap, the first
that does not fit keeping its most connected entities and every later one dropped (enrich) (ADR 0356, ADR 0386).
- **Pack digest**: the sha256 of a pack's route, subject and served sections, each section's digest the judged input
digest of its selector over the members it served; the budget is recorded beside it, not in it (ADR 0356).
- **Context record**: a `context`-written block `{route, digest, max_tokens}` the host writes when it records a
route's pack on an entity (ADR 0356).
- **Stale record**: a record whose pack, evaluated again at its budget, has another digest or no subject; reported
with the route's stale code (ADR 0356).
route's pack on an entity, `max_tokens` the cap its read stated, absent when it stated none; no pack shows one
(ADR 0356, ADR 0386).
- **Stale record**: a record whose pack, evaluated again under the budget its read had (its stated cap, else the core
whole and the route's allowance), has another digest, no subject or a core above the stated cap; reported with the
route's stale code (ADR 0356, ADR 0386).
- **Field filter**: `kind[field=value|…]` in a selector: only entities whose field holds one of the values (ADR 0356).
- **Result field**: the enum field of a collector-written kind that holds a fact's result, its values `TestStatus`
names (`KindBuilder::result`, ADR 0329 D3); what a judged `test(..)` input and a reader of a reference to the fact
Expand Down
3 changes: 1 addition & 2 deletions crates/app/ops/src/authoring/apply/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,7 @@ fn rejudge(
&before,
&after,
project.environment().registries(),
change.moved(),
&|id| change.renews(id),
change,
host_only,
)
.map_err(|refusal| refusal.error)
Expand Down
19 changes: 11 additions & 8 deletions crates/app/ops/src/authoring/apply/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
//! no origin can forge a record. In order: the route is registered (`unknown_route`); it records the entity's kind
//! (`not_recorded`); the origin is a command, collector or hook of the route's extension or of one naming it a peer,
//! or a core surface (`origin`); the record's selector derives exactly one subject (`no_subject`,
//! `several_subjects`); the pack fits its budget (`budget`). Each is `record_refused` with that `reason`. The write is
//! a set of the context field, which the ledger records as it records a harness value.
//! `several_subjects`); a stated cap holds the pack's core (`budget`). Each is `record_refused` with that `reason`. The
//! write is a set of the context field, which the ledger records as it records a harness value. Its `max_tokens` is
//! the cap the operation stated, and absent when it stated none (ADR 0386 D6): evaluating the record again reads its
//! pack under the same budget, so only a stated cap can refuse a core that grew.

use super::{Origin, flags, invalid};
use crate::authoring::edit::{Edit, Input, Step};
Expand Down Expand Up @@ -40,8 +42,8 @@ pub(crate) fn refused(number: usize, reason: &str, message: impl std::fmt::Displ
.with_data(json!({"op": number, "reason": reason}))
}

/// A pack read for a record, its error as the record reports it: a budget below the route's core sections (E062) is
/// `record_refused` for `budget`, about operation `number`; any other error is itself.
/// A pack read for a record, its error as the record reports it: a stated cap below the route's core sections (E062)
/// is `record_refused` for `budget`, about operation `number`; any other error is itself.
pub fn record_read_error(number: usize, error: OpError) -> OpError {
if error.code == codes::E062.id() {
refused(number, "budget", error.message)
Expand Down Expand Up @@ -151,22 +153,23 @@ pub(crate) fn check(
));
}
let subject = recorded.subject(view, op.number)?;
let budget = op.max_tokens.unwrap_or(route.budget);
// shortcut: the pack is computed over the project the plan is applied to, before the plan's other operations;
// a plan that also edits what the pack serves records the pack it read, and the next check reports it stale.
let request = ContextRequest {
route: &route.name,
subject: &subject,
max_tokens: Some(budget as usize),
max_tokens: op.max_tokens.map(|cap| cap as usize),
format: Format::Context,
};
let pack = context(view, &request)
.map_err(|refusal| record_read_error(op.number, refusal.into_error()))?;
let value = BTreeMap::from([
let mut value = BTreeMap::from([
("route".to_string(), Input::One(route.name.clone())),
("digest".to_string(), Input::One(pack.digest)),
("max_tokens".to_string(), Input::Number(budget.into())),
]);
if let Some(cap) = op.max_tokens {
value.insert("max_tokens".to_string(), Input::Number(cap.into()));
}
Ok(Step::Edit(Edit::Set {
entity_id: recorded.entity,
field: recorded.record.field.clone(),
Expand Down
60 changes: 58 additions & 2 deletions crates/app/ops/src/authoring/edit/declared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//! changes (ADR 0186).

use super::Edit;
use crate::authoring::planned::at_or_under;
use specforge_graph::{GraphDelta, NodeAspect};
use std::collections::{BTreeMap, BTreeSet};

Expand All @@ -15,6 +16,13 @@ pub(crate) struct Declared {
/// The files a rename of the plan rewrites: it changes the graph by a substitution only (ADR 0198), so every
/// entity of these files may read differently afterwards.
renamed: BTreeSet<String>,
/// The entities a create names, each at the id it has once the later moves are made, less those a later delete
/// removes: what the edits create (ADR 0385).
created: BTreeSet<String>,
/// The entities the project held that the edits change: a field or an aspect set, a delete, either id of a move,
/// each at the id it has once the later moves are made. An edit of an entity the edits create is not one. A
/// settled-later finding at or above one may be the write's own doing, so it is counted (ADR 0385).
altered: BTreeSet<String>,
}

#[derive(Debug, Default)]
Expand All @@ -39,16 +47,62 @@ impl Declared {
Edit::AddVerify { .. } | Edit::RemoveVerify { .. } => {
self.aspect(path, NodeAspect::Obligations);
}
Edit::Create { .. } | Edit::Delete { .. } => {
Edit::Create { .. } => {
self.whole.insert(path.to_string());
self.created.insert(path.to_string());
}
Edit::Delete { .. } => {
self.whole.insert(path.to_string());
self.alter(path);
let under = format!("{path}/");
self.created
.retain(|id| id != path && !id.starts_with(&under));
}
}
}

/// The entity at `old` is now at `new` (a move, ADR 0284): both ids are declared whole.
/// The entity at `old` is now at `new` (a move, ADR 0284): both ids are declared whole, and an entity the edits
/// created at or under `old` is created at its new id.
pub(crate) fn moved(&mut self, old: &str, new: &str) {
self.whole.insert(old.to_string());
self.whole.insert(new.to_string());
let held = !self.creates(old);
let moves = [(old.to_string(), new.to_string())];
let relocate = |ids: &mut BTreeSet<String>| {
*ids = std::mem::take(ids)
.into_iter()
.map(|id| super::steps::relocated(&id, &moves))
.collect();
};
relocate(&mut self.created);
relocate(&mut self.altered);
// A held entity moved changes what both its old scope and its new one hold.
if held {
self.altered.insert(old.to_string());
self.altered.insert(new.to_string());
}
}

/// Whether the edits create `id` or an entity it is under.
fn creates(&self, id: &str) -> bool {
self.created.iter().any(|created| at_or_under(id, created))
}

/// The edits change the entity at `id`: one the project held, unless the edits create it.
fn alter(&mut self, id: &str) {
if !self.creates(id) {
self.altered.insert(id.to_string());
}
}

/// The entities the edits create, at their ids once every move is made (ADR 0385).
pub(crate) fn created(&self) -> impl Iterator<Item = &String> {
self.created.iter()
}

/// The entities the project held that the edits change, at their ids once every move is made (ADR 0385).
pub(crate) fn altered(&self) -> impl Iterator<Item = &String> {
self.altered.iter()
}

/// The entities a create, a delete or a move names, at either id of a move.
Expand All @@ -63,6 +117,7 @@ impl Declared {

/// `field` of `id` may change (also a delete's referrer, ADR 0163).
pub(crate) fn field(&mut self, id: &str, field: &str) {
self.alter(id);
self.changes
.entry(id.to_string())
.or_default()
Expand All @@ -71,6 +126,7 @@ impl Declared {
}

pub(crate) fn aspect(&mut self, id: &str, aspect: NodeAspect) {
self.alter(id);
self.changes
.entry(id.to_string())
.or_default()
Expand Down
68 changes: 68 additions & 0 deletions crates/app/ops/src/authoring/edit/declared/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,71 @@ fn an_edge_between_two_undeclared_entities_is_beyond() {

assert_eq!(declared.beyond(changed).added_edges.len(), 1);
}

#[specforge_test(requirement = "FEATURE-131")]
fn a_created_entity_is_followed_through_a_later_move() {
let create = Edit::Create {
kind: "plan".into(),
id: "P1".into(),
title: "P1".into(),
file: "f.spec".into(),
fields: Default::default(),
verify: Vec::new(),
};
let delete = Edit::Delete {
entity_id: "Q1".into(),
unlink_references: false,
};
let mut declared = Declared::default();
declared.edit(&create, "PH/P1");
declared.edit(&create, "Q1/T1");
declared.edit(&create, "R1");
// Moved, its new id is the created one; deleted, a created entity and what is under it are created no more.
declared.moved("PH", "PX");
declared.edit(&delete, "Q1");
// A delete creates nothing, and neither does a move.
declared.edit(&delete, "S1");
declared.moved("U1", "U2");
let created: Vec<&String> = declared.created().collect();
assert_eq!(created, ["PX/P1", "R1"]);
}

#[specforge_test(requirement = "FEATURE-131")]
fn an_entity_held_before_and_changed_is_altered_and_one_created_is_not() {
let create = Edit::Create {
kind: "plan".into(),
id: "P3".into(),
title: "P3".into(),
file: "f.spec".into(),
fields: Default::default(),
verify: Vec::new(),
};
let delete = Edit::Delete {
entity_id: "PH/P2".into(),
unlink_references: false,
};
let unset = Edit::Unset {
entity_id: "PH/P1".into(),
field: "requirements".into(),
};
let mut declared = Declared::default();
declared.edit(&create, "PH/P3");
// A field of what the edits create, and a delete of it, alter nothing the project held.
declared.edit(&unset, "PH/P3");
declared.edit(&delete, "PH/P3");
declared.edit(&create, "PH/P4");
declared.moved("PH/P4", "PX/P4");
assert_eq!(declared.altered().count(), 0);
// A held entity's field, a held entity deleted, a held entity moved (both ids), a delete's referrer.
declared.edit(&unset, "PH/P1");
declared.edit(&delete, "PH/P2");
declared.moved("PH/P5", "PY/P5");
declared.field("R1", "phase");
// A later move of a scope carries what was altered under it.
declared.moved("PY", "PZ");
let altered: Vec<&String> = declared.altered().collect();
assert_eq!(
altered,
["PH/P1", "PH/P2", "PH/P5", "PY", "PZ", "PZ/P5", "R1"]
);
}
12 changes: 3 additions & 9 deletions crates/app/ops/src/authoring/edit/steps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ fn conclude(
.rewriting_sources(rewritten)
.moving(raw_moves.clone())
.renewing(declared.whole().cloned())
.creating(declared.created().cloned())
.altering(declared.altered().cloned())
.keeping_ledger(
project,
LedgerChange {
Expand All @@ -273,15 +275,7 @@ fn conclude(
let added = if change.is_empty() {
Vec::new()
} else {
validate::check(
view,
&change.after(),
&declared,
change.ledger_after(),
change.moved(),
&|id| change.renews(id),
host_only,
)?
validate::check(view, &change, &declared, host_only)?
};
let report = EditReport {
entities: change.entities(),
Expand Down
Loading
Loading