MAINFRAME ARCHAEOLOGY / MOCK 05

Legacy Rule Extraction

Design a reproducible static-analysis factory that turns CMS-scale COBOL and Assembly into line-sourced business rules and a safe SME review workflow.

30 MINUTES16 INTERVIEWER TURNSFULL Q & AINTERACTIVE 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.

Estate18M LOC · 2,400 programs · 65k copybooks/includes · four systems
Target≈100k candidate rules · 8k cross-system clusters
DeliveryFirst complete candidate pass in 40 mock days; incremental rerun nightly
Review120 SMEs · median decision < 7 min · complete reviewer history
TrustEvery 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 architectureSix stage architecture from Source vault through SME review.Source vaulthashed snapshotNormalizedialects/macrosIR + graphscontrol + data flowRule candidatesdeterministic evidenceCorrelatecluster, not mergeSME reviewapprove/reject/editaudit · policy · metrics · lineage
01Source vaulthashed snapshot
02Normalizedialects/macros
03IR + graphscontrol + data flow
04Rule candidatesdeterministic evidence
05Correlatecluster, not merge
06SME reviewapprove/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.

EntityPrimary / unique keyImportant 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

I will define success as reproducible, inspectable candidate rules—not “an LLM summarizes 18M lines.” The source snapshot and toolchain manifest are immutable inputs. Several deterministic passes normalize dialects, expand includes, build intermediate representation, and trace control/data flow. A model can turn a bounded symbolic candidate into readable language, but sentence-level provenance is constructed from the IR, never hallucinated. SMEs remain the authority. I would ask whether production execution is available as an oracle.

INTERVIEWER

Clarify functional and nonfunctional scope.

CANDIDATE

V1 ingests source and build metadata, resolves copybooks/macros, parses supported dialects, builds call/control/data graphs, separates business predicates from technical plumbing, emits Given/When/Then-like candidates, clusters similar candidates across systems, and provides side-by-side review. Every candidate exposes exact file, snapshot, line/column and derivation. Unsupported constructs produce explicit coverage gaps. We need deterministic reruns, seven-year audit history, review queues and exports. We do not claim semantic completeness or auto-approve rules.

  • Abstention is a valid result.
  • Coverage denominator is the source estate, not only successfully parsed files.
  • Editing wording never changes the underlying evidence unnoticed.
INTERVIEWER

Estimate the work.

CANDIDATE

Eighteen million lines over 40 mock days means only 450k LOC/day, so raw parse throughput is easy; correctness, dependencies and human review dominate. One hundred thousand candidates at seven minutes each is 700k minutes, around 11,667 hours. At 120 SMEs and five focused review hours/day, a full pass is about 19.4 working days, before rework. This tells me to prioritize candidates by risk and use stratified sampling for quality—not ask every reviewer to inspect every near-duplicate.

18M LOC / 40 days = 450k LOC/day
100k × 7 min = 700k min = 11,667 h
11,667 / (120 × 5 h/day) ≈ 19.4 review days
INTERVIEWER

What is the canonical data model?

CANDIDATE

SourceSnapshot has one cryptographic manifest. SourceUnit maps paths and encoding to blob hashes. IR nodes and graph edges are namespaced by snapshot and toolchain bundle. A RuleCandidate stores normalized predicate/outcome IR and an evidence-set hash; it is not just prose. RuleRendering is versioned separately so better wording does not rewrite candidate identity. RuleCluster groups candidates but does not collapse them, because similar implementations can have meaningful jurisdiction or effective-date differences. ReviewDecision is append-oriented and optimistic-versioned.

  • Candidate identity derives from normalized logic plus evidence—not line number alone.
  • Source spans include expansion stacks back through copybooks/macros.
  • Approved rule points to exact candidate and rendering versions.
INTERVIEWER

Walk the pipeline end to end.

CANDIDATE

