Skip to content

refactor(source): parse the source into a typed model at the boundary - #231

Merged
furedea merged 2 commits into
mainfrom
refactor/parse-source-into-typed-model
Nov 12, 2026
Merged

furedea merged 2 commits into
mainfrom
refactor/parse-source-into-typed-model

Conversation

@furedea-agent

@furedea-agent furedea-agent Bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

概要

Issue #217 の波 4 source です.境界(loader)で source を読んで解析・検証し,型付きの Source にします.計算は &Source だけを受け取って FileOp を返し,パスで探したり生の文字列を解析したりしません.

計画: #217 (comment)

変更内容

  • source_model::Source を追加.manifest,フック設定,権限規則,除外コマンドの正規表現ポリシー,秘密パスのポリシー,スキル(metadata と描画方針),Claude 設定,Codex 設定,プロバイダ別の source 設定,外部 hook bundle を持ちます.解析の失敗はすべて境界で出て,エラーはファイルのパスを含みます.
  • 丸ごとコピーするだけのディレクトリは「場所とファイル一覧」(SourceDir)だけを持ち,FileOp::CopyTree/CopyFile で返します.中身は読みません.
  • SnapshotRequest,Snapshot,Tree を削除.何をどこから読むかは shell::load_source だけが知ります(LoadInputs は呼び出し側が渡すプロバイダと外部入力だけ).
  • install を Source と InstalledConfigs(境界で解析済みのインストール済み設定)から 1 回で計画します(InstallPlan).段階ごとの snapshot の取り直しはありません.
    • 他プロバイダのスキル出力をコピーするプロバイダは,同じ Source から描画し直し,FileOp::relocated で出力先を移します.ディスクから読み戻しません.
    • Claude 設定のインストール済み設定とのマージを描画の中で行い,「描画してから保存」の段階をなくしました.
    • bundle の asset の衝突は,それまでの段階が出力に残すファイルの一覧(SourceDir の一覧から導出)と照合します.
  • generate-hook-bundle の staging も型付き(Staged)にしました.
  • shell::load を load.rs/load/files.rs/load/bundle.rs に,generation/skills.rs を skills.rs/skills/rendering.rs に分割しました(1 ファイル 500 行の制限のため).
  • ADR-0028 に 2 つ目の amendment を追記し,DESIGN.md と DESIGN_ja.md を更新しました.

挙動の変化(生成物は変わりません)

  • スキルは name,description,レベル 1 の見出しが必須になり,どのコマンドでも source の読み込みで検証されます(以前は list skills だけが見出しを要求).
  • allowed_commands.json,プロバイダの source 設定,bundle のフックファイルの不正は,install 以外のコマンドでも読み込み時に拒否されます.
  • 2 つのファイルが同じインストール先に写る bundle は,読み込み時に拒否されます.
  • verify は source 全体を読み込んでから manifest の実行時コマンドを確認します.

検証

  • cargo test: 全通過(lib 247,統合テスト含む).complete_source_golden,neutral_generated_artifacts,nix_provider_registry を含み,生成物と nix/providers.json は 1 バイトも変わっていません.
  • cargo clippy -- -D warnings(CI と同じ): 警告なし.cargo fmt --check: 差分なし.
  • 追加したテスト: loader(型付きの値,コピー専用ディレクトリ,境界でのエラーとパス,symlink の扱い,bundle の重複と version),FileOp::relocated,InstallPlan::planned_files.旧 Snapshot のテストは loader のテストに置き換えました.

残り

Issue #217 の受け入れ条件は,この PR で波 4 まで揃います.ただし次が残るため Refs にしています.

  • layout.rs の hermes_config/dsh の package.json のパスと,generation/hook_bundle.rs の Codex の設定ファイルは,今もプロバイダ名で引いています(種類による分岐ではなく名前での参照).
  • Issue に「未着手の指摘」として挙がっているプロバイダ enum の重複(ProviderId/render::Provider/cli::Provider),ConfigLocation 型,秘密パスポリシーの Codex 適用.
  • 計画は「モジュールごとに段階的に」でしたが,GenerationContext が Tree を持っていたため,モジュール単位では緑のまま分けられず,1 つのコミットにまとまっています(コード 1,ドキュメント 1).

Refs #217

🤖 Generated with Claude Code

