A production stack frame names a source file nobody on the team wrote — how do you trace it back?
answer
- the frame is an indirection, not a wall
- read the header first
- provenance comment names the input
- debugger needs the emitted file present
- ownership follows the input or template
basics
~20 sRead the emitted file's header to learn which generator owns it, then use its provenance comment to map the frame back to the input declaration and the template that produced that line. The fix lands in the input or the template, never in the frame's file.
solid answer
~50 sThe frame is not a dead end, it is an indirection. First confirm the file is derived — the header marker says so — and note which generator and which output directory own it. Then use whatever provenance the file carries, a comment naming the declaration it came from or a stable naming convention, to get from the emitted line to the input that produced it. To step through it rather than read it, the emitted source has to be on the debugger's source path and the compiled artifact has to have kept line information for it; emission happened during the build, so at run time the emitted file is all that is left. Finally decide where the defect actually lives: in the input description, in the template or generator, or in the contract the emitted code was asked to implement. The frame's file is evidence, not the patient.
code
pseudocode · 9 lines// GENERATED - DO NOT EDIT
// derived from: Order.total (declaration in the hand-written tree)
// template: value-mapper, numeric branch
function readTotal(source)
value = source.total // <- the reported frame is this line
if value is missing
throw MappingError("total")
return round(value)go deeper
Recall that a file you did not write still came from something you did: look at the top of it for a comment naming the generator and the declaration it was derived from.
Explain the inversion mechanically — header marker, provenance comment or naming convention, re-derive and read — and name what a debugger needs before it can show that file's source at all.
Demonstrate triage under pressure: confirm the file is derived, map the frame to an input, and state whether the defect is in the input, the template or the contract before anyone touches a keyboard.
Argue the standard: provenance emitted unconditionally, emitted source archived with every build, and an ownership rule saying machine-written output is never the owner of a defect found in it.
A stack frame pointing at a file nobody on the team wrote feels like a wall. It is not — it is one indirection, and the work is to invert it in three steps: whose output is this, which input produced this line, and where does the defect actually live. ## Step one: whose output is this? Open the file. A well-behaved generator puts a marker at the top saying the file is derived, which generator emitted it, and what it was derived from. If the header is missing, the directory usually answers it — emitted code should live in a tree that holds nothing hand-written. If neither answers it, that is the first defect to fix, because every future trace pays the same tax. ## Step two: from a line to an input Three things get you from the emitted line back to something a person wrote, in descending order of reliability: 1. **A provenance comment on or near the emitted construct**, naming the declaration or description element it came from. This is the strongest signal and it costs the generator one comment per emitted member. 2. **A naming convention** — an emitted type or member whose name is derived mechanically from the input's name. Reliable until two inputs mangle to the same name. 3. **Re-deriving and reading.** Run the generator over the current inputs, open the emitted file, and read the shape around the reported line. This always works and is the slowest. An emitted line is usually the *symptom* of a decision the generator made much earlier — a branch in the template chosen because some property of the input was or was not present. So the question to carry back is not only "which input" but "which property of that input made the template emit this branch". ## Step three: stepping through it Reading is often enough; stepping is sometimes necessary. Two conditions have to hold, and teams routinely discover them only in an incident: - **The emitted source must be available to the debugger**, at the path the compiled artifact records. If output is deleted after the build, or emitted into a path that no longer exists on the machine doing the debugging, the debugger has line numbers and nothing to show against them. - **The compiled artifact must have kept line information** for the emitted file, and those lines must correspond to the file the debugger is showing — which they do not if the file was re-derived after the artifact was built, from different inputs. Note the phase: the generator ran **during the build**. At run time nothing is generating anything; only the emitted source and the artifact built from it remain. Where a toolchain can map emitted lines back to the template that produced them, that mapping is another build-time product that must be shipped with the artifact to be useful. ## Where the defect actually lives | Where it lives | How it shows | Where the fix goes | |---|---|---| | The input description | Output faithfully encodes something wrong or missing | The declaration or description; the output is only reporting it | | The template or generator | The same wrong shape appears in every emitted file of that kind | The template, then re-derive everything | | The contract the output implements | Emitted code is internally fine but violates what callers assume | The contract, and usually the template that encodes it | | The consumer | Output is correct; the caller passes something it never promised | The caller | The ownership answer that interviewers listen for is that **machine-written output is never the owner**. "The generator produced it, so it is the generator team's bug" is as wrong as "it is in our repository, so it is ours": ownership follows the input or the template, whichever caused it. ## Making the next trace cheap The organisational half matters more than the debugging half. Emit provenance comments unconditionally. Keep emitted source available in the same artifact archive as everything else the build produced. Make the generator's identity and its input revision visible somewhere a responder can read without reconstructing the build. Each of those is minutes of work at emission time and removes the worst part of an incident — the period where the responder does not yet know who wrote the code they are looking at.
- The debugger shows the frame but will not display any source for it. What is missing?Either the emitted file is not where the compiled artifact says it is — deleted after the build, or emitted into a path that does not exist on this machine — or the artifact was built without line information for it. A third possibility is that the file present is a later re-derivation from different inputs, so its lines no longer match the artifact.
- The emitted code is exactly what the input described, and the input was wrong. Whose defect is it?The owner of the input description. Emitted output that faithfully encodes a wrong input is a correct generator reporting a wrong instruction. Fixing it in the output is both wasted work and a lie the next re-derivation removes. The generator team only owns it when the same wrong shape appears for inputs that were right.
- Why does emitting a provenance comment beat relying on a naming convention?A convention holds only while names map one to one. Two inputs that mangle to the same emitted name, or a template that renames for legality, break the inversion silently. A comment records the actual source element the generator was holding when it emitted that member, which survives renaming, mangling and collisions.
saying these in an interview costs you the question
- Treats a frame in emitted code as unowned and unactionable
- Fixes the emitted file and calls the incident closed
- Assumes the generator runs at run time and can be re-run then
- Blames the generator before checking the input it was given
- Deletes emitted output after the build, then cannot debug it
- Expects a debugger to show source that was never kept anywhere