GeezerVison is showing github.com — fix: parseFrontmatter型バリデーション + repetition共有util抽出 by terisuke · Pull Request #70 · Cor-Incorporated/opencode
Conversation
What
PR #56 のレビュー残り2件を修正。
Why
- parseFrontmatter() が invalid type を無検証でキャストしていた
- repetition.test.ts が production コードを import せず独自実装していた
Closes #69
Changes
- memory/file.ts: Memory.TYPES に対するバリデーション追加
- session/repetition.ts: 新規共有util
- session/processor.ts: import に置換
- test 更新
Review
- code-reviewer Agent: CRITICAL/HIGH 0
- Codex CLI: No issues in PR A
Test plan
- bun test test/memory/file.test.ts — 19 pass
- bun test test/session/repetition.test.ts — 8 pass
- typecheck 13/13 pass
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Move detectRepetition function and constants from processor.ts to
a dedicated repetition.ts module. Test now imports production code
instead of reimplementing the algorithm.
Closes #69 (partial)
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
parseFrontmatter() now checks fm.type is a valid Memory.Type value
before casting. Invalid types return undefined instead of silently
propagating through the system.
Closes #69 (partial)
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
This PR doesn't fully meet our contributing guidelines and PR template.
What needs to be fixed:
- PR description is missing required template sections. Please use the PR template.
Please edit this PR description to address the above within 2 hours, or it will be automatically closed.
If you believe this was flagged incorrectly, please let a maintainer know.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR addresses remaining review items from PR #56 by adding runtime validation for user-editable memory frontmatter types and by extracting the repetition-detection logic into a shared production util that tests can import.
Changes:
- Add validation in
parseFrontmatter() to reject unknown type values (based on Memory.TYPES).
- Extract
detectRepetition (+ constants) into src/session/repetition.ts and reuse it from SessionProcessor and tests.
- Update/add tests to cover valid/invalid/missing memory
type parsing and to import the shared repetition util.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File |
Description |
| packages/opencode/src/memory/file.ts |
Validate frontmatter type against Memory.TYPES before casting. |
| packages/opencode/src/session/repetition.ts |
New shared repetition-detection util + exported constants. |
| packages/opencode/src/session/processor.ts |
Replace inlined repetition logic with imports from ./repetition. |
| packages/opencode/test/session/repetition.test.ts |
Switch test to import production detectRepetition + constants. |
| packages/opencode/test/memory/file.test.ts |
Add coverage for valid/invalid/missing frontmatter type. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+2
to
+3
|
|
import { detectRepetition } from "../../src/session/repetition"
|
|
|
import { REPETITION_THRESHOLD, REPETITION_WINDOW } from "../../src/session/repetition"
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two imports come from the same module; consider combining them into a single import to reduce redundancy and keep imports easier to maintain.
|
import { detectRepetition } from "../../src/session/repetition" |
|
import { REPETITION_THRESHOLD, REPETITION_WINDOW } from "../../src/session/repetition" |
|
import { detectRepetition, REPETITION_THRESHOLD, REPETITION_WINDOW } from "../../src/session/repetition" |
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Copilot uses AI. Check for mistakes.
This was referenced Apr 5, 2026
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.