The source vault verifies encoding and hashes every unit, then seals a snapshot manifest. A deterministic preprocessor expands copybooks, macros and conditional compilation while recording an origin map. Language front ends parse to a common but loss-aware IR; unknown constructs become typed opaque nodes. Link passes resolve calls, files and shared data. Control- and data-flow passes create summaries per procedure, then a fixpoint propagates summaries across the call graph. Candidate passes identify externally meaningful predicates and outcomes, trace backward to source spans, and filter logging/retry/plumbing. Correlation computes blocking keys and similarities. A bounded renderer produces prose from predicate IR and receives only evidence IDs. The review index is published after run validation.

  • Each pass consumes and emits content-addressed artifacts.
  • Run manifest pins source, config, dictionaries, compiler and model information.
  • Failed partitions retry without changing completed artifacts.
INTERVIEWER

How do you guarantee exact provenance?

CANDIDATE

Preprocessing emits a bidirectional origin map: every normalized token maps to one or more original byte and line spans, including an include stack. Every IR node carries the union of contributing token spans plus the pass that created it. A candidate stores a minimal evidence subgraph. The renderer cannot provide arbitrary citations; it must assign each sentence to supplied evidence IDs. A deterministic verifier rejects a rendering if a sentence lacks evidence, points outside the snapshot, or states a literal absent from the predicate/outcome IR. The UI opens the sealed blob at exact spans and also shows expansion context.

INTERVIEWER

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

CANDIDATE

Pass one normalizes fixed/free formats, encodings and dialect syntax without erasing original coordinates. Pass two resolves includes and conditional compilation. Pass three builds per-program CFGs and symbol tables. Pass four computes procedure summaries: inputs read, records mutated, exits and side effects. Pass five resolves inter-program calls and JCL execution edges. Pass six performs backward slicing from business outcomes such as payment amount, eligibility flag or denial code to predicates that influence them. A deterministic candidate builder serializes those predicate/outcome slices. Recursive call components use bounded fixpoint iteration; unresolved dynamic calls remain gaps with impact counts.

  • Order passes explicitly; do not stuff the estate into one context window.
  • Persist intermediate artifacts for diagnosis and replay.
  • Distinguish “not a business rule” from “could not analyze.”
INTERVIEWER

Deep dive: deduplicate across four systems.

CANDIDATE

I cluster rather than merge. First create blocking keys from normalized domain terms, outcome codes and predicate shape. Within blocks, compare canonical IR features, cited policy terms and embeddings of a controlled rendering. A pairwise explanation says which predicates align and which differ. Graph clustering produces candidate families, but an SME chooses same-rule, variant, supersedes or unrelated. Effective date, geography, claim type and system remain facets. One golden business rule may link to several implementations, each with its own evidence and review state.

  • Similarity never discards a source-specific candidate.
  • Cluster version is reproducible and reviewable.
  • High-frequency copybook logic is not automatically one business rule.
INTERVIEWER

Consistency, idempotency and backpressure?

CANDIDATE

Snapshot seal, toolchain promotion, review decision and approved export need strong transactions. Extraction artifacts are immutable and eventually published. A run key is snapshot manifest + toolchain bundle + configuration hash; task keys include pass and partition. At-least-once workers write by content hash, so duplicates converge. Queues separate ingest, parse, graph fixpoint, render and reprocessing. Backpressure is measured in estimated CPU, graph fan-out and model tokens. High-risk incremental changes preempt full historical reclustering, and reviewer queues are capacity-aware.

INTERVIEWER

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

CANDIDATE

Silent skip is unacceptable. Unknown or unsupported syntax creates an opaque IR node with severity and reachability. Coverage dashboards report parsed lines, opaque reachable nodes, unresolved calls and outcome slices affected. Canary corpora contain rare opcodes and hand-labeled programs; a parser bundle cannot promote if coverage regresses. If discovered after publication, quarantine affected candidates via lineage from the parser version and opaque node, roll back the review projection, fix the parser, and run only impacted partitions plus dependent summaries. Existing reviewer decisions remain, but are visibly invalidated pending re-review.

INTERVIEWER

How does the SME review application work?

CANDIDATE

