Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutContactPrivacyTerms
Skip to lesson

Course contents

  • Getting Started with AI for VLSI Engineers5
  • Just Enough AI: Models and Context15
  • Prompting13
  • Trust and Verification14
  • Using AI for Engineering Work17
  • Engineering Walkthroughs7
  • Practical Foundations for AI Workflows4
  • Engineering Data5
  • Retrieval-Augmented Generation6
  • Agents and Tool Use18
  • Agent Design8
  • MCP and Skills6
  • Multi-Agent Design6
  • Practical Capstone6
  • Tokens, Cost and Latency12
  • Agentic Workflows for Chip Teams18
    • Regression Triage Agent
    • Lint-and-Fix Loops
      • Anatomy of the Loop
      • Acceptance Rules and the Test Suite
      • Limits and Failure Modes
      • A Loop Simulator with a Fake Fixer
    • Guardrails and Human in the Loop
    • Evaluating and Operating Agents
  • Interview and Judgment10
  • AI Skills: Full Course Index
  • Working with AI Glossary
  • Working with AI Cheatsheet
Loading lesson

‹Lint-and-Fix Loops
  1. Topics
  2. AI Skills for VLSI Engineers
  3. Agentic Workflows for Chip Teams
  4. Lint-and-Fix Loops
  5. A Loop Simulator with a Fake Fixer

Reference: Agentic Workflows for Chip Teams · Beginner to Intermediate

A Loop Simulator with a Fake Fixer

A small deterministic simulator with a fake fixer, an acceptance rule, and a stop rule.

On this page

    What the simulator models

    The program below stands in for a model with a fake scripted function. It fixes the first open issue each round and plants a bad edit on two rounds.

    Part

    Role in the program

    fake_lint

    Counts open issues in the scratch state.

    fake_tests

    Fails when a bad edit is present.

    fake_fixer

    Scripted stand-in: fixes one issue, plants a bad edit on rounds 1 and 2.

    Acceptance rule

    Keeps a patch only on fewer hits plus green tests.

    Stop rule

    Stops at 5 rounds, at zero hits with green tests, or after 2 stalled rounds.

    The program

    The run starts from 3 open issues and ends with 2 left for a human. Every number in the next section follows from these bounds.

    example.py
    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
    import sys
    
    MAX_ROUNDS = 5
    STALL_LIMIT = 2
    
    state = ["A", "B", "C"]
    rounds = 0
    accepted = 0
    stalled = 0
    history = [len(state)]
    
    def fake_lint(items):
        return list(items)
    
    def fake_tests(items):
        return "BAD" not in items
    
    def fake_fixer(open_issues, round_no):
        # FAKE scripted stand-in for a model: fixes the first open issue,
        # and plants a bad edit on rounds 1 and 2.
        if len(open_issues) == 0:
            return []
        if round_no == 1 or round_no == 2:
            return ["fix:" + open_issues[0], "BAD"]
        return ["fix:" + open_issues[0]]
    
    def apply_patch(items, patch):
        out = list(items)
        for token in patch:
            if token.startswith("fix:"):
                name = token[4:]
                if name in out:
                    out.remove(name)
            elif token not in out:
                out.append(token)
        return out
    
    while rounds < MAX_ROUNDS:
        open_issues = fake_lint(state)
        if len(open_issues) == 0 and fake_tests(state):
            break
        patch = fake_fixer(open_issues, rounds)
        candidate = apply_patch(state, patch)
        if len(fake_lint(candidate)) < len(fake_lint(state)) and fake_tests(candidate):
            state = candidate
            accepted += 1
            stalled = 0
        else:
            stalled += 1
        rounds += 1
        history.append(len(fake_lint(state)))
        if stalled >= STALL_LIMIT:
            break
    
    if rounds != 3:
        print("FAIL: rounds is " + str(rounds) + ", wanted 3")
        sys.exit(1)
    if accepted != 1:
        print("FAIL: accepted is " + str(accepted) + ", wanted 1")
        sys.exit(1)
    if stalled != 2:
        print("FAIL: stalled is " + str(stalled) + ", wanted 2")
        sys.exit(1)
    if state != ["B", "C"]:
        print("FAIL: leftover state is " + str(state))
        sys.exit(1)
    if history != [3, 2, 2, 2]:
        print("FAIL: history is " + str(history))
        sys.exit(1)
    print("PASS: 3 rounds, 1 patch kept, 2 stalled rounds, 2 issues left for a human")

    Reading the result

    Round 0 fixes issue A and the patch is kept, so the count falls from 3 to 2. Rounds 1 and 2 each pair a fix with a bad edit, so the count stays at 2 and both patches are dropped.

    Two consecutive stalled rounds hit the stall limit, so the loop stops after 3 rounds. One patch is kept, 2 issues remain, and the history reads 3, 2, 2, 2.

    Common mistakes

    Common pitfall

    Reading the kept-patch count as success hides the stall. The history 3, 2, 2, 2 shows one gain followed by two flat rounds, which is exactly when to stop.

    Interview

    Likely probes: trace the simulator by hand, and say what each check proves.

    • Round 0 is kept, rounds 1 and 2 are dropped, and the stall limit fires.

    • The state check proves the leftovers are issues B and C.

    • The history check proves the no-improvement stop, not the round budget.

    Check yourself Why is the round 1 patch dropped even though it fixes issue B?

    It also plants a bad edit, so the count does not fall and the suite turns red. Both halves of the acceptance rule fail.

    Check yourself What stops this run: the round budget or the stall limit?

    The stall limit. Only 3 of the 5 allowed rounds run before 2 consecutive stalled rounds stop the loop.

    Related topics

    • Anatomy of the loop

    • Guardrails and human in the loop

    Previous

    151 / 173

    Next: Guardrails and Human in the Loop

    Up next

    Up nextGuardrails and Human in the Loop

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Anatomy of the Loop
    • Acceptance Rules and the Test Suite