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
3 changes: 2 additions & 1 deletion README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ inka review --path my-argument --as alice premise --approve
inka review --path my-argument --as alice goal --decline --comment "state a real objective"
```

`--list` も対象も指定しなければ,`review` は待ち行列を対話的に順に巡ります。判断はすべて
`--list` も対象も指定しなければ,`review` は待ち行列を対話的に順に巡ります。待ち行列は部分木ごとに
葉から根へ向かって並ぶので,あるブロックはその下にあるすべてのブロックの後に出てきます。判断はすべて
`approvals/<approver>.jsonl` に追記され,書き換えられることはありません。承認はそのとき示された内容に
対するものなので,ブロックを編集するとその承認は古くなり,そのブロックの契約に依拠する親の承認も
古くなります。承認が古くなったブロックは待ち行列に戻ります。
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ inka review --path my-argument --as alice premise --approve
inka review --path my-argument --as alice goal --decline --comment "state a real objective"
```

Without `--list` or a target, `review` walks the queue interactively. Every decision is appended to
Without `--list` or a target, `review` walks the queue interactively. The queue runs from the leaves
up, one subtree at a time, so a block comes after everything below it. Every decision is appended to
`approvals/<approver>.jsonl` and nothing is ever rewritten. An approval covers the content it was
given for, so editing a block makes its approval stale, and its parents' too, since they rest on its
contract. Each block with a stale approval goes back in the queue.
Expand Down
23 changes: 16 additions & 7 deletions crate/inka-cli/src/review.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,13 @@ fn current_hash(
}

/// The `--list` rendering: a summary line, then one section per state.
///
/// The state comes first: a reader of the list wants to know what is
/// unapproved, what went stale and what is vetoed. The queue's leaves-first
/// order therefore holds within each section, not across them — a stale leaf
/// is listed under `Stale` even when its unapproved parent is listed above it
/// under `Unapproved`. The interactive walk, which does not group, follows the
/// queue's order throughout.
fn write_queue(queue: &ReviewQueue, screen: Screen, out: &mut impl Write) -> io::Result<()> {
let summary = match queue.items.len() {
0 => "nothing needs review".to_owned(),
Expand Down Expand Up @@ -1067,8 +1074,10 @@ mod tests {
// Act
let transcript = run_interactive(dir.path(), "a\na\na\n");

// Assert: queue order is sorted block IDs — branch, leaf, root.
assert!(transcript.contains("[1/3] structure:branch"));
// Assert: the queue runs leaves first — leaf, branch, root.
assert!(transcript.contains("[1/3] fiat:leaf"));
assert!(transcript.contains("[2/3] structure:branch"));
assert!(transcript.contains("[3/3] objective:root"));
assert!(transcript.contains("the branch claim"));
assert!(transcript.contains("children:"));
assert!(transcript.contains("decisions recorded: 3; targets remaining: 0"));
Expand All @@ -1079,17 +1088,17 @@ mod tests {
fn a_decline_demands_a_comment_until_one_is_given() {
// Arrange & Act: decline the first target, first with a blank comment.
let dir = scenario_project();
let transcript = run_interactive(dir.path(), "d\n\nthe branch claim is wrong\nq\n");
let transcript = run_interactive(dir.path(), "d\n\nthe leaf claim is wrong\nq\n");

// Assert: the blank was refused, the decline recorded, and quit left
// the remaining targets untouched.
assert!(transcript.contains("a decline must say why"));
assert!(transcript.contains("recorded decline of structure:branch"));
assert!(transcript.contains("recorded decline of fiat:leaf"));
assert!(transcript.contains("decisions recorded: 1; targets remaining: 2"));
let lines = record_lines(dir.path());
assert_eq!(lines.len(), 1);
assert!(lines[0].contains("\"label\":\"decline\""));
assert!(lines[0].contains("the branch claim is wrong"));
assert!(lines[0].contains("the leaf claim is wrong"));
}

#[test]
Expand Down Expand Up @@ -1237,7 +1246,7 @@ fiat leaf {
}
assert!(
transcript.contains(
"── [2/2] fiat:leaf ── stale ────────────────────────────────\n \
"── [1/2] fiat:leaf ── stale ────────────────────────────────\n \
alice approved an earlier version\n\n \
╔═══════════════╗\n ║ taken, edited ║\n ╚═══════════════╝\n\n\
[a]pprove [d]ecline [s]kip [q]uit > "
Expand Down Expand Up @@ -1293,7 +1302,7 @@ fiat leaf {
fn colour_marks_the_state_and_leaves_the_text_unchanged() {
// Arrange: a declined leaf, so the prelude and a target both render.
let dir = scenario_project();
run_interactive(dir.path(), "s\nd\nnot so\nq\n");
run_interactive(dir.path(), "d\nnot so\nq\n");
let render = |color: bool| {
let request = Request {
approver: "alice".to_owned(),
Expand Down
8 changes: 4 additions & 4 deletions crate/inka-cli/tests/review.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ fn editing_a_description_returns_the_target_and_its_direct_parent_as_stale() {
}
write_argument(dir.path(), "taken as given, but edited");

// Act & Assert: exactly the leaf and its direct parent come back, stale;
// the root's local view is untouched, so it stays out.
// Act & Assert: exactly the leaf and its direct parent come back, stale
// and leaf first; the root's local view is untouched, so it stays out.
inka()
.arg("review")
.arg("--path")
Expand All @@ -136,8 +136,8 @@ fn editing_a_description_returns_the_target_and_its_direct_parent_as_stale() {
.stdout(predicate::str::starts_with("2 targets need review\n"))
.stdout(predicate::str::contains(
"Stale (2)\n \
structure:branch alice approved an earlier version\n \
fiat:leaf alice approved an earlier version\n",
fiat:leaf alice approved an earlier version\n \
structure:branch alice approved an earlier version\n",
))
.stdout(predicate::str::contains("root").not());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@ expression: "String::from_utf8(output.stdout).expect(\"the queue is UTF-8\")"
24 targets need review

Unapproved (24)
structure:approvals_meaningful
fiat:approver_unforgeable
fiat:local_view_binding
fiat:local_view_hash_sound
structure:invalidation_exact
fiat:id_not_in_contract
structure:surface_edits_free
structure:edit_cost_proportional
fiat:lint_flags_leaky_contracts
fiat:approvers_follow_norm
fiat:assumptions_surfaced
fiat:bind_validity_by_human
structure:description_is_contract
structure:edit_cost_proportional
fiat:eval_reproducible
fiat:git_hosting_intact
fiat:id_not_in_contract
objective:inka_ok
structure:invalidation_exact
fiat:labels_cover_reality
fiat:lint_flags_leaky_contracts
fiat:local_view_binding
fiat:local_view_hash_sound
fiat:log_tamper_evident
fiat:policy_is_reviewable
fiat:queue_minimizes_friction
structure:records_auditable
structure:surface_edits_free
structure:approvals_meaningful
structure:target_unswappable
structure:truth_validity_separated
fiat:approver_unforgeable
fiat:log_tamper_evident
fiat:eval_reproducible
fiat:git_hosting_intact
structure:records_auditable
fiat:verification_truth_by_machine
fiat:bind_validity_by_human
fiat:assumptions_surfaced
structure:truth_validity_separated
objective:inka_ok
Loading
Loading