MAINFRAME ARCHAEOLOGY / MOCK 05

Legacy Rule Extraction

Design a repeatable code-analysis factory that turns CMS-scale COBOL and Assembly into line-sourced business rules and a safe subject-matter expert (SME) review workflow.

30 MINUTES 16 INTERVIEWER TURNS FULL Q & A INTERACTIVE LAB

The problem on the whiteboard

Read this once, then begin aloud. Spend the first two minutes establishing contract, actors, risk and what must remain authoritative.

Design RuleMine, a static-analysis and review platform for a mock 18-million-line estate of COBOL, Assembly, JCL and copybooks. It must extract roughly 100,000 plain-language business rules, preserve exact source provenance, correlate duplicates across four claims systems, and let subject-matter experts verify, edit, reject and search rules. Re-running the same toolchain on the same snapshot must reproduce the same result.
Central design thesis

Treat extraction as a compiler and evidence pipeline, not a single LLM prompt. Immutable snapshots, deterministic intermediate representations and versioned passes establish reproducibility; a model may phrase or classify candidates but can never invent provenance.

Scope before components

These are supplied mock numbers for sizing and follow-ups. Say your assumptions before using them.

Estate 18M LOC · 2,400 programs · 65k copybooks/includes · four systems
Target ≈100k candidate rules · 8k cross-system clusters
Delivery First complete candidate pass in 40 mock days; incremental rerun nightly
Review 120 subject-matter experts · median decision < 7 min · complete reviewer history
Trust Every sentence links to exact snapshot lines; same manifest ⇒ same canonical output

Actors

  • Legacy developer and language specialist
  • Claims policy SME
  • Review lead assigning queues
  • Auditor tracing rule to source
  • Modernization engineer consuming approved rules
  • Pipeline operator managing extractors

Functional scope

  • Immutable code ingestion and preprocessing
  • Multi-pass parse, control/data flow and rule candidates
  • Plain-language rendering with exact source spans
  • Cross-system deduplication and correlation
  • SME review, search, assignment and audit

Explicitly out

  • Executing production claims
  • Automatically deleting legacy code
  • Perfect decompilation of all dynamic behavior
  • Replacing policy documents
  • Treating unreviewed candidates as approved truth

A traceable end-to-end path

Name the authoritative state, derived projections, asynchronous boundaries and the exact point where a business decision becomes durable.

Legacy Rule Extraction reference architecture Six stage architecture from Source vault through SME review. Source vault hashed snapshot Normalize dialects/macros IR + graphs control + data flow Rule candidates deterministic evidence Correlate cluster, not merge SME review approve/reject/edit audit · policy · metrics · lineage
01 Source vault hashed snapshot
02 Normalize dialects/macros
03 IR + graphs control + data flow
04 Rule candidates deterministic evidence
05 Correlate cluster, not merge
06 SME review approve/reject/edit

Keys that preserve history

The table is logical, not a mandate for one database. Choose physical stores after access patterns, transactions, retention and rebuildability are clear.

Entity Primary / unique key Important fields and purpose
SourceSnapshot (estate_id, snapshot_id) manifest_hash, vcs_refs, encoding, created_at, immutable
SourceUnit (snapshot_id, unit_id) path, blob_hash, language, dialect, include_graph
IRNode (snapshot_id, toolchain_id, node_id) opcode, normalized_operands, source_spans
FlowEdge (snapshot_id, toolchain_id, from_id, type, to_id) control/call/data/include; derivation
RuleCandidate (snapshot_id, toolchain_id, candidate_id) predicate_ir, outcome_ir, evidence_set_hash, confidence
RuleRendering (candidate_id, rendering_version) canonical_text, sentence_span_map, model_manifest
RuleCluster (cluster_id, clustering_version) member_candidates, similarity_evidence, status
ReviewDecision (candidate_id, decision_version) reviewer, state, edits, reason_code, decided_at
POST /v1/snapshots

Register manifest; content hashes make retry idempotent

202 {snapshotId,ingestRun}
POST /v1/extraction-runs

Pin snapshot + toolchain bundle + configuration

202 {runId}
GET /v1/rules?system=&program=&state=&cursor=

Search candidates/approved rules with facets

200 {rules,nextCursor}
GET /v1/rules/{id}/evidence

Canonical text → exact spans + derivation graph

200 {sentences,spans,runManifest}
POST /v1/reviews/claim-next

Lease a stratified review item

200 {leaseId,rule}
POST /v1/rules/{id}/decisions

Expected version + lease + decision + reason

200 / 409

The complete mock interview

Answers are written in a speakable first-person style. Turn on Practice Mode to hide them, answer aloud, then reveal one at a time.

INTERVIEWER

Design the extraction and review system.

CANDIDATE

Candidate · clear top-down answerThe goal is not to ask an AI model to summarize millions of lines. The goal is to produce rule candidates that a subject expert can inspect and reproduce. Every candidate must point back to the exact old code that supports it.

Why this mattersThis gives the interviewer a map before any boxes appear, and it makes the system's most important trust decision explicit.

INTERVIEWER

Clarify functional and nonfunctional scope.

CANDIDATE

Candidate · clear top-down answerVersion one imports source and build files, follows includes and calls, finds likely business conditions, groups similar rules, and gives experts a side-by-side review screen. It does not automatically replace the old system or claim perfect understanding.

Why this mattersA narrow first release keeps the design realistic. It also shows which tempting features can wait without weakening the core product.

INTERVIEWER

Estimate the work.

CANDIDATE

Candidate · clear top-down answerParsing 18 million lines is manageable. Human review is the bottleneck: 100,000 candidates at seven minutes each means about 11,700 hours. This math tells us to prioritize high-risk rules and group duplicates before asking experts to review.

Why this mattersThe calculation is not about perfect forecasting. It identifies the part most likely to run out of capacity or delay users.

INTERVIEWER

What is the core data model?

CANDIDATE

Candidate · clear top-down answerThe main records are a fixed source snapshot, source file, parsed node, relationship, rule candidate, readable wording, review decision, and tool version. A candidate's identity comes from its logic and evidence, not from fragile line numbers. The main reads are rules by business area, all evidence for one rule, callers and data sources for one program, and every review for one candidate. Those paths guide the database and graph indexes.

Why this mattersA small set of records is easier to reason about. Exact versions keep later changes from silently rewriting an earlier decision.

INTERVIEWER

Walk the pipeline end to end.

CANDIDATE

Candidate · clear top-down answerFirst we freeze and hash the source. Next we expand included files, parse each language, connect calls and data flow, find conditions that affect business outcomes, and create candidates. Every stage writes a versioned result so a failed job can restart safely. An AI model may improve wording from a small symbolic slice, but a verifier rejects any sentence that cannot point back to exact source evidence.

Why this mattersSeparating the work into repeatable passes exposes coverage gaps and makes failures restartable. The model is limited to wording after deterministic evidence exists.

INTERVIEWER

How do you guarantee exact provenance?

CANDIDATE

Candidate · clear top-down answerEvery parsing step keeps a map back to the original bytes and lines. A rule candidate stores the smallest useful evidence graph. If one sentence in the readable rule has no supporting source span, the system marks it unsupported.

Why this mattersTracing one real request proves the boxes connect. It also exposes where we acknowledge success and where a retry may begin.

INTERVIEWER

Deep dive: explain multi-pass static analysis for legacy code.

CANDIDATE

Candidate · clear top-down answerWe use several simple analysis passes because each answers one question. Parse the syntax, resolve includes, map control flow, summarize what each program reads and writes, connect programs, then trace backward from business outcomes to the conditions that caused them. Unknown syntax becomes an explicit unknown node rather than disappearing. We prefer a visible coverage gap over a confident rule built from an incomplete path.

Why this mattersThe deep dive starts only after the basic path is clear. Use one concrete example, then state the speed-versus-correctness choice.

INTERVIEWER

Deep dive: deduplicate across four systems.

CANDIDATE

Candidate · clear top-down answerSimilar rules should be grouped, not silently merged. We compare their condition shape, outcomes, domain terms, and meaning-based text fingerprints. A strict threshold gives fewer but safer groups; a loose threshold saves more review time but may mix different policies. The screen shows matches and differences, and a subject-matter expert makes the final merge decision.

Why this mattersEvidence must be visible to a reviewer. AI may help rank or explain, but it does not become the final authority.

INTERVIEWER

Consistency, idempotency and backpressure?

CANDIDATE

Candidate · clear top-down answerImportant approvals use immediate database transactions. Extraction jobs may run more than once, so each job key includes the source snapshot and tool version; writing by content hash makes repeats harmless. Separate queues protect interactive review from large imports.

Why this mattersUse immediate agreement only for decisions that cannot be ambiguous. Let rebuildable views catch up and always show their freshness.

INTERVIEWER

Failure injection: one dialect parser silently skips an uncommon branch opcode.

CANDIDATE

Candidate · clear top-down answerA parser must never skip unknown syntax quietly. It creates an explicit unknown node and shows which possible outcomes are affected. A tool version cannot ship if rare-instruction tests or parse coverage become worse.

Why this mattersA failure answer should name the uncertain state first. Then explain how the system learns the truth before it repeats an action.

INTERVIEWER

How does the SME review application work?

CANDIDATE

Candidate · clear top-down answerThe reviewer sees plain rule wording beside highlighted source, the path through included files and calls, similar candidates, and policy links. A short lease prevents two people from silently deciding the same case; if it expires, the next reviewer still sees the earlier draft. They can approve, edit wording, split, group, reject, or report a tool bug. Every decision creates a new history record rather than overwriting the evidence.

Why this mattersThe review screen keeps evidence, uncertainty, and human authority together. Leases avoid duplicate work without hiding a previous reviewer’s reasoning.

INTERVIEWER

Failure injection: a toolchain update changes 30% of candidate IDs.

CANDIDATE

Candidate · clear top-down answerBefore a new analyzer ships, run both old and new versions on the same frozen sample. Explain every changed candidate as wording-only, evidence growth, logic change, added, or removed. Large unexplained churn blocks the release.

Why this mattersStable IDs are part of the product contract. A side-by-side tool comparison separates genuine new understanding from accidental analyzer churn.

INTERVIEWER

Security and tenant isolation?

CANDIDATE

Candidate · clear top-down answerLegacy source is highly sensitive. Keep each customer's storage, search index, encryption keys, and worker access separate. Run parsers without open internet access and with strict CPU, memory, and file limits because source files are untrusted input. Send an approved AI model only the smallest symbolic slice, and never place raw source or secrets in general logs.

Why this mattersSecurity belongs in keys, tokens, workers, and logs. It is not a single box added to the diagram at the end.

INTERVIEWER

What metrics and rollout prove this works?

CANDIDATE

Candidate · clear top-down answerMeasure parse coverage, unresolved calls, evidence-link success, review queue age, agreement between reviewers, and accuracy on a hand-labeled sample. Start with one language and one business area, then expand only when experts trust the evidence.

Why this mattersMetrics should cover user speed, system safety, and result quality. Rollout starts read-only and earns stronger automation with evidence.

INTERVIEWER

Trade-offs and traps?

CANDIDATE

Candidate · clear top-down answerA shared internal form helps compare languages, but it must keep language-specific details it cannot understand. More model context may improve prose but increases leakage and invention risk. The biggest mistake is one giant prompt over the whole codebase.

Why this mattersEvery design choice has a cost. Name the simpler alternative and explain which requirement makes the added complexity worth it.

INTERVIEWER

Give the recap you would say aloud.

CANDIDATE

Candidate · clear top-down answerIn short: freeze the old source, analyze it in small repeatable passes, keep an exact map back to original code, and give experts reviewable rule candidates. AI can explain bounded results, but deterministic analysis and human approval carry the trust.

Why this mattersThe recap should repeat the user flow, the main trust rule, the hardest failure, and the most important trade-off—not every component.

