Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3ec8358
feat(8-1): add the plan judge's spine and member walk
crenshawdev Oct 23, 2026
bf1bb37
feat(8-1): refuse unknown members and out-of-range plan counters
crenshawdev Oct 23, 2026
b3c6ab7
feat(8-1): judge the plan's lease and its path rule
crenshawdev Oct 23, 2026
f57a9c2
feat(8-1): judge a plan's tasks and refuse files outside the lease
crenshawdev Oct 23, 2026
a2d9d47
feat(8-1): judge a plan's questions through the question set judge
crenshawdev Oct 23, 2026
742c18a
feat(8-1): judge each evidence item and its spec in the plan grammar
crenshawdev Oct 23, 2026
e9668e6
feat(8-1): refuse a check with a blank command, expected value, file …
crenshawdev Oct 23, 2026
a339dc6
feat(8-1): refuse a plan for a phase with no truths or an uncommitted…
crenshawdev Oct 23, 2026
56123fa
feat(8-2): bind each evidence item to its own story's current truth
crenshawdev Oct 23, 2026
ff0c0a1
feat(8-2): refuse a link whose value its truth does not name
crenshawdev Oct 23, 2026
f2449ee
feat(8-2): refuse an item id an approved plan holds with another defi…
crenshawdev Oct 23, 2026
898590b
feat(8-2): refuse a served truth uncovered or without a check across …
crenshawdev Oct 23, 2026
0043184
feat(8-2): refuse a truth a person must prove with no observation
crenshawdev Oct 23, 2026
3a1735f
feat(8-2): refuse a second check for one story, truth and version
crenshawdev Oct 23, 2026
939604f
feat(8-2): refuse a plan that takes the phase over its capacity
crenshawdev Oct 23, 2026
34e7d39
feat(8-3): add the default test style as its own constant
crenshawdev Oct 23, 2026
faec2a1
feat(8-3): serve the planner text as bal-phase-planner
crenshawdev Oct 23, 2026
dfc6934
feat(8-3): port the bal-plan front door text, still unavailable
crenshawdev Oct 23, 2026
273c70e
fix(8-3): make the planner's verify entries bare commands
crenshawdev Oct 24, 2026
f044fc5
docs(8-4): count a phase's size per plan and name the new refusals
crenshawdev Oct 30, 2026
003e471
docs(8-4): describe the plan and evidence item records as judged
crenshawdev Oct 30, 2026
ae2c659
docs(8-4): cite the core plan judge and the served planner text
crenshawdev Oct 30, 2026
fa08c21
docs(8-4): list bal-phase-planner among the served instructions
crenshawdev Oct 30, 2026
53f01eb
docs(8-4): show build 4 t7 merged and t8 in progress
crenshawdev Oct 30, 2026
0850fcd
docs(8-4): let a unit of work carry one or more verify commands
crenshawdev Oct 30, 2026
3f5efba
docs(glossary): count a phase's size per plan, as design 0005 does
crenshawdev Oct 30, 2026
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
2 changes: 1 addition & 1 deletion CONTEXT.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Two notes on history:
| Deferral | The owner's recorded choice to leave a question undecided for now, with a reason ([0005](docs/design/0005-context-plans-and-acceptance.md#2-terms)). | skip, postponement |
| Phase planning | Committing stories to a phase and writing its plans ([0005](docs/design/0005-context-plans-and-acceptance.md#2-terms)). | sprint planning |
| Increment | What a completed phase delivers: something the owner can use, proven by its truths and the suite ([0005](docs/design/0005-context-plans-and-acceptance.md#2-terms)). | deliverable, release (a release is a tagged version) |
| Size | The number of tasks a story's approved plans need; a phase's size is the sum ([0005](docs/design/0005-context-plans-and-acceptance.md#2-terms)). | estimate, story points |
| Size | A story's size counts the tasks of the approved plans that serve it; a phase's size counts each of its approved plans' tasks once, so a plan serving two stories is counted once ([0005](docs/design/0005-context-plans-and-acceptance.md#2-terms)). | estimate, story points |
| Capacity | The owner's ceiling on a phase's size in tasks, `planning.phase_capacity` ([0005](docs/design/0005-context-plans-and-acceptance.md#2-terms)). | budget, sprint capacity |
| Velocity | Tasks completed per closed phase, shown as a fact and never used to decide ([0005](docs/design/0005-context-plans-and-acceptance.md#2-terms)). | throughput, speed |
| Plan | One typed document for a phase: the stories it serves, its file lease, its tasks, its suite, its evidence map and its questions. A phase may have several ([0005](docs/design/0005-context-plans-and-acceptance.md#2-terms)). | roadmap, spec, PLAN file |
Expand Down
1 change: 1 addition & 0 deletions crates/baley-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub mod catalog;
pub mod checkout;
pub mod forge;
pub mod guard;
pub mod plan;
pub mod policy;
pub mod questions;
pub mod reconcile;
Expand Down
130 changes: 130 additions & 0 deletions crates/baley-core/src/plan/binding.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
//! Step (7) of the plan judge: each evidence item bound to its own story's
//! current truth (PLN-R13, D-01). A truth id is unique only within its
//! story, so the truth is looked up inside the item's story alone.

use super::evidence::EvidenceItem;
use super::judge::{CurrentTruth, PlanFacts, PlanRefusal};

/// Step (7), item by item in submitted order: an item whose story is not
/// one the plan serves, or whose truth id is not a current truth of that
/// story, is refused `evidence-item-truth`; one naming its truth at another
/// version, older or newer, is refused `truth-version-mismatch` with the
/// current version. Answers each item's truth, in the plan's item order.
pub(super) fn bind<'a>(
stories: &[u32],
items: &[EvidenceItem],
facts: &'a PlanFacts,
) -> Result<Vec<&'a CurrentTruth>, PlanRefusal> {
items
.iter()
.enumerate()
.map(|(position, item)| {
let truth = stories
.contains(&item.story)
.then(|| facts.stories.iter().find(|story| story.id == item.story))
.flatten()
.and_then(|story| story.truths.iter().find(|truth| truth.id == item.truth));
match truth {
None => Err(PlanRefusal::EvidenceItemTruth {
position,
id: item.id.clone(),
}),
Some(truth) if truth.version != item.truth_version => {
Err(PlanRefusal::TruthVersionMismatch {
position,
id: item.id.clone(),
current: truth.version,
})
}
Some(truth) => Ok(truth),
}
})
.collect()
}

#[cfg(test)]
mod tests {
//! Expected answers are written out from design 0005, the phase's
//! decisions and the plan's test data, never from running this code.

use serde_json::json;

use crate::plan::PlanRefusal;
use crate::plan::fixtures::{ar, f1, p1, p2, plus, refusal, with};

fn untrue(position: usize, id: &str) -> PlanRefusal {
PlanRefusal::EvidenceItemTruth {
position,
id: id.into(),
}
}

fn mismatch(position: usize, id: &str, current: u32) -> PlanRefusal {
PlanRefusal::TruthVersionMismatch {
position,
id: id.into(),
current,
}
}

#[test]
fn an_item_naming_no_served_truth_or_an_old_version_accepted_is_caught() {
let facts = f1();
let cases = [
(
with(p1(), "/evidence_map/0", "story", json!(3)),
untrue(0, "c1"),
),
(
with(p1(), "/evidence_map/0", "truth", json!("t3")),
untrue(0, "c1"),
),
(
plus(
p1(),
with(
with(ar(), "", "truth", json!("t2")),
"",
"truth_version",
json!(1),
),
),
mismatch(3, "a1", 2),
),
];
for (plan, refused) in cases {
assert_eq!(refusal(&plan, &facts), refused, "{plan}");
}
assert_eq!(untrue(0, "c1").code(), "evidence-item-truth");
assert_eq!(mismatch(3, "a1", 2).code(), "truth-version-mismatch");
}

#[test]
fn an_item_bound_by_truth_id_alone_is_caught() {
let facts = f1();
let cases = [
(
with(p2(), "/evidence_map/3", "truth_version", json!(1)),
mismatch(3, "c4", 3),
),
(
with(p2(), "/evidence_map/3", "story", json!(1)),
mismatch(3, "c4", 1),
),
];
for (plan, refused) in cases {
assert_eq!(refusal(&plan, &facts), refused, "{plan}");
}
}

#[test]
fn a_newer_version_than_the_current_accepted_is_caught() {
assert_eq!(
refusal(
&with(p1(), "/evidence_map/1", "truth_version", json!(3)),
&f1()
),
mismatch(1, "c2", 2)
);
}
}
66 changes: 66 additions & 0 deletions crates/baley-core/src/plan/capacity.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//! Step (14) of the plan judge, last: the phase's capacity (PLN-R9, D-02).

use super::judge::{PlanFacts, PlanRefusal};

/// Step (14): with a capacity set, a plan whose `tasks` would take the
/// phase's current size above it is refused `over-capacity`, naming every
/// story it serves and the size the phase would reach. Each task counts
/// once whatever number of stories the plan serves; landing exactly on the
/// capacity is accepted, and with no capacity there is no ceiling.
pub(super) fn within(stories: &[u32], tasks: usize, facts: &PlanFacts) -> Result<(), PlanRefusal> {
let Some(capacity) = facts.capacity else {
return Ok(());
};
// Summed wider than the counter, so a size past u32::MAX is over any
// capacity instead of wrapping under it.
let size = u64::from(facts.size) + tasks as u64;
if size > u64::from(capacity.get()) {
return Err(PlanRefusal::OverCapacity {
stories: stories.to_vec(),
size,
});
}
Ok(())
}

#[cfg(test)]
mod tests {
//! Expected answers are written out from design 0005, the phase's
//! decisions and the plan's test data, never from running this code.

use crate::plan::PlanRefusal;
use crate::plan::fixtures::{accepted, at, f1, p1, p2, p4, refusal};

fn over(stories: &[u32], size: u64) -> PlanRefusal {
PlanRefusal::OverCapacity {
stories: stories.to_vec(),
size,
}
}

#[test]
fn a_plan_over_capacity_accepted_or_counted_per_story_is_caught() {
accepted(&p1(), &at(3, 2));
assert_eq!(refusal(&p1(), &at(3, 3)), over(&[1], 4));
accepted(&p2(), &at(2, 1));
assert_eq!(refusal(&p2(), &at(2, 2)), over(&[1, 2], 3));
let mut unbounded = f1();
unbounded.size = 4_000_000_000;
accepted(&p1(), &unbounded);
accepted(&p4(), &at(4, 2));
assert_eq!(refusal(&p4(), &at(4, 3)), over(&[1], 5));
assert_eq!(over(&[1], 4).code(), "over-capacity");
}

#[test]
fn a_size_that_wraps_past_the_counter_is_caught() {
assert_eq!(
refusal(&p1(), &at(u32::MAX, u32::MAX)),
over(&[1], 4_294_967_296)
);
assert_eq!(
refusal(&p4(), &at(u32::MAX, u32::MAX - 1)),
over(&[1], 4_294_967_296)
);
}
}
Loading
Loading