Nestack Agent Care
Industries / Engineering / R&D / Refactoring agent

Engineering AI agent · Tech debt

Tech-Debt Refactoring AI Agent

Enumerate the behaviours a restructure is promising not to change, test the change against that written list rather than a specification nobody wrote, and hold it for the reviewer who takes it.

4–6 weeksTypical delivery
Your stackDeployment
Behaviour firstNamed reviewer
Agent CareAfter launch

What this agent does

Restructures the code, not the claim that nothing moved

In
01

A module is restructured, and the behaviours it promises to hold are written down before a line moves.

02

A function moves in the sequence, and SEC Release 34-70694 para 14 is why its dead callers are retested.

Reason
03

A path with no callers is raised with a proposed category — dead, deactivated or extraneous — not deleted.

04

A bug is found mid-restructure, and whether it was buggy does not matter, so it is raised separately.

05

A behaviour is observable and never promised, and it goes on the list, because the edge is found by breaking it.

Decide
06

A transformation runs, and the engine that performed it is named, because engines ship bugs of their own.

07

A run touches many files at once, and FDA asks whether that is a significant software re-write.

Out
08

A behaviour resists enumeration, and that is recorded as a limit of the check rather than as a pass.

09

Execute write actions only inside the approval boundaries agreed during implementation.

Product statement

Enumeration, restructuring and testing belong to the agent. Taking the change belongs to a named reviewer, who merges it and answers for what moved.

Example workflow

One restructure, module to merge

AgentHuman
1Module and history receivedRepository, call graph, runtime traces, test suite and the change history behind the module
2Preserved behaviours enumeratedThe observables the module shows now, its callers, the paths believed unreachable and what no test asserts
3Restructure draftedThe diff, the enumerated list, what the check could not cover and confidence
4Controls appliedPreservation replay, scope measurement, unused-code categorisation and confidence threshold
No human action required

Stages 1 to 4 run unaided, and nothing is merged at any of them — the agent is restructuring, and the reviewer lane opens at the confidence gate.

5DecisionBranches at the confidence threshold
High confidence

Goes to the named reviewer to merge.

Low confidence

Adds a codebase-owner read first.

Reviewer acceptance

The change is held with its enumerated list, what went unchecked and the confidence.

Merge · Amend · Send to owner review
Taken — merged by the reviewer
6Repository and tracker updatedOnly where write access and change policy allow it
7Outcome evaluatedAmendment rate, preservation outcomes, defects after merge and what review found
Amendments

Each reviewer amendment is counted in the evaluation.

What should not run autonomously

Human approval stays in control

Outside the boundary — human approval required8 items
Merging a restructure into the mainline.
Declaring unused code safe to delete.
Classifying the scope of a change under a regime.
Signing the design-control record for a change.
Automation boundaryAgent acts unaided
Enumerate the behaviours the change must preserve.
Replay each enumerated behaviour on both sides and diff the results.
Run the transformation through a tested engine wherever one exists.
Hold the change and its gaps for the named reviewer.
Nothing is merged except by a named reviewer, inside the boundaries agreed at implementation.
Correcting a behaviour found while restructuring.
Changing an interface another team already reads.
Deciding what counts as observable at all.
Changes to restructuring rules or approval thresholds.

Example output

One restructure, annotated

This serves teams whose diffs say no functional change against a definition that names observable behaviour and no observer; below is one restructure exactly as the agent leaves it.

Refactoring output · single moduleIllustrative example
Module
Behaviour at issue
Checked against
Evidence of record
Confidence
Held for
Order-routing module
A caller on a path with no live route was not replayed
The enumerated list
Production traces
81%
The named reviewer, by name
As receivedTaken from the module as it runs and the traces behind it — nothing here is assumed preserved.
What the record holds Production traces Caller inventory Unused-path register
Why this is heldThe reachable callers pass; one sits on a path nothing exercises.
ActionMergeAmendSend to owner review
What the score decidesBelow the configured threshold a change picks up an owner read before the reviewer sees it.

Value

Where AI adds value

The same four claims, placed at the point in the workflow where each one applies.

Where the value landsValue 01 – 04
Each restructureFrom the module it touches
03Restructuring

Enumerate before you change

Fowler defines the promise over observable behaviour and names no observer; Opdyke fixes it to the inputs and outputs of main, and concedes some preconditions are undecidable.

01Approved path

It promised nothing changed

MDCG 2020-3, on the Article 120 transitional regime for legacy devices, gives the bug fix a safe harbour and withholds one from the restructure.

02Human review

What was searched for, and not found