A reviewer claims a leased item from a stratified queue based on system, domain, risk and expertise. The page shows canonical rule, source beside it, highlighted evidence, call/include breadcrumb, correlated variants and official-document links. The reviewer can approve, edit wording, split, merge-as-family, reject-as-plumbing or flag analyzer defect. Decision reasons are structured. Optimistic versioning prevents two reviewers overwriting. Leads adjudicate disagreements. Search facets include system, program, rule family, outcome, review state, analyzer version and coverage risk.

  • Capture time-on-item and evidence opened, but do not turn them into employee surveillance.
  • Edits preserve original machine rendering and diff.
  • Random duplicate review estimates inter-rater agreement.
INTERVIEWER

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

CANDIDATE

Candidate identity should be stable under wording and line movement, but logic normalization can legitimately change. Before promotion, run old and new toolchains on a representative frozen corpus and build an equivalence map: unchanged, wording-only, evidence-expanded, logic-changed, added, removed. A 30% unexplained churn breaches the gate. Keep both projections queryable, show reviewers impact, and require lead approval. Review decisions transfer only when normalized logic and evidence equivalence pass a deterministic policy; otherwise schedule re-review. Never overwrite the old run.

INTERVIEWER

Security and tenant isolation?

CANDIDATE

Treat source as highly sensitive. Separate estates by tenant in object keys, metadata, search, encryption keys and worker credentials. Processing sandboxes have no outbound network; source never enters general logs. Model rendering receives only the minimal symbolic slice, uses an approved deployment, and is disabled for restricted tenants. Fine-grained roles separate source read, rule review, toolchain administration and export. Every evidence view and bulk export is audited. Signed snapshot manifests and append-only decision history support chain of custody.

  • Prompt injection in comments or literals is data, not instruction.
  • Redact secrets before any external inference.
  • Break-glass reads expire and require reason.
INTERVIEWER

What metrics and rollout prove this works?

CANDIDATE

Operationally: snapshot completeness, parse coverage, unresolved-call reachability, pass latency, task retry, lineage integrity, review queue age and search SLO. Quality: rule precision/recall on a golden corpus, sentence-evidence coverage, provenance open success, inter-rater agreement, reviewer edit distance, candidate churn between toolchains, cluster purity and reproducibility hash match. Roll out one claims domain, hand-label a corpus, run dual extractor versions, open reviewer-only search, then expand languages and systems. Approved downstream export starts only after sampling and reproducibility gates pass.

  • Report false negatives by outcome slice, not only discovered candidates.
  • Quarterly drift checks for the rendering model.
  • Every published batch has a signed quality report.
INTERVIEWER

Trade-offs and traps?

CANDIDATE

A common IR enables correlation but must preserve language-specific opaque detail. More context can improve prose but harms determinism and leakage; bounded symbolic slices are safer. Deduplication reduces review load but merging destroys system-specific evidence. The biggest traps are one-pass prompting, line URLs to mutable source, hiding unsupported constructs, treating readable prose as the canonical rule, and reporting precision only on the easy parsed subset.

INTERVIEWER

Give the recap you would say aloud.

CANDIDATE

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.

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.

InjectionRecovery mechanismTempting wrong answer
01Unsupported opcodeOpaque reachable IR + coverage impactSilent omission
02Include cycleCycle-aware expansion and bounded diagnosticInfinite worker
03Parser regressionGolden corpus + version rollbackOverwrite old run
04Graph explosionProcedure summaries and SCC fixpointPath enumeration
05Model invents ruleEvidence-ID constrained render + verifierProse as truth
06Toolchain churnDifferential migration reportBlind 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/dayChange 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. 01Seal one source domain
  2. 02Hand-label golden corpus
  3. 03Deterministic IR + coverage UI
  4. 04Candidate + provenance reviewer
  5. 05Correlation across two systems
  6. 06Expand estates behind quality gates

Corrections worth memorizing

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

TrapBetter move
One giant LLM promptUse ordered deterministic passes.
Line number as identityPin blob hash plus origin span.
Unknown syntax ignoredExpose opaque reachable nodes.
Dedup means deleteCluster while retaining variants.
Prose is canonicalCanonicalize symbolic predicate/outcome.
Only precisionMeasure 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