Skip to content

refactor(core): make loading, the local view and recording a decision callable without a terminal (#343) - #351

Open
shunsuke-shimomura wants to merge 2 commits into
docs/340-web-ui-review-and-cardsfrom
feat/343-core-operations
Open

shunsuke-shimomura wants to merge 2 commits into
docs/340-web-ui-review-and-cardsfrom
feat/343-core-operations

Conversation

@shunsuke-shimomura

@shunsuke-shimomura shunsuke-shimomura commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Description

Closes #343. Part of #340. Stacked on #341.

A change of structure with no change of behaviour, so that a caller other than the terminal — the server, in
#345 — can use what the commands use. Three things move from inka-cli into inka-core, as plain operations
that take inputs and return typed results:

  • argument::load_argument composes loading, graph construction, shape validation and projection, and
    answers with the Argument or the findings that Rejected it — as data, written nowhere. A rejection also
    carries a typed RejectionCause: the stage that refused the project (load, sources, graph or shape), with the
    loader's LoadError kept whole for a load failure, so a caller need not parse a message.
    inka-cli/src/load.rs keeps only rendering those findings to a stream.
  • local::LocalContent is a node's local view as content to present: the comment on the block, the
    description, the evidence reference, the children with their entry comments, the deadline — the content and
    order inka review prints. write_target renders it instead of reading the view itself.
  • review::current_hash, record_decision and decide compute the hash a decision names, append the
    record, and — with an expected hash — refuse when the content is no longer what was shown. Errors are a typed
    DecideError whose messages are the ones the CLI printed.

No new crate and no dispatch layer; inka-core stays synchronous.

Test results

  • cargo test --workspace: all pass. No existing test or snapshot changed, apart from two added imports in the
    test module of inka-cli/src/review.rs.
  • cargo clippy --workspace --all-targets -- -D warnings: clean.
  • New unit tests cover the three operations, including the refusal of a changed hash, which writes nothing.

Impact

None on behaviour. inka-core gains a public API (argument, local, and the decision operations in review);
tempfile becomes a dev-dependency of inka-core.

Supplementary information

The expected-hash guard in decide has no caller yet: the CLI judges the project as it was loaded. #347 uses it.

🤖 Generated with Claude Code

https://claude.ai/code/session_014DUhbQ16uSDG5M4Lt9o3NM

@shunsuke-shimomura shunsuke-shimomura added the enhancement ✨ New feature or request label Nov 24, 2026
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Explain Change →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 6 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 5c37425 and 773941d.

Files ignored due to path filters: 1

  • Cargo.lock is excluded by !**/*.lock, !**/Cargo.lock
Files selected for processing: 10

  • crate/inka-cli/src/eval.rs
  • crate/inka-cli/src/load.rs
  • crate/inka-cli/src/review.rs
  • crate/inka-core/Cargo.toml
  • crate/inka-core/src/argument.rs
  • crate/inka-core/src/lib.rs
  • crate/inka-core/src/local.rs
  • crate/inka-core/src/review.rs
  • docs/en/design/web-ui.md
  • docs/ja/design/web-ui.md
Walkthrough

The PR moves project loading, local node-content assembly, and review-decision recording into inka-core. The CLI calls these core APIs and renders their returned data and diagnostics. Tests cover loading outcomes, local content, decision recording, hash mismatches, and invalid targets.

Changes: Shared core operations

Layer / File(s) Summary
Load arguments and update CLI callers
crate/inka-core/src/argument.rs, crate/inka-core/src/lib.rs, crate/inka-core/Cargo.toml, crate/inka-cli/src/load.rs, crate/inka-cli/src/eval.rs
inka-core adds argument-loading APIs that return the manifest, evidence, validated view, source map, and warnings, or rejection diagnostics. The CLI delegates loading to this API and renders warnings or diagnostics.
Build and render local node content
crate/inka-core/src/local.rs, crate/inka-core/src/lib.rs, crate/inka-cli/src/review.rs
inka-core adds structured local content for node details, evidence, children, and deadlines. The review CLI renders the supplied content, including child descriptions and comments.
Record decisions through core review APIs
crate/inka-core/src/review.rs, crate/inka-cli/src/review.rs
inka-core adds decision recording with target validation and an optional expected-hash check. The CLI passes single decisions and queued decisions to the core APIs. Tests cover successful records, hash mismatches, unknown targets, and unhashable targets.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Refactor

Sequence Diagram(s)

sequenceDiagram
  participant InkaCli
  participant InkaCoreReview
  participant ApprovalStore
  InkaCli->>InkaCoreReview: decide with target and optional expected hash
  InkaCoreReview->>InkaCoreReview: calculate current view hash
  InkaCoreReview->>ApprovalStore: append decision record
  ApprovalStore-->>InkaCoreReview: return record
  InkaCoreReview-->>InkaCli: return record or typed error
Loading

Possibly related issues

  • Issue 344 — This PR adds the structured local-content types that the Web UI data types depend on; it does not add generated front-end types.
  • Issue 340 — This PR implements core operations described as part of the Web UI revision.
  • Issue 345 — This PR supplies core loading and local-view operations that the server route needs.
  • Issue 346 — This PR moves local-view content into core as structured data for the browser rendering work.
  • Issue 347 — This PR adds decision recording with an expected-hash check; it does not add the browser route or its safeguards.
Merge Risk: Minimal · previous review 5c374 · assessed changes only

Path filters excluded changed files. This rating applies only to the assessed changes.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the refactor scope (core loading, local view, and decision recording callable without a terminal) and the issue number. The changeset moves project loading into inka-core as load_argum…
Linked Issues check Passed Directly linked issue #343 has five closing conditions. Current PR #351 addresses each one (stack objectives, current PR evidence):

1. Load project into shared view, returning view or diagnostics as …
Out of Scope Changes check Passed All changes introduced by PR #351 map to #343 objectives or their direct support:
- inka-core/src/argument.rs, local.rs, review.rs and lib.rs changes implement the loading, local-view and deci…
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title names the refactor scope (core loading, local view, and decision recording callable without a terminal) and the issue number. The changeset moves project loading into inka-core as load_argument, adds LocalContent, and adds current_hash, record_decision, and decide. The title covers the main change. It is somewhat long at 104 characters, but it is specific and accurate.

Full details: Linked Issues check

Explanation

Directly linked issue #343 has five closing conditions. Current PR #351 addresses each one (stack objectives, current PR evidence):

  1. Load project into shared view, returning view or diagnostics as data [#343]: Addressed by PR #351. inka-core/src/argument.rs adds load_argument and load_argument_with, returning Result<Argument, Rejected>. Rejected carries SourceMap and Diagnostics. inka-cli/src/load.rs only renders them.
  2. Local view of a node as structure, in inka review order [#343]: Addressed by PR #351. inka-core/src/local.rs adds LocalContent::of, which preserves direct-child declaration order. review.rs queue rendering reads content from LocalContent.
  3. Record one decision: compute hash, optionally refuse on expected-hash mismatch, append record, typed errors [#343]: Addressed by PR #351. review.rs adds current_hash, record_decision, decide and DecideError. The expected-hash refusal occurs before any write.
  4. CLI uses these operations and keeps only parsing, prompting, rendering [#343]: Addressed by PR #351. load.rs, review.rs and eval.rs delegate to core, per the change summaries.
  5. Existing CLI tests and snapshots pass unchanged [#343]: Addressed by PR #351 per the author report. Only two imports were added in the review.rs test module. No snapshot changed. Test results are author-reported; I did not re-run them.

Limits: Stack members #341 (uncertain), #354 and #355 (uncertain) lack current review evidence. #341 is the merge base of this PR, so its code is part of the base that the reviewed changes use. Its content was not separately reviewed. Later members are not required by #343 objectives and were not used to establish compliance. Evidence relies on the supplied file summaries and author report.

Full details: Out of Scope Changes check

Explanation

All changes introduced by PR #351 map to #343 objectives or their direct support:

  • inka-core/src/argument.rs, local.rs, review.rs and lib.rs changes implement the loading, local-view and decision operations (#343).
  • inka-cli changes (load.rs, review.rs, eval.rs) remove the moved logic and call core operations (#343).
  • inka-core/Cargo.toml adds tempfile as a dev-dependency. It supports the new unit tests only.
  • Cargo.lock is in ignored_files and was not assessed.
  • The expected-hash guard in decide has no CLI caller yet. It is part of the #343 requirement for optional refusal, so it is in scope.

No unrelated behaviour change was identified in the supplied evidence.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional comments: 1

crate/inka-core/src/argument.rs: 1

75-75: Trivial · Maintainability & Code Quality · Quick win

Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Preserve the structural load error alongside its diagnostic.

This conversion removes the LoadError variant and its underlying cause. A non-terminal caller cannot distinguish a missing manifest from a permission failure without parsing text. Retain a typed rejection cause alongside diagnostics; the CLI can continue to render the same message.

Based on learnings, “Flag library code that swallows or erases error context by converting to generic error types.”

Source: Learnings

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 40a1e60 and 5c37425.

Files ignored due to path filters: 1

  • Cargo.lock is excluded by !**/*.lock, !**/Cargo.lock
Files selected for processing: 8

  • crate/inka-cli/src/eval.rs
  • crate/inka-cli/src/load.rs
  • crate/inka-cli/src/review.rs
  • crate/inka-core/Cargo.toml
  • crate/inka-core/src/argument.rs
  • crate/inka-core/src/lib.rs
  • crate/inka-core/src/local.rs
  • crate/inka-core/src/review.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

shunsuke-shimomura and others added 2 commits November 26, 2026 10:57
… callable without a terminal (#343)

Three things a caller other than the terminal needs lived inside `inka-cli`,
tied to its output:

- `argument::load_argument` loads a project to the shared view and answers
  with the argument or the findings that rejected it, as data.
- `local::LocalContent` is a node's local view as content to present: what
  `inka review` prints, in the order it prints it.
- `review::decide` and `review::record_decision` compute the current hash,
  optionally refuse when it is not the expected one, and append the record,
  with typed errors.

`inka-cli` calls these and keeps argument parsing, prompting and rendering.
No behaviour changes: the existing tests and snapshots pass as they were.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014DUhbQ16uSDG5M4Lt9o3NM
…ror (#343)

`Rejected` carried only the findings, so a caller that is not a terminal had
to parse a message to tell a missing manifest from a permission failure.
`RejectionCause` names the stage that refused the project — load, sources,
graph or shape — and for a load failure keeps the loader's `LoadError` whole.

The findings, and what the CLI prints, are unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014DUhbQ16uSDG5M4Lt9o3NM

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement ✨ New feature or request sys::SE システムズエンジニアリング

Projects

None yet

Development

Successfully merging this pull request may close these issues.

core: make loading, the local view and recording a decision callable without a terminal

1 participant