Skip to content
Draft
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
1 change: 1 addition & 0 deletions CHANGELOG.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ inka の最初のリリースです。inka は,設計の論証を構造化さ
- 計算が仮定するノードは bind の依存先になり,bind の承認対象にも含まれます。
- `inka review` は calc の bind のソース・結果・仮定を表示します。
- その bind を前回承認したときから仮定がどう変わったかも示します。
- `inka review` は blocked な対象ごとに解消手段(`until:` の編集,またはエビデンスの配送)を示します。
- Python パッケージ `inka-evidence` は,`inka-evidence-veriq` コマンドで veriq のプロジェクトからこれを出力します。

`inka-evidence-veriq` にはリリース済みのどの版よりも新しい veriq が必要なため,`veriq` extra は固定した git コミットから veriq をインストールします。
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Every package in the repository is released together under this version.
- The nodes a calculation assumes become dependencies of the bind and part of what its approval covers.
- `inka review` shows a calc bind's sources, results and assumptions.
- It also shows how the assumptions changed since the last approval of the bind.
- `inka review` says what resolves each blocked target: an edit of `until:`, or the delivery of the evidence.
- The `inka-evidence` Python package emits it from a veriq project, with the `inka-evidence-veriq` command.

`inka-evidence-veriq` needs a veriq newer than any released one, so the `veriq` extra installs veriq from a pinned git commit.
Expand Down
168 changes: 165 additions & 3 deletions crate/inka-cli/src/review.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,8 @@ fn current_hash(
.map_err(|error| error.to_string())
}