furedea and others added 2 commits November 12, 2026 04:27
Computation used to receive a Snapshot of files, look them up by path, and parse raw text where it
used them. The loader now reads the source tree, the external hook bundles, and the external
skills, parses and validates every document once (each error names its file), and returns a typed
`Source`. Computation takes `&Source` and returns FileOps.

- add `source_model::Source`; directories that are only copied are a location and a file list
- add `shell::load_source`/`load_installed`; remove `SnapshotRequest`, `Snapshot`, and `Tree`
- plan the whole install from `Source` + installed configs in one pass; a provider that copies
  another's skills renders them again and moves them with `FileOp::relocated` instead of reading
  the other's output back from disk
- merge the Claude settings into the installed ones while rendering, replacing the
  render-then-preserve step
- check bundle asset conflicts against the planned files rather than a re-read staging directory
- type the staged home of `generate-hook-bundle` instead of snapshotting it

Generated output is byte-identical: the golden tests and nix/providers.json are unchanged.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@furedea

furedea commented Nov 11, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T19:32:24.875075Z e8d5b1e Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

Review summary

No P0–P3 findings.

Reviewed the move from a Snapshot to a typed Source (loader, InstallPlan, ProviderRenderer, external hook bundles, sync, verify). Things I checked against the old behavior:

  • Installed config merge: load_installed reads configs from the real prefix with no sidecar. The old flow copied only the config into staging and merged there, so it never saw the sidecar either. Claude settings (KeyScope::Every) has no sidecar. config_path() and the registration.path() lookup give the same key for SameAsHookRegistration.
  • Claude settings merge moved into rendering: this replaces preserve_claude_settings. install_keeps_top_level_claude_settings_it_does_not_generate still covers it.
  • Pi skills: Pi now re-renders the Codex skills and moves them with FileOp::relocated instead of copying from disk. The result is the same, and Pi no longer depends on the Codex provider being rendered first.
  • Bundle asset conflicts: these are now checked against planned_files (synced-directory listings plus bridge assets). The executor copies trees with the same regular_files walk, so the list matches what lands on disk. The two-bundle conflict integration test still covers this path.
  • Symlinks: the skill and support-entry filters match the old snapshot Child semantics.
  • Stricter validation: load-time checks now run for every command, as the PR description says. The Nix module always passes a fully composed source, so generate-skills and install are unaffected.

I could not run cargo test in this environment, so this review comes from reading the code.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: e8d5b1edbc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@furedea
furedea merged commit 1f9503d into main Nov 12, 2026
21 checks passed
@furedea
furedea deleted the refactor/parse-source-into-typed-model branch November 12, 2026 03:25
furedea added a commit that referenced this pull request Nov 17, 2026
## 概要

共有の ADR チェック(`adr-check`,markdownlint,lychee)と ast-grep を採用し,CI
で実行する.ADR 本文は変更しない(agent-config ADR-0025).

Refs furedea/agent-config#169

## 変更

- 全 30 件の ADR のメタデータ行(Status,Date,Supersedes,Superseded
by,Related,Amends)を YAML front matter に移した.
- `docs/adr/.markdownlint.yml` を追加した.`default: true`,`MD013:
false`,`MD024: false` に加え,既存本文が違反する次のルールだけを無効にした.
  - MD007: 5 件(ADR-0029 のリスト字下げ)
  - MD033: 1 件(ADR-0027 の `<name>`)
- `ci.yml` に `adr-lint`(`madr-from: 31`)と
`ast-grep`(v1.6.0)を追加し,`all-green` の `needs` に加えた.
- ファイル名は既に `NNNN_words.md` 形式のため,リネームは不要.

## 保守的・曖昧な front matter の値

- ADR-0026: 本文に「superseded by」がない.スキーマが `superseded-by`
を必須とするため,ADR-0027 の `Supersedes: ADR-0026` から `superseded-by:
[ADR-0027]` を補った.
- ADR-0014: `Amends: ADR-0012` に対応するキーがない.precedent に従い `related:
[ADR-0012] # amends ADR-0012` とした.
- ADR-0021: 本文の `## Amendment (2026-10-20)` から `amended`
を作った.要約文は新しく書いた.
- ADR-0028: 2 つの Amendment 節に日付がない.git 履歴(#229,#231)から 2026-11-12 を補った.

## 確認

- `adr-check docs/adr`: 通過
- markdownlint-cli2: 0 エラー
- `lychee --offline docs/adr`: 0 エラー,壊れたリンクなし
- actionlint: `ci.yml` はエラーなし

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: furedea <[email protected]>
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant