2141. Lesson identity
2142. Learning objective
After this lesson, you can produce a repository map that identifies the relevant systems, entry points, data owners, dependency boundaries, one safe change location, and the main risks of changing it.
2143. Why this matters
An unfamiliar repository does not present its architecture in the order you need it. A plausible file can still be the wrong place to make a change because another system owns the state, another layer controls the lifecycle, or several consumers depend on the same interface. Mapping ownership turns repository exploration into a constrained engineering decision. It also gives you a precise brief to evaluate before asking an AI tool to suggest or implement a change.
2144. Prior knowledge
You should be able to inspect a proposed change, review the actual diff, validate the result, and recover when the result is unsafe. This lesson builds directly on 5.5 L2 — Inspect, validate, and recover. You should also be familiar with the project’s basic language, directory structure, and normal validation commands.
2145. Core concept
The central idea is ownership before modification.
For any requested change, distinguish four things:
- System: Which subsystem performs the behavior?
- Entry point: Where does the behavior begin or where does the relevant request enter the system?
- Data owner: Which component creates, stores, or authoritatively changes the state?
- Boundary: Which interfaces, events, services, scenes, modules, or consumers must remain compatible?
A file that displays a value may not own it. A function that receives an event may not define the rule behind it. A central utility may be easy to edit but risky because many unrelated systems depend on the same interface. The safe change location is the narrowest authoritative location that satisfies the request without crossing an unnecessary boundary.
2146. Mental model
Use the S-E-D-B map:
| Element | Question | Evidence to record |
|---|---|---|
| S — System | Which subsystem is responsible for this behavior? | Directory, module, scene, service, or component name |
| E — Entry point | Where does control or data first enter the relevant path? | Handler, public method, event listener, route, or lifecycle callback |
| D — Data owner | Where is the authoritative state created or changed? | Model, store, resource, manager, or state transition |
| B — Boundary | What must remain compatible with this change? | Callers, emitted events, serialized data, interfaces, and validation checks |
Then add a decision line:
Requested behavior → S-E-D-B evidence → safest change location → likely risks → validation evidence
Do not treat the map as a complete architecture diagram. It is a decision map for one change. Its value comes from recording evidence and uncertainty, not from drawing every dependency in the repository.
2147. Concrete example
Suppose the request is: “When a completed task grants a reward, prevent the reward from being granted twice.”
A weak orientation might select the screen that displays the reward and add a guard there. That screen is an observer, not necessarily the owner.
A stronger S-E-D-B map might look like this:
| Element | Finding | Confidence |
|---|---|---|
| System | Task completion and reward-resolution subsystem | Medium |
| Entry point | Completion handler called after the task reaches its terminal state | High |
| Data owner | The component that records completion and applies the reward transaction | Medium |
| Boundary | Save data, reward inventory state, and any event consumed by the display layer | Medium |
The safer candidate is the authoritative reward-resolution path, provided the evidence confirms that all completion sources use it. The display layer remains a risk surface because changing it may hide duplicate rewards without preventing them. Additional risks include retries, loaded completed tasks, and callers that bypass the suspected entry point.
The example demonstrates the decision, not a project-specific implementation. You must verify each finding in the repository before changing code.
2148. Common mistake
The most common mistake is equating visibility with ownership. Developers often choose the file where a value is shown, logged, or initially received because it is easy to find. This can create duplicated rules, leave alternate entry points unprotected, or introduce a fix that works only for one caller.
Another mistake is drawing a dependency map from filenames alone. Names are clues. Imports, call sites, state mutations, event flows, tests, and runtime configuration provide stronger evidence.
2149. Guided practice and practical assessment
Use the bounded unfamiliar repository snapshot below. The request is: “A completed task should not apply its reward more than once.” Do not propose or write an implementation.
Repository snapshot
src/tasks/TaskCompletionService.ts
src/rewards/RewardLedger.ts
src/ui/RewardToast.ts
src/save/SaveCodec.ts
config/event-bindings.json
tests/TaskCompletionService.test.ts
tests/RewardLedger.test.ts
The supplied evidence contains these excerpts:
config/event-bindings.json:task_finishedis routed toTaskCompletionService.complete.src/tasks/TaskCompletionService.ts, symbolcomplete: marks the task complete, callsRewardLedger.grantForTask, and then publishestask.completed.src/rewards/RewardLedger.ts, symbolsgrantForTaskandrestore:grantForTaskappends a reward entry and updates the balance;restorereplaces ledger entries from saved data.src/ui/RewardToast.ts, symbolonTaskCompleted: subscribes totask.completedand reads the current balance; it does not mutate task or reward state.src/save/SaveCodec.ts, symbolsencodeanddecode: serialize and restore both task state and reward-ledger entries.- Symbol references show that production code calls
grantForTaskonly fromTaskCompletionService.complete; mutation of reward-ledger entries occurs only insideRewardLedger. tests/TaskCompletionService.test.tscovers one normal completion.tests/RewardLedger.test.tscovers one grant and one restore, but neither test covers repeated completion or grant replay.- Relevant history note: a prior change moved reward-entry mutation from
TaskCompletionServiceintoRewardLedgerto centralize reward writes. The note does not address duplicate prevention.
Required AI verification workflow
- Give an AI tool only the request, file list, and selected excerpts. Ask it to propose candidate search paths or summarize the responsibilities of the selected files.
- Record each useful AI statement in a claim log with four fields: claim, proposed source, verification result, and citation.
- Verify or reject every claim against the supplied source excerpts, symbol references, tests, configuration, or history note. Cite file paths and symbols, such as
src/rewards/RewardLedger.ts::grantForTask; the AI summary itself is not evidence. - Mark unsupported claims unknown rather than filling gaps with guesses.
Submission
Submit one text artifact named repository-map.md containing:
- an S-E-D-B map with evidence paths and confirmed, inferred, or unknown labels;
- the AI claim log;
- one accepted future change location and one rejected location, each justified with repository evidence;
- at least three risks, with one risk-linked validation check for each; and
- the evidence that would make you revise the accepted location.
The mandatory decision is: Which location would you authorize for a future change, and what evidence would make you change that decision?
2150. Validation / evidence
A reviewer scores repository-map.md out of 20 points:
| Criterion | 4 points | 2–3 points | 0–1 point |
|---|---|---|---|
| Ownership accuracy | Correctly distinguishes the system, entry point, data owner, and boundaries | Mostly correct, with a minor ownership ambiguity | Confuses visibility, invocation, or ownership |
| Dependency reasoning | Traces relevant calls, state mutations, consumers, persistence, and alternate paths | Traces the main path but misses an important dependency | Relies mainly on filenames or assumptions |
| Evidence quality | Supports claims with precise file-path and symbol citations from multiple evidence types | Provides relevant but incomplete or imprecise citations | Treats unsupported statements or AI output as evidence |
| Uncertainty handling | Consistently labels confidence and identifies evidence needed to resolve unknowns | Labels uncertainty but does not fully explain how to resolve it | Presents guesses as confirmed findings |
| Decision justification | Defends one accepted and one rejected location and links three risks to specific validation checks | Makes the decision but incompletely connects risks and checks | Gives no defensible location decision or risk-linked checks |
A passing submission earns at least 15/20 and scores at least 2 points in every criterion. The multiple-choice quiz remains a secondary knowledge check; it does not replace this practical assessment.
2151. Key takeaways
- Map ownership before selecting a file to change.
- Separate the system, entry point, data owner, and boundary.
- Prefer repository evidence over filenames or AI-generated guesses.
- Choose the narrowest authoritative change location, not merely the easiest file to edit.
- Record uncertainty and risks so later inspection can test the decision.
2152. Next lesson
Continue to 5.6 L2 — Plan a staged multi-system change. Carry the approved change location, ownership boundaries, risks, unresolved uncertainties, and validation checks from your repository map into that lesson as constraints for the staged plan.
2153. Knowledge check
Answer these items for yourself before reading the answers.
What is the primary purpose of an S-E-D-B repository map?
Show answer and feedback
Answer: To choose an evidence-supported, low-risk location for a specific change.
Why: The map is a focused decision tool. It records enough evidence about systems, entry points, data ownership, and boundaries to select and evaluate a safe change location.
Which finding most strongly identifies the data owner?
Show answer and feedback
Answer: The component that creates or authoritatively changes the state.
Why: Display code and filenames provide clues, but ownership is best supported by evidence showing where authoritative state is created or changed.
Why should a repository map distinguish confirmed, inferred, and unknown findings?
Show answer and feedback
Answer: To expose uncertainty and identify what the next inspection must verify.
Why: Confidence labels prevent guesses from being treated as facts. They make the map useful for planning the next inspection and for evaluating risk.
Which location is usually the strongest candidate for a safe change?
Show answer and feedback
Answer: The narrowest authoritative location that satisfies the request without an unnecessary boundary crossing.
Why: A safe candidate is close to the authoritative rule or state while minimizing the number of interfaces and consumers placed at risk.