1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
---
name: review-subsystem
description: Architecture and code review of an existing TeachOS subsystem (for example VFS, memory allocators, the device model, kstd, ACPI) with no diff involved. Use for design audits, preparing a refactoring or extension, or getting oriented in an area. For pending diffs, branches or MRs, use review-changes.
---
# Review an existing subsystem
Mentor mode applies (AGENTS.md §1): analysis, trade-offs and direction, never implementations.
Report in the conversation, not in the repository.
## 1. Scope
If the subsystem is ambiguous, ask.
List its files: `git ls-files <dirs>`, split into interface headers, implementation, tests and docs.
State the boundary.
If it is large [threshold: ~40 files], review a vertical slice and say what you left out.
## 2. Reading order
1. Interface headers, then the relevant `docs/briefs/` and `docs/`.
2. Implementation.
3. Tests.
4. History: `git log --oneline -- <paths>`.
Recent churn shows unstable or unclear areas.
## 3. Build a model before critiquing
Write a short "what this is" that the maintainer can confirm or correct: responsibilities, key types and who owns them, lifecycle, dependencies in and out (map includes with `git grep -n '#include'`), execution contexts (boot, thread, interrupt), and the invariants the code relies on.
## 4. Analyses (each may yield findings)
- Architecture:
cohesion, coupling, layering violations, whether the abstractions fit, use of the `kapi` seam, consistency with recorded decisions.
List places where docs and code disagree.
- Correctness risks:
error paths, cleanup, lifetimes, state machines, integer edge cases, unimplemented branches.
- Concurrency and interrupts:
inventory the shared state, what protects it, lock ordering, what can run in interrupt context.
- Freestanding discipline:
kstd use, hidden allocation, stack use.
- Tests:
what is covered against the risks above, and what is untestable and why (usually coupling to hardware).
- Teachability:
could this be explained in a lecture?
Separate essential complexity from accidental complexity.
Is it a good teaching example, or an advanced topic that needs prerequisites?
- Precedent:
how Linux, the BSDs, xnu or Windows handle the same problem, with a confidence label, and what is worth borrowing or avoiding.
Provide references when possible.
## 5. Design questions
Where a real choice exists, lay out the options with trade-offs, then take a position and say what would change it.
Don't present one answer as obvious.
## 6. Report
1. Overview: the model from step 3.
2. Strengths: specific and factual, not praise.
3. Findings:
most severe first.
Each has `path:line`, what and why, severity (High / Medium / Low), and confidence (verified or inferred).
4. Design trade-offs.
5. Docs versus code divergences.
6. Follow-ups, each sized roughly (afternoon / week / thesis-sized).
7. Not covered: what you didn't read, and any question that depends on planning documents outside this repository.
Rules: every finding cites a location.
Don't claim a property of the code you did not read.
If a conclusion depends on a decision that isn't recorded in the repository, say so and ask.
Don't rewrite anything.
|