/// The `--list` rendering: one line per queued target, then blocked targets.
/// The `--list` rendering: one line per queued target, then one line per
/// blocked target.
fn write_queue(queue: &ReviewQueue, out: &mut impl Write) -> io::Result<()> {
if queue.items.is_empty() {
writeln!(out, "nothing needs review")?;
Expand Down Expand Up @@ -631,6 +632,15 @@ fn write_information(queue: &ReviewQueue, out: &mut impl Write) -> io::Result<()
write_blocked(queue, out)
}

/// The blocked targets, one line each in both forms of the command: the
/// reason, then what resolves it.
///
/// A blocked bind is not shown with its evidence, whichever kind it cites and
/// even when the evidence is loaded. Nothing can be decided on a blocked
/// target, and the presentation exists for a decision: the way out of an
/// expired `until:` is an edit, which changes the hash and brings the target
/// back into the queue, where it is presented in full against what was last
/// approved. Whether its evidence passes meanwhile is `inka eval`'s report.
fn write_blocked(queue: &ReviewQueue, out: &mut impl Write) -> io::Result<()> {
if queue.blocked.is_empty() {
return Ok(());
Expand All @@ -639,10 +649,11 @@ fn write_blocked(queue: &ReviewQueue, out: &mut impl Write) -> io::Result<()> {
for item in &queue.blocked {
writeln!(
out,
" {}:{} — {}",
" {}:{} — {} ({})",
item.mode.name(),
item.id,
blocked_line(&item.reason)
blocked_line(&item.reason),
blocked_remedy(&item.reason)
)?;
}
Ok(())
Expand Down Expand Up @@ -931,6 +942,15 @@ fn blocked_line(reason: &BlockedReason) -> String {
}
}

/// What takes a target out of `blocked:`, as the declines of the prelude say
/// `edit or retract to resolve`.
const fn blocked_remedy(reason: &BlockedReason) -> &'static str {
match reason {
BlockedReason::MissingEvidence { .. } => "deliver the evidence to resolve",
BlockedReason::UntilExpired { .. } => "edit `until:` to resolve",
}
}

/// Reports one unanchored error through the shared rendering path.
///
/// The message is sanitized here, once, for every caller: an error may quote
Expand Down Expand Up @@ -1261,6 +1281,148 @@ fiat table_complete {
dir
}

/// Runs `--list` against `dir`, returning the captured stdout.
fn run_list(dir: &Path) -> String {
let request = Request {
approver: "alice".to_owned(),
key_id: None,
action: Action::List,
};
let mut input = Cursor::new(Vec::new());
let mut now = || -> Timestamp {
"2026-11-01T00:00:00Z"
.parse()
.expect("the fixed instant parses")
};
let session = Session {
input: &mut input,
input_is_tty: false,
now: &mut now,
};
let mut out = Vec::new();
let mut err = Vec::new();
let outcome = run(dir, &request, session, &mut out, &mut err, false)
.expect("writing to vecs succeeds");
assert!(matches!(outcome, Outcome::Ok), "the listing succeeds");
String::from_utf8(out).expect("the listing is UTF-8")
}

/// Moves the project one phase on: `M0`, the phase every `until:` of
/// these scenarios names, is now behind it.
fn advance_past_m0(dir: &Path) {
let manifest = dir.join("inka.toml");
let text = fs::read_to_string(&manifest).expect("the manifest reads");
let advanced = text.replace(
"order = [\"M0\"]\ncurrent = \"M0\"",
"order = [\"M0\", \"M1\"]\ncurrent = \"M1\"",
);
assert_ne!(advanced, text, "the manifest declares the single phase");
fs::write(manifest, advanced).expect("the manifest writes");
}

/// The lines of `transcript` from `blocked:` up to the first prompt or
/// the end: everything either form says about blocked targets.
fn blocked_section(transcript: &str) -> String {
let lines: Vec<&str> = transcript
.lines()
.skip_while(|line| *line != "blocked:")
.take_while(|line| !line.is_empty() && *line != "nothing needs a decision")
.collect();
format!("{}\n", lines.join("\n"))
}

#[test]
fn an_expired_calc_bind_is_one_line_with_its_remedy_in_both_forms() {
// Arrange: the evidence is loaded and the bind was approved, so a
// snapshot exists — everything a full presentation would draw on.
let argument = CALC_ARGUMENT.replace(
" calc: \"Power::?verify_margin\"\n",
" calc: \"Power::?verify_margin\"\n until: M0\n",
);
let dir = calc_project(
&argument,
&calc_evidence(&["model_valid", "table_complete"]),
);
run_interactive(dir.path(), "a\na\na\na\n");
assert_eq!(snapshot_files(dir.path()).len(), 1);
advance_past_m0(dir.path());

// Act
let listing = run_list(dir.path());
let transcript = run_interactive(dir.path(), "q\n");

// Assert: the reason and the way out, and none of the evidence.
let expected = "\
blocked:
bind:margin_ok — approvals no longer count: the current phase is past until:M0 (edit `until:` to resolve)
";
assert_eq!(blocked_section(&listing), expected, "{listing}");
assert_eq!(blocked_section(&transcript), expected, "{transcript}");
for output in [&listing, &transcript] {
assert!(!output.contains("sources:"), "{output}");
assert!(!output.contains("leaves:"), "{output}");
assert!(!output.contains("assumes:"), "{output}");
}
}

#[test]
fn a_calc_bind_without_evidence_is_one_line_with_its_remedy_in_both_forms() {
// Arrange: a delivery that holds no target at all.
let dir = calc_project(CALC_ARGUMENT, r#"{"v": 1, "targets": []}"#);

// Act
let listing = run_list(dir.path());
let transcript = run_interactive(dir.path(), "q\n");

// Assert
let expected = "\
blocked:
bind:margin_ok — no imported calc evidence provides `Power::?verify_margin` (deliver the evidence to resolve)
";
assert_eq!(blocked_section(&listing), expected, "{listing}");
assert_eq!(blocked_section(&transcript), expected, "{transcript}");
}

#[test]
fn a_blocked_test_bind_reads_as_a_blocked_calc_bind_does() {
// Arrange: one test bind expired over loaded evidence, one that no
// delivery answers.
let dir = project_with(
"objective root {\n ```\n the root claim\n ```\n children: tested, untested\n}\n\n\
bind tested {\n ```\n the hash survives a round trip\n ```\n test: \"tests/clean.rs::holds\"\n until: M0\n}\n\n\
bind untested {\n ```\n the hash is stable\n ```\n test: \"tests/clean.rs::stable\"\n}\n",
);
fs::write(
dir.path().join("inka.toml"),
"[project]\nname = \"review-scenario\"\n\n[phases]\norder = [\"M0\"]\ncurrent = \"M0\"\n\n\
[values]\nfiles = []\n\n[evidence]\ntests = [\"evidence.json\"]\n",
)
.expect("the manifest writes");
fs::write(
dir.path().join("evidence.json"),
r##"{"v": 1, "tests": [{"id": "tests/clean.rs::holds", "body": "#[test]\nfn holds() {}\n",
"executions": [{"case": "default", "outcome": "pass"}]}]}"##,
)
.expect("the evidence writes");
advance_past_m0(dir.path());

// Act
let listing = run_list(dir.path());
let transcript = run_interactive(dir.path(), "q\n");

// Assert: the same two lines as for calc binds, and no case list.
let expected = "\
blocked:
bind:tested — approvals no longer count: the current phase is past until:M0 (edit `until:` to resolve)
bind:untested — no imported test evidence provides `tests/clean.rs::stable` (deliver the evidence to resolve)
";
assert_eq!(blocked_section(&listing), expected, "{listing}");
assert_eq!(blocked_section(&transcript), expected, "{transcript}");
for output in [&listing, &transcript] {
assert!(!output.contains("default"), "{output}");
}
}

