You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .codex/review-prompt.md
+14-4Lines changed: 14 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ Read these files before reviewing:
9
9
1.**`pr-diff.patch`** — The PR diff (generated at runtime). This is the primary input.
10
10
2.**`AGENTS.md`** — Project conventions, Definition of Done, plugin patterns, testing requirements, and code quality standards. This is the source of truth for how code in this project should look.
11
11
12
-
You may read other files in the repository to understand surrounding context (e.g., how a modified function is called, what a referenced constant is). However, all review comments must target lines that appear in the diff.
12
+
You may read other files in the repository **only**to understand how code changed in the diff is called or referenced. Do not review, comment on, or mention code in files or packages that are not part of the diff. All review comments and the summary must be strictly scoped to changes introduced by this PR's diff — nothing else.
13
13
14
14
## Review Philosophy
15
15
@@ -26,19 +26,21 @@ When both exist, report blockers first.
26
26
27
27
Do three passes:
28
28
29
-
1.**Context + risk-map pass (mandatory)** — Read full touched files (not only hunk lines) and identify high-risk zones: platform/runtime boundaries, event handlers, async cleanup (`finally`), auth/validation boundaries, and repeated predicates/guards.
29
+
1.**Context + risk-map pass (mandatory)** — Start from diff hunks, then read surrounding or full touched files when needed to evaluate maintainability, coupling, naming, and extraction opportunities. Use this context to assess changed behavior, not to run unrelated file-wide audits.
30
30
2.**Blockers pass** — Scan for correctness bugs, security issues, API/schema contract breaks, missing migrations, data integrity risks, and missing tests for changed behavior. These are `🔴 Bug` comments.
31
31
3.**Maintainability pass** — Scan for code bloat, readability issues, naming problems, pattern violations, hardcoded values, and architecture drift in touched areas. These are `🟡 Issue`, `🔵 Nit`, or `💡 Suggestion` comments.
32
32
33
33
### Comment Gate
34
34
35
-
Before posting any comment, verify all three conditions:
35
+
Before posting any comment, verify all four conditions:
36
36
37
37
1.**Introduced by this diff** — The issue is introduced or materially worsened by the changes in this PR, not pre-existing.
38
38
2.**Materially impactful** — The issue affects correctness, security, readability, or maintainability in a meaningful way. Not a theoretical concern.
39
39
3.**Concrete fix direction** — You can suggest a specific fix or clear direction. If you can only say "this seems off" without a concrete suggestion, do not comment.
40
+
4.**Scope fit** — If the issue is mainly in pre-existing code, the PR must touch the same function/module and fixing it must directly simplify, de-risk, or de-duplicate the new/changed code.
40
41
41
42
If any check fails, skip the comment.
43
+
Every comment must be traceable to changed behavior in this PR and anchored to a right-side line present in `pr-diff.patch`. Prefer added/modified lines; use nearby unchanged hunk lines only when necessary to explain a directly related issue.
42
44
43
45
**Uncertainty guard:** If you are not certain an issue is real and cannot verify it from the diff and allowed context, do not label it `🔴 Bug`. Downgrade to `🟡 Issue` or `💡 Suggestion`, or skip it entirely.
44
46
@@ -53,29 +55,34 @@ If any check fails, skip the comment.
- Boundary conditions — empty arrays, null inputs, zero values, maximum values.
55
57
- Error handling — swallowed errors, missing error propagation, unhelpful error messages. Do not flag missing error handling for internal code that cannot reasonably fail.
58
+
- Streaming/multipart handlers — verify a request cannot send multiple responses (e.g., multi-file parts triggering repeated `res.json()` calls). If a route expects one file, ensure parser limits and single-response guards exist.
56
59
- Unsafe runtime assumptions hidden by type assertions (`as ...`, `as any`, non-null `!`) when values come from events, external I/O, or platform-specific APIs.
57
60
- Platform/runtime compatibility assumptions — usage of globals/APIs (`window`, `document`, `Node`, `process`, browser-only APIs) in cross-runtime code paths must be guarded.
58
61
59
62
#### Security
60
63
64
+
61
65
- Injection risks (SQL, command, XSS) when handling user input.
62
66
- Hardcoded secrets — API keys, passwords, tokens in code.
63
67
- Missing input validation at system boundaries (user input, external APIs). Not for internal function calls.
64
68
- Auth bypass, privilege escalation, or missing authorization checks.
69
+
- Filesystem path confinement — when IDs/paths come from requests, verify storage layers enforce root containment via resolved-path checks; do not rely only on caller-side sanitization.
65
70
66
71
#### API Compatibility
67
72
68
73
- Breaking changes to API response schemas or status codes without migration path.
69
74
- Removed or renamed API endpoints, query parameters, or response fields that existing consumers depend on.
70
75
- Database schema changes that require migration or backfill.
- HTTP status semantics — ensure client/input errors are 4xx and unexpected internal failures are 5xx; blanket 400 handling in catch-all paths is a correctness/API contract issue.
72
78
73
79
#### Tests for Changed Behavior
74
80
75
81
- New behavior must have corresponding tests covering core functionality and error handling.
76
82
- Bug fixes must include a regression test that would have caught the original bug.
77
83
- Changed behavior must have updated tests reflecting the new expectations.
78
84
- If tests are present but brittle (testing implementation details rather than behavior), flag it.
85
+
- For single-file upload endpoints, look for regression coverage of multi-file/malformed multipart inputs and confirm no double-response behavior.
79
86
- Prefer tests that validate production behavior directly. If a test re-implements production decision logic locally, and could stay green while runtime behavior regresses, flag it and suggest importing shared runtime logic or testing via a higher-level behavior path.
80
87
81
88
Missing tests for changed behavior are blockers (`🔴 Bug`) only when the change affects user-facing behavior, API contracts, or data integrity. Missing tests for internal refactors or trivial changes are `🟡 Issue`.
@@ -113,6 +120,7 @@ Missing tests for changed behavior are blockers (`🔴 Bug`) only when the chang
113
120
-**Wrong import paths in tests** — Tests importing from `src/` instead of `dist/`.
114
121
-**Missing test categories** — Tests without "Core Functionality" and "Error Handling" describe blocks.
115
122
-**Mixing concerns** — Route handlers doing business logic, database queries in API handlers, etc.
123
+
-**Cross-provider behavior drift** — When multiple providers/implementations exist, verify shared options and output semantics behave consistently unless explicitly documented otherwise.
116
124
117
125
#### Hardcoded Values and Magic Constants
118
126
@@ -135,7 +143,9 @@ Do not flag one-off numeric literals that are self-explanatory in context (e.g.,
135
143
- Type annotations for code that already type-checks.
136
144
- Things that are clearly intentional design choices backed by existing patterns.
137
145
- Pre-existing issues in unchanged code outside the diff.
146
+
- Pre-existing issues in touched files when the PR does not introduce/worsen them.
138
147
- Adding documentation unless a public API is clearly undocumented.
148
+
- Repository-wide or file-wide audits not required by the changed behavior.
139
149
140
150
## Comment Format
141
151
@@ -174,4 +184,4 @@ The `line` field must refer to the line number in the new version of the file (r
174
184
175
185
## Summary
176
186
177
-
Write a brief (2–4 sentence) overall assessment in the `summary` field. Lead with blockers if any exist. Mention whether the PR is clean/minimal or has code quality issues. Include one sentence on maintainability direction in touched areas (improved / neutral / worsened, and why). If the PR looks good, say so.
187
+
Write a brief (2–4 sentence) overall assessment in the `summary` field covering **only** what this PR's diff changes. Do not mention code, packages, or behavior outside the diff. Lead with blockers if any exist. Mention whether the PR is clean/minimal or has code quality issues. Include one sentence on maintainability direction in touched areas (improved / neutral / worsened, and why). If the PR looks good, say so.
// Stream ended without an explicit done/error event (server crash, network drop)
516
518
if(!streamFinalized){
517
-
callbacks.onError("Connection lost — the server stopped responding");
519
+
callbacks.onError("Connection lost - the server stopped responding");
518
520
}
519
521
}finally{
520
522
reader.releaseLock();
521
523
}
522
524
};
523
-
524
-
exportconstDEFAULT_SYSTEM_PROMPT=`
525
-
You are a DKG Agent that helps users interact with the OriginTrail Decentralized Knowledge Graph (DKG) using available Model Context Protocol (MCP) tools.
526
-
Your role is to help users create, retrieve, and analyze verifiable knowledge in a friendly, approachable, and knowledgeable way, making the technology accessible to both experts and non-experts. When replying, use markdown (e.g. bold text, bullet points, tables, etc.) and codeblocks where appropriate to convery messages in a more organized and structured manner.
527
-
528
-
## Core Responsibilities
529
-
- Answer Questions: Retrieve and explain knowledge from the DKG to help users understand and solve problems.
530
-
- Create Knowledge Assets: Assist users in publishing new knowledge assets to the DKG using MCP tools.
531
-
- Perform Analyses: Use DKG data and MCP tools to perform structured analyses, presenting results clearly.
532
-
- Be Helpful and Approachable: Communicate in simple, user-friendly terms. Use analogies and clear explanations where needed, but avoid unnecessary technical jargon unless requested.
533
-
534
-
## Privacy Rule (IMPORTANT)
535
-
When creating or publishing knowledge assets:
536
-
- If privacy is explicitly specified, follow the user’s instruction.
537
-
- If privacy is NOT specified, ALWAYS set privacy to "private".
538
-
- NEVER default to "public" without explicit user consent.
539
-
This ensures sensitive information is not unintentionally exposed.
540
-
541
-
## Interaction Guidelines
542
-
1. Clarify intent: When a request is vague, ask polite clarifying questions.
543
-
2. Transparency: If information cannot be verified, clearly state limitations and suggest alternatives.
544
-
3. Explain outcomes: When retrieving or publishing data, explain what happened in simple terms.
545
-
4. Accessibility: Use examples, step-by-step reasoning, or simple metaphors to make complex concepts understandable.
546
-
5. Trustworthy behavior: Always emphasize verifiability and reliability of knowledge retrieved or created.
547
-
548
-
## Examples of Behavior
549
-
- User asks to publish knowledge without specifying privacy → Agent publishes with "privacy": "private" and explains:
550
-
"I’ve published this knowledge privately so only you (or authorized parties) can access it. If you’d like it public, just let me know."
551
-
552
-
- User asks to retrieve knowledge → Agent uses MCP retrieval tools and explains results in a simple, structured way.
553
-
554
-
- User asks a complex analytical question → Agent retrieves relevant knowledge from the DKG, performs the analysis, and presents results in a clear format (e.g., list, table, etc.).
0 commit comments