Two places to earn the strong hire

These mechanisms are the interview’s differentiators. Be able to redraw each from memory and defend its failure behavior.

01

Deep dive A · Provenance chain

Each transformation preserves an origin map and derivation edge, letting an auditor walk prose back to symbolic predicate, IR and sealed source bytes.

  1. Snapshot manifest and blob hash
  2. Preprocessor origin stack
  3. IR node with spans
  4. Minimal candidate evidence graph
  5. Sentence-to-evidence verifier
02

Deep dive B · Reviewable correlation

Similarity proposes families. It never erases the distinctions that can carry policy, date or system meaning.

  1. Deterministic blocking keys
  2. IR and controlled-text similarity
  3. Difference explanation
  4. SME relationship label
  5. Versioned cluster projection

Revise, do not hand-wave

When the interviewer injects a fault, restate the violated assumption, change state or protocol, and name the new invariant.

Injection Recovery mechanism Tempting wrong answer
01Unsupported opcode Opaque reachable IR + coverage impact Silent omission
02Include cycle Cycle-aware expansion and bounded diagnostic Infinite worker
03Parser regression Golden corpus + version rollback Overwrite old run
04Graph explosion Procedure summaries and SCC fixpoint Path enumeration
05Model invents rule Evidence-ID constrained render + verifier Prose as truth
06Toolchain churn Differential migration report Blind review transfer

Calculate before you provision

Use orders of magnitude to expose the bottleneck. State what this simple model omits.

SME review capacity lab

Estimate mock review days; change candidates, reviewer count and focused hours.

Working days at 5 focused h/day — Change an input to recalculate.
Queue
—
Assigned
—
Reviewed
—
Adjudication
—

Prove quality in production

A system is incomplete without observable user outcomes, staged deployment, rollback and an answer to “how will we know?”

Scoreboard

  • Reachable parse coverage
  • Golden-corpus precision/recall
  • Sentence evidence coverage
  • Reproducibility hash match
  • Inter-rater agreement
  • Toolchain candidate churn

Rollout ladder

  1. 01 Seal one source domain
  2. 02 Hand-label golden corpus
  3. 03 Deterministic IR + coverage UI
  4. 04 Candidate + provenance reviewer
  5. 05 Correlation across two systems
  6. 06 Expand estates behind quality gates

Corrections worth memorizing

Use these as flash cards. The right column is the compact sentence you want available under pressure.

Trap Better move
One giant LLM prompt Use ordered deterministic passes.
Line number as identity Pin blob hash plus origin span.
Unknown syntax ignored Expose opaque reachable nodes.
Dedup means delete Cluster while retaining variants.
Prose is canonical Canonicalize symbolic predicate/outcome.
Only precision Measure missing rules and estate coverage.

Vocabulary without fog

Define the term, then connect it to a concrete invariant in this design. Avoid dropping vocabulary as a substitute for reasoning.

IR
Intermediate representation: normalized program structure used by analysis passes.
CFG
Control-flow graph describing possible execution order inside a program.
Backward slice
Statements and predicates that can influence a chosen outcome.
Fixpoint
Repeated propagation until summaries stop changing.
Origin map
Mapping from normalized tokens/IR back to exact original source spans.
Opaque node
Explicit placeholder for syntax or behavior the analyzer cannot model.
Golden corpus
Expert-labeled frozen sample used to evaluate toolchain changes.
Cluster purity
Degree to which grouped candidates truly represent the same rule family.

Close with a decision, not a component list

RuleMine seals an immutable source manifest and runs a compiler-like, versioned series of preprocessing, IR, control/data-flow, slicing and candidate passes. Every derived node carries origin spans and pass lineage. A bounded model may render the symbolic candidate, but a verifier requires sentence-level evidence. Similar candidates form reviewable clusters rather than being erased. SMEs work from leased, stratified queues with side-by-side source and append-only decisions. Content-addressed tasks make retries reproducible; coverage gaps, toolchain differentials and conservative rollout keep modernization evidence trustworthy.

Rehearse again