fn snapshot_files(dir: &Path) -> Vec<PathBuf> {
let mut files: Vec<PathBuf> = fs::read_dir(dir.join("approvals/snapshots"))
.map(|entries| {
Expand Down
30 changes: 30 additions & 0 deletions docs/en/design/calc-evidence.md
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,36 @@ of another version alone.
Large assumption sets are presented naively for now; grouping and diff-only
views are an [open question](open-questions.md).

### Blocked binds

The presentation above is for a bind a decision can be recorded on. A bind
`inka review` reports under `blocked:` gets one line — the reason and what
resolves it — in `--list` and in the prelude of the interactive loop alike:

```text
blocked:
bind:margin_ok — approvals no longer count: the current phase is past until:M2 (edit `until:` to resolve)
bind:detumble_ok — no imported calc evidence provides `AOCS::?verify_detumble` (deliver the evidence to resolve)
```

A bind without loaded evidence has nothing to present. A bind whose `until:`
has expired does — its evidence is loaded — and is still not presented:

- The presentation serves a decision, and none can be recorded. Expiry is
hard, so no approval of the bind counts, including a new one.
- The way out is an edit of `until:`. That changes the bind's hash, so the
bind returns to the queue, where it is presented in full and diffed against
the snapshot of its last approval. Nothing is approved unseen.
- Whether the evidence passes meanwhile is what `inka eval` reports, as a
cause independent of the expiry.
- `--list` is one line per target, and the prelude is read before every
session; the sources of every expired bind there would bury the queue.

The two forms agree so that a blocked target reads the same wherever it is
met. Test binds follow the same rule: a blocked test bind is its one line,
and no case list is shown. The remedies are not specific to binds either — an
expired objective, structure or fiat reads the same way.

## Delivery through capsula

Delivery follows the [test evidence](test-evidence.md#delivery-through-capsula)
Expand Down
26 changes: 26 additions & 0 deletions docs/ja/design/calc-evidence.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,32 @@ bind に対する最新の `approve` レコードのうちスナップショッ

大きな仮定集合は当面素朴に提示する。グルーピングや diff のみの表示は[未決事項](open-questions.md)。

### blocked な bind

上の提示は、判断を記録できる bind のためのものである。`inka review` が `blocked:` の下に報告する bind は、
`--list` でも対話ループの前置きでも1行で表示する。内容は理由と、それを解消する手段である。

```text
blocked:
bind:margin_ok — approvals no longer count: the current phase is past until:M2 (edit `until:` to resolve)
bind:detumble_ok — no imported calc evidence provides `AOCS::?verify_detumble` (deliver the evidence to resolve)
```

証拠が読み込まれていない bind には、提示するものがない。`until:` が失効した bind は証拠が読み込まれているが、
それでも提示しない。理由は次のとおり。

- 提示は判断のためにあるが、記録できる判断がない。失効は hard であり、新しい承認を含めて、その bind への
承認は一切数えられない。
- 出口は `until:` の編集である。編集すると bind のハッシュが変わるので、bind はキューに戻る。そこで全体が
提示され、直近の承認のスナップショットとの diff も表示される。見ないまま承認されるものはない。
- その間に証拠が通っているかどうかは、`inka eval` が失効とは独立した原因として報告する。
- `--list` は1ターゲット1行であり、前置きはセッションのたびに読まれる。失効した bind すべてのソースを
そこに出すと、キューが埋もれる。

2つの形式で表示を揃えるのは、blocked なターゲットがどこで見ても同じに読めるようにするためである。
test の bind も同じ規則に従う。blocked な test の bind は1行だけで、ケース一覧は表示しない。解消手段の
表示も bind に限らない。失効した objective・structure・fiat も同じ形で表示する。

## capsula による配送

配送は[テスト証拠](test-evidence.md#capsula経由の配送)の手順に従い、テストのアダプターの代わりに veriq の
Expand Down