No regulator found here defines technical debt. Nothing requires code to be maintainable, forbids duplication or sets a complexity limit, and no rule found requires a restructure to be tested — the protocol Knight was faulted for lacking was constructed after the loss.

04Build an evidence trail

The restructure, the behaviour it preserved and the reviewer who took it stay together.

Integrations

Typical integrations

Five system groups connect to the same agent. Which of them are in scope is decided in discovery.

Repositories and forgesGitHub · GitLab · Bitbucket
Azure DevOps · Gerrit · Perforce
Refactoring enginesEclipse JDT · IntelliJ IDEA
NetBeans · OpenRewrite · Rope
Code quality and analysisSonarQube · CodeScene · Semgrep
CodeQL · coverage and mutation tools

Agent

Tech-debt refactoring

Reads the module
Drafts the restructure
Holds for the reviewer

Trackers and change recordsJira · Linear · Azure Boards
ServiceNow · Polarion · Jama Connect
Observability & evaluationOpenTelemetry · Langfuse
Supported monitoring/evaluation sources

Integration availability depends on the client's existing systems and API access.

Agent controls

Six clamps between the model and the mainline

Six clamps around one beam, the last the tightest. What holds is set out in the map below.

L6 · Outermost — last line of defenceInward → L1 · closest to the model
L6Rollback / safe modeNarrow the agent to enumeration and reporting when evaluation or production signals degrade.Roll back
L5Version monitoringTrack model, prompt, transformation-rule and engine-version changes.Track
L4TraceabilityRecord the enumerated list, the diff, what went unchecked and the merge time.Record
L3Reviewer acceptanceHold the change for the named reviewer; the hold governs the merge, not whether behaviour held.Gate
L2Change guardrailsTest each change against its enumerated list; a difference left unexplained returns it.Restrict
L1Confidence thresholdsRoute low-confidence changes to a codebase-owner read before the reviewer sees them.Require review
Model coreRestructure drafted — the diff, the enumerated list, what went unchecked and confidence
L1 – L2Test whether a change may stand
L3Leaves the merge to a named reviewer
L4 – L5Keep the restructure and the baseline behind it
L6Leaves the structure alone when signals degrade

How Nestack evaluates it

Evaluate the whole restructure — not only the diff that comes out of it.

Coverage runs the whole depth of the workflow, and every layer is cut by slice.

Surface — the code the mainline now carries
Depth of coverage ▼
E1Final-output evaluationDid the change hold the behaviours its own list named?
E2Step-level evaluationDid the agent read the live module, its callers and the traces behind them?
E3Tool evaluationDid it read and write the correct module and the correct paths?
E4Confidence calibrationDo low-confidence changes actually attract more reviewer amendments?
E5Slice evaluationHow does performance change across specific module classes?
E6Business outcomeHow many changes needed an amendment before the reviewer merged?
Floor — the behaviour the module actually had

Failure modes

Where each failure originates in the agent

Seven failure modes, each placed where the restructure first shows it.

Agent lifecycleDirection of processing →
01 · Retrieval1 mode
RZ-03

Caller inventory incomplete

A dependent nobody knew about is missed.

Stage gathersThe module, its callers, the traces and the suite
02 · Reasoning2 modes
RZ-04

Corrected while restructuring

A bug is fixed inside a no-change diff.

RZ-06

Unused code called dead

A path is deleted without being categorised.

Stage proposesThe diff, the list and what went unchecked
03 · Tool / write2 modes
RZ-02

Merged without a person

Agent completes a merge that needed a reviewer.

RZ-05

Engine transformation wrong

A tested engine returns an altered program.

Stage writesOnly where write access and approval policy allow it
04 · Output1 mode
RZ-01

Merged, list unrecorded

The record shows a merge but not what was checked.

Stage returnsThe code the mainline carries into tomorrow
05 · Change / Version1 mode
RZ-07

Silent scope creep

Small changes accumulate into a re-write.

Stage tracksModel, prompt, rewrite rules and engine versions
Sev-1 · a merge made outside the boundary Sev-2 · a preserved behaviour moved anyway Sev-3 · coverage drops, change goes to review

Affected slices

Unreachable paths absorb the amendments

A module-level preservation figure can read clean while paths believed unreachable carry most of the amendments. Nestack reports the reviewer-amendment rate by module class, not only in total.

Slice performance — reported separately, not only in aggregateIllustrative example
SliceFailure rateLift Lift vs. thresholdStatus
Paths believed unreachable6.1%3.7× Review
Interfaces other teams read4.3%2.6× Review
Timing-sensitive code2.7%1.6× Watch
Well-covered internal modules1.3%0.8× Normal
Bar: reviewer-amendment-rate lift vs. well-covered-module baseline · scale 0–4.0× · tick marks the 2.0× review threshold 2 of 4 slices over threshold

