Skip to content

feat(ci): storeId の完全性検査を強化 (notedeck#913 前提) - #40

Merged
hitalin merged 1 commit into
mainfrom
fix/registry-integrity-913
Aug 11, 2026
Merged

feat(ci): storeId の完全性検査を強化 (notedeck#913 前提)#40
hitalin merged 1 commit into
mainfrom
fix/registry-integrity-913

Conversation

@hitalin

@hitalin hitalin commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

なぜ

notedeck-dev/notedeck#913(設定ファイル名と表示名の分離)は storeId(レジストリのディレクトリ名)をローカル同一性の正準リンクにする設計で、その前提としてレジストリ側の機械保証 4 点が必要(詳細は notedeck#913 の仕様確定版コメント)。

何を

check-registry-integrity.mjs に検査 4 点を追加:

  1. skills の frontmatter id = ディレクトリ名の強制 — 従来 skills だけ検証がスキップされており、ID を偽った配布物による既存スキル乗っ取りの経路だった
  2. レジストリ全体(全 kind 横断)の ID 重複検査
  3. テーマ内部 ID(theme.json5 の id)の一意性検査
  4. storeId 形式検査^[a-z0-9-]{1,48}$ かつ Windows 予約デバイス名でない

現行実データは全項目 pass(174 エントリ、違反ゼロ)。一時フィクスチャで 4 検査すべての発火を確認済み。docs(registry-format / security)も追随。

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved registry integrity checks to detect invalid, duplicate, or reserved item IDs.
    • Added validation ensuring skill IDs match their directory names.
    • Added clearer reporting for malformed theme configuration files.
  • Documentation

    • Documented ID formatting requirements, uniqueness rules across item types and themes, Windows reserved-name restrictions, and skill ID matching requirements.

notedeck#913 で storeId(レジストリのディレクトリ名)がローカル同一性の
正準リンクになるため、check-registry-integrity.mjs に 4 検査を追加:

- skills も frontmatter の id = ディレクトリ名を強制
  (skills だけ S11 検査をスキップしており乗っ取り経路が残っていた)
- 全 kind 横断の ID 重複検査(storeId はレジストリ全体で一意)
- テーマ内部 ID(theme.json5 の id)の一意性検査(欠損は現状どおり許容)
- storeId 形式検査: ^[a-z0-9-]{1,48}$ かつ Windows 予約デバイス名でない

現行レジストリ実データは全項目 pass を確認済み。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The registry integrity checker now validates store ID formats, reserved names, cross-kind uniqueness, skill frontmatter IDs, and theme-internal IDs. Registry documentation describes these rules, and security documentation lists the expanded CI checks.

Changes

Registry integrity validation

Layer / File(s) Summary
ID contracts and source parsing
docs/registry-format.md, scripts/check-registry-integrity.mjs
The registry rules now cover directory ID formats, Windows reserved names, skill frontmatter IDs, and JSON5 theme parsing.
Registry and theme validation
scripts/check-registry-integrity.mjs, docs/design/security.md
The checker validates directory and skill IDs, collects IDs across item kinds and themes, reports duplicates and JSON5 parse errors, and documents the expanded CI checks.

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

Sequence Diagram(s)

sequenceDiagram
  participant CI
  participant RegistryChecker
  participant RegistryItems
  participant ThemeSources
  CI->>RegistryChecker: Run integrity checks
  RegistryChecker->>RegistryItems: Validate directory, metadata, and frontmatter IDs
  RegistryItems-->>RegistryChecker: Return collected item IDs
  RegistryChecker->>ThemeSources: Parse theme.json5 files
  ThemeSources-->>RegistryChecker: Return theme IDs
  RegistryChecker-->>CI: Report format, consistency, parse, and duplicate errors
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: strengthening CI checks for storeId integrity.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/registry-integrity-913

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

Comment @coderabbitai help to get the list of available commands.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
misstore bb47ef7 Aug 11 2026, 10:08 PM

@hitalin hitalin self-assigned this Aug 11, 2026
@hitalin
hitalin merged commit 2db779a into main Aug 11, 2026
4 of 5 checks passed

@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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/check-registry-integrity.mjs`:
- Around line 172-181: Validate the parsed result in the theme-loading flow
before accessing theme.id: when JSON5.parse returns null, an array, or any
primitive rather than an object, add an integrity error and skip ID processing.
Keep the existing parse-error handling and only execute the themeInternalIds
logic for object values.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1e2f7279-2d65-4861-a7e3-60665fc9d22b

📥 Commits

Reviewing files that changed from the base of the PR and between 8660b24 and bb47ef7.

📒 Files selected for processing (3)
  • docs/design/security.md
  • docs/registry-format.md
  • scripts/check-registry-integrity.mjs

Comment on lines +172 to +181
let theme
try {
theme = JSON5.parse(readFileSync(sourcePath, 'utf-8'))
} catch {
errors.push(`[${label}] theme.json5 が JSON5 として解釈できない`)
theme = {}
}
if (theme.id != null) {
if (!themeInternalIds.has(theme.id)) themeInternalIds.set(theme.id, [])
themeInternalIds.get(theme.id).push(id)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Trace top-level theme parsing and subsequent property access.
rg -n -C 10 'JSON5\.parse|theme\.id|themeData' \
  scripts/check-registry-integrity.mjs scripts/build-registry.js

# Confirm that the JSON5 grammar accepts null as a value.
curl -fsSL https://spec.json5.org/ | rg -n -i -C 2 'null|JSON5Value'

Repository: notedeck-dev/misstore

Length of output: 23721


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the checker control flow and its command entry point.
sed -n '1,230p' scripts/check-registry-integrity.mjs
printf '\n--- package scripts ---\n'
rg -n -C 3 'check-registry-integrity|build-registry' package.json README.md .github 2>/dev/null || true

# Probe the relevant JavaScript property-access behavior without executing repository code.
node - <<'JS'
for (const theme of [null, [], {}, 'text', 0, false]) {
  try {
    console.log(JSON.stringify({ value: theme, id: theme.id, outcome: 'no throw' }))
  } catch (error) {
    console.log(JSON.stringify({ value: theme, outcome: error.name, message: error.message }))
  }
}
JS

Repository: notedeck-dev/misstore

Length of output: 8526


非 object の theme.json5 をエラーとして処理してください。

JSON5.parse はトップレベルの null、配列、プリミティブ値を受理します。null の場合、theme.idTypeError を発生させ、CI チェックが終了します。

トップレベル値が object でない場合は integrity error を追加し、theme.id を参照しないでください。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/check-registry-integrity.mjs` around lines 172 - 181, Validate the
parsed result in the theme-loading flow before accessing theme.id: when
JSON5.parse returns null, an array, or any primitive rather than an object, add
an integrity error and skip ID processing. Keep the existing parse-error
handling and only execute the themeInternalIds logic for object values.

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