Evidence-linked improvement

What a no-change diff costs later

A cycle shuts when the path nobody could reach is a regression case. That suite is what the next restructure taken is measured against.

Improvement cycle · five stagesSwitchback — the path turns at Improve and returns at Learn
01Detect

Amendment rate rises in one module class.

02Diagnose

The diff that says no functional change, over behaviour nobody has ever written down, is worked backwards until one cause is left standing.

03Improve

Numbered the change ships, and the restructures behind it travel attached.

04Verify

Each touched behaviour case is run again, and one red holds it back.

05Learn

The case is kept, and the restructuring rules change in that same commit.

Learn → DetectThe return edge. The next restructure taken is measured against a suite one case longer.

Typical build scope

Twelve workstreams across six weeks

The build scope read against the delivery timeline. Week structure follows the six-week plan — discovery, sources, refactoring workflow, evaluation, integration, then production validation and handover.

Workstream Week 1Week 2Week 3Week 4Week 5Week 6
01Refactoring discovery and automation-boundary scope.
02Repository and engine assessment.
03Preserved-behaviour and unused-code categorisation.
04Module ingestion.
05Enumeration and preservation logic.
06Confidence scoring and review routing.
07Reviewer acceptance workflow.
08Repository and engine integration.
09Preservation and scope cases.
10Guardrails and transformation controls.
11Restructure-trail instrumentation.
12Deployment, documentation and Agent Care handover.
12 workstreams · 6 weeks · bar shows the weeks a workstream is active — several run in parallel Final scope and sequence confirmed in discovery

Engagement tiers

What each tier includes

Rows are the capabilities named in each tier's scope. Higher tiers include everything below them.

Capability✓ in scope · — not at this tier PilotOne module, one cycle ProductionProduction repository AdvancedMultiple repositories / teams
Introduced at Pilot
Restructuring to your rules
Named reviewer acceptance
Observable-behaviour baseline
Introduced at Production
Reporting by module class
Acceptance workflow in your systems
Approved write-back
Engine-and-forge integration
Introduced at Advanced
Multi-language transformation rules
Multi-stage change approvals
Large codebases
Multi-module transformation controls
Build price From $5,000 From $8,000 Custom quote
Final build priceConfirmed after discovery based on integrations, workflow complexity, codebase size, approval controls and deployment requirements.
Separate from buildBuild pricing is separate from recurring Agent Care, which covers managed monitoring, evaluations, incidents and verified improvements after launch.

What we need from you

What you bring, and what we build with it

Each input maps to a piece of build scope and a week in the delivery timeline.

You bringWe build with it
01Your modules and what each one still does Behaviour enumeration and list versioningWeek 1
02Representative production traces and callers Enumeration baseline, engine binding and the preservation suiteWeek 2
03Your change-classification and merge policy Preserved-behaviour and unused-code categorisationWeek 1
04Access to relevant repositories, engines or exports Repository and engine assessment, then integration setupWeek 2
05Restructures you would not want inspected Preservation cases and the evaluation roundWeek 4
06What no restructure may remove Confidence scoring, review routing, guardrails and acceptance controlsWeek 3
07A named reviewer to take the changes Reviewer acceptance workflow, then pilot and production validationWeeks 5–6
Nothing else is required Deployment, documentation and Agent Care handover are ours.

Delivery timeline

Four phases across six weeks

Each phase gets exactly the width it costs, so week five shows two bands where one would look neater.

Phase W1W2W3W4W5W6
Discovery W1
Build W2 – W3
Evaluate W4 – W5
Pilot & Launch W5 – W6
Week focus W1Refactoring workflow discovery, behaviour enumeration and the automation boundary W2Repository and engine integration and the enumeration baseline W3Restructuring workflow, confidence logic and acceptance controls W4Evaluation suite, preservation cases and failure-mode testing W5Repository integration, pilot modules and targeted corrections W6One engineering cycle run under the codebase owner, then Agent Care handover
Reading the bandA bar spans the weeks its own work is named in, and the week five overlap is real.
At the end of W6Once the behaviour record validates, Agent Care picks the agent up.
DurationSix-week plan shown · typical delivery 4–6 weeks depending on scope confirmed in discovery.

Next step · Engineering AI agent

Build a refactoring agent around the behaviour your last no-change diff never listed.

Show us one module you keep meaning to clean up and who merges it. What the last restructure did not enumerate was the caller on a path nobody could reach and the ordering somebody relied on. A migration declares that things will change; this declares that nothing will.

Nestack Agents · Tech-debt refactoringAGT-ENG-12 · Agent Care available after launch