Inside ASQS: The Main Features (Part 2)

Part 2 of a three-part series on ASQS. Part 1 covered what ASQS is and what it's for; Part 3 covers the technology stack.
The hard part isn't writing the test
Ask a modern language model to "write a unit test for this function," and it will. The output will look plausible. It may even be good.
It may also import a package you don't have, mock a method that doesn't exist, assert something trivially true, or test behavior the function never promised. A plausible-looking test that doesn't compile — or that passes without checking anything real — is worse than no test, because it creates false confidence and clutter.
So the genuinely hard problem we set out to solve with ASQS isn't generating a test. It's generating one that compiles, passes, and is worth keeping — repeatably, across a large codebase, without a human babysitting each one. And around that, two things enterprises always ask for: control over what the bot is allowed to do, and choice over which AI models touch their code.
This post walks the features that deliver all three. The recurring lesson is the same throughout: the scaffolding around the model is what makes the model useful.
1. Knowing what to test: graph-based gap planning
Before ASQS writes anything, it decides what deserves a test — and in what order.
It does this with a symbol graph: a structured map of your code where the nodes are "symbols" (classes, methods, fields) and the edges are relationships between them (calls, imports, inheritance, and a special "this test covers that source" link). With that graph in hand, ASQS lists candidate gaps — for example, public methods with no detected test — and then ranks and diversifies them.
The ranking uses graph signals such as:
- Inbound centrality — how many other parts of the code depend on a symbol. A method that fifty others call is a higher-value test target than one called once.
- Business-critical modules — areas you've flagged as important get prioritized.
- Test traceability — symbols that already have tests pointing at them get deprioritized, so effort flows to genuinely uncovered code.
The "diversify" step matters too: rather than generating twenty tests for one heavily-used class and ignoring the rest, ASQS spreads attention so a single run improves breadth, not just depth.
This is the first place ASQS differs from "ask an LLM nicely." The model never sees the whole repo and couldn't prioritize it if it did. The graph does that reasoning deterministically, before any tokens are spent.
(High Centrality)"] process["process() - TESTED"] OrderController --> PaymentService PaymentService --> refund PaymentService --> process PaymentServiceTest["PaymentServiceTest.cs (Test Code)"] PaymentServiceTest --> process style refund fill:#7f1d1d,stroke:#ef4444,stroke-width:2px,color:#fff style process fill:#064e3b,stroke:#10b981,stroke-width:2px,color:#fff style PaymentServiceTest fill:#1b365d,stroke:#3b82f6,stroke-width:2px,color:#fff
2. Understanding the code: multi-language structural indexing
The graph doesn't appear by magic. ASQS builds it with language-native indexers — separate tools that genuinely parse each language (a Java parser for Java, Roslyn for C#, a TypeScript-aware parser for JS/TS) rather than treating source as plain text.
Indexing produces three things:
- Symbols — every class, method, and field, with a fully-qualified name, language, file, and line span.
- Typed edges — the relationships (calls, imports, extends/implements, test-to-source), each labeled with its type.
- Chunks with provenance — slices of source code paired with metadata about where they came from: the file path, line range, the symbol they belong to, and a "role" such as
definition,test,route, orfixture.
That last point — provenance — is what makes the later search targeted. When ASQS looks for "a similar test to use as an example," it can filter to chunks whose role is actually test, in the same language, in a relevant module. It searches code, not arbitrary text blobs.
3. Finding the right context: hybrid retrieval and MMR
Here is the single most important idea in the system, and it deserves plain-language definitions first.
- An embedding turns a piece of code into a list of numbers (a vector) such that similar code produces nearby vectors. "Nearby" becomes a measurable distance.
- RAG (Retrieval-Augmented Generation) is the technique of fetching relevant excerpts from your data and putting them in the prompt, so the model answers from your code rather than from its training memory.
- An ANN (approximate nearest neighbor) search finds the closest vectors quickly without comparing against every chunk. ASQS uses an index type called HNSW to do this at scale.
When ASQS prepares to write a test for a method, it embeds a query and asks: which chunks of this codebase are most similar? Pure similarity has two failure modes, and ASQS's design addresses both.
Failure mode one: similarity ignores structure. The most semantically similar snippet might be in an unrelated module. So ASQS uses hybrid retrieval — it combines the vector similarity ranking with structured SQL filters (same repository, same language, the right chunk type, optional module/directory locality). If the strict filters return too little, it widens and re-ranks rather than coming back empty.
Failure mode two: the top results are near-duplicates. The five "most similar" tests might be five copies of the same pattern, wasting prompt space. To fix this, ASQS applies MMR (Maximal Marginal Relevance) — a classic information-retrieval technique that picks results which are relevant and different from each other, maximizing the information per token of context.
HNSW index] Q --> F[Structured SQL filters
repo, language, chunk type, module] V --> P[Candidate chunk pool] F --> P P --> M[MMR re-ranking
relevant AND diverse] M --> C[Final context bundle:
similar tests, dependencies, fixtures] C --> G[Sent to the generator]
Two more refinements sit on top. Retrieval profiles (unit, HTTP API, React/Nest, Playwright end-to-end, full-stack, and so on) tune which relationships and chunk types matter for each kind of gap, with per-profile budgets capping how much context is gathered. And retrieval sufficiency / abstention lets ASQS skip a gap when the signals are too weak — a deliberate choice to write nothing rather than guess badly.
4. Keeping your team's knowledge: existing skills and docs as context
Every team accumulates hard-won knowledge about how it writes tests and documentation — which assertion style it prefers, how it names specs, which fixtures to reuse, what a good docstring looks like here. Increasingly, teams write that knowledge down in agent skill files (the SKILL.md convention under .cursor/skills/ or .agent/skills/ — the same format AI coding tools already read) and in ordinary repository docs: testing guides, conventions, architecture notes.
ASQS reads them. Before generation, a project-intelligence pass discovers your existing skill files and Markdown docs, ranks them by relevance to this run (language, test framework, E2E stack, repository layout), keeps the most relevant, optionally summarizes them, and folds the result into the context for both test and doc generation. If your knowledge lives somewhere non-standard, you can point ASQS at extra file globs.
Why this matters: a model working from generic training writes generically-correct tests. A model that has also been handed your team's own testing playbook and doc style writes tests and docs that match your conventions — the right mocking library, the right spec layout, the right tone. It's the difference between a competent stranger and a teammate who has read the onboarding guide.
This is also how ASQS retains institutional knowledge instead of re-deriving it on every run. When a senior engineer encodes "this is how we test payment flows" in a skill file once, every future run inherits it — and the effect compounds: the more your team writes down, the more consistent the bot's output becomes.
5. A quick win first: making untestable code testable
Some code can't be unit-tested as written — not because the logic is hard, but because of how it's wired. The classic example is a method that constructs its own collaborator: new Storage(connectionString) buried inside the body, or a GetStorage() => new Storage(...) helper. A test has no way to substitute a fake database or a stub service, so the only "test" a model can honestly write is a hollow check that the type exists — exactly the kind of low-value test ASQS rejects (section 7).
The fix is a seam — a term from Michael Feathers' work on legacy code for a place where you can change a program's behavior without editing in that place. When its policy enables it, ASQS runs an optional pre-generation seam pass that recognizes these hard-wired-collaborator patterns and inserts a small, behavior-preserving seam before any test is written:
- C# — an
internalconstructor overload plus aFunc<IStorage>factory field, so a test can inject a fake. - Java — a
Supplier-backed factory hook and a package-visible setter. - TypeScript/JavaScript — an AST-scoped factory and setter on the target class.
Production behavior is unchanged: existing callers use the same public API, and the seam only adds a testability injection point. ASQS then re-indexes so the generator sees the new seam and writes a real, behavioral test against it instead of a hollow one. (A companion autofix adds missing C# project references when a test project can't even see the code under test — another small unblock.)
The payoff is leverage, especially in legacy codebases: a symbol that would otherwise be skipped or saddled with a worthless test becomes genuinely covered. The trade-off is honest — this pass edits production source — so it is opt-in, deliberately narrow, behavior-preserving, fully audited, and lands in the same reviewable pull request as everything else. Teams that would rather the bot never touch source code simply leave it off.
6. Writing it: unit tests, end-to-end tests, and docs
Only now does the LLM enter. For each gap, ASQS assembles a focused bundle — the target method plus its enclosing class, relevant dependency slices, domain models, fixture and configuration paths, and the diverse exemplars from retrieval — and asks the model to produce the artifact. ASQS generates several kinds:
- Unit tests — JUnit 5 for Java, xUnit for C#.
- End-to-end (E2E) tests — full-flow tests that drive the running application, not just a single function. For web apps that means Playwright or Cypress specs; for Java and .NET it means Playwright/Selenium bindings. E2E is a first-class gap type with its own retrieval profile and generation playbook, and you can cap how many E2E gaps a run takes on (separately from unit gaps).
- Per-symbol documentation — docstrings and comments attached to specific methods or classes.
The phrase to hold onto is context-rich. The quality difference between "write a test for this function" and "write a test for this function, here are three real tests from this very codebase, here's the class it lives in, here are its dependencies and the fixtures you'll need" is enormous. The first prompt produces generic guesses; the second produces code that fits your conventions. Everything in sections 1–3 exists to make the second prompt possible.
7. The part that makes it trustworthy: sandbox, repair, and quality gates
This is where ASQS earns the word "reliable."
Generated code is written to disk and then run through a sandbox — an isolated environment (local or in a Docker container) with the right toolchain (Maven/Gradle for Java, .NET for C#, Node for JS/TS, plus a browser stack for E2E). The sandbox actually compiles and runs the test.
If it fails, ASQS doesn't give up and it doesn't ship broken code. It enters a repair loop: the LLM "fixer" receives the actual error output plus the relevant code and proposes a fix, and the sandbox re-runs. This repeats for a small, bounded number of attempts.
sees the real error] --> S Q -->|No, out of attempts| Discard[Discard this artifact] Gate -->|Real, behavioral test| Keep[Keep] Gate -->|Tautological / empty / skipped| Discard
But "it compiles and passes" is not the same as "it's a good test." A test that asserts assertTrue(true), or is annotated to be skipped, or only checks that an object isn't null, will pass — and be worthless. So ASQS adds quality gates: fast checks that reject low-value patterns before and after the sandbox — empty test shells, skipped/disabled tests, tautological assertions, and no-op placeholders.
This three-part defense — compile/run validation, the repair loop, and the quality gates — is the heart of why ASQS's output is reviewable rather than risky. The LLM proposes; the toolchain disposes.
8. Governance: policy as configuration
Generating good tests is necessary but not sufficient for an enterprise. The next question is always: what is the bot allowed to do, and how do we make it follow our rules? This is where ASQS is deliberately opinionated. Almost every aspect of a run is controlled by policy expressed as configuration, so quality standards stop being tribal knowledge and become an enforced, version-controlled artifact.
A policy block governs the whole lifecycle. Here is an illustrative slice:
runner:
gap_concurrency: 6 # how many gaps to work on in parallel (0–16)
policy:
run_hooks:
retrieve:
weights: # how the planner ranks which gaps to fill first
coverage: 1.0
risk: 1.5
churn: 0.5
dependency_max_depth: 2 # how far through the graph to gather context
coverage_gate:
min_delta: 0.0 # don't ship a run that would lower coverage
ship:
commit_message_template: "test(asqs): {{.TaskKind}} for {{.RepoID}}"
gap_hooks:
fixer:
structured_output: true
dependency_signature_only: false
skill_pack:
value: "e2e-v1" # which generation playbook to apply
indexer:
max_gaps: 40 # cap unit/doc gaps per run
max_gaps_e2e: 10 # cap E2E gaps per run
Read top to bottom, that policy controls planning (how gaps are ranked and how many are attempted), generation (which "skill pack" playbook a gap uses), evaluation (a coverage gate that blocks regressions, and how aggressively the fixer works), and shipping (the commit-message format, the branch, and the conditions under which anything ships at all). On the ingress side, webhook policy can refuse to even start on a draft pull request, the wrong base branch, or a PR that already has too many failing tests.
This is what makes high-level organizational rules enforceable rather than aspirational. Policies like:
Every public method must have tests
Every controller must have integration (E2E) tests
Every DTO must be documented
Don't ship if coverage drops
Never touch the release branch directly
…are not slogans in a wiki — they are the planner's weights, the gap caps, the coverage gate, and the ship rules above. Change the policy, change the bot's behavior, with a full record of who changed what.
The trade-off to be honest about: policy is powerful, which means it can be misconfigured. Weights set carelessly can starve real gaps; a gate set too strictly can block every run. ASQS ships sensible defaults precisely so teams can start simple and tighten the policy as they learn what they want enforced.
9. Your models, your rules: first-level support for open-source models
The second enterprise concern is the AI itself. Which model sees our code, and where does that code go? ASQS treats the model as a pluggable, per-step choice rather than a single hard-wired dependency, and features native, first-level support for self-hosted open-source models like Llama and Codestral.
You can assign a different provider and model to each step of the pipeline — test generation, documentation, the repair fixer, even embeddings — independently:
llm:
provider: openai # default for any step not overridden
model: gpt-4o
generation_provider: ollama # draft tests with a local Codestral model
generation_model: codestral:22b
base_url: http://127.0.0.1:8081 # the ASQS Ollama gateway
fixer_provider: ollama # repair failures with a local Llama model
fixer_model: llama3.3:70b
base_url: http://127.0.0.1:8081
doc_provider: ollama # write docs with another local model
doc_model: qwen2.5-coder:14b
base_url: http://127.0.0.1:8081 # nothing leaves your network
Two capabilities here matter most to teams that have hesitated to put an AI bot near their source.
Cost control through specialization. Routing each step to the right-sized model can cut spend substantially. By integrating directly with local open-source endpoints, you get completely cost-free generation loops for drafting and fixing tests, allowing you to run hundreds of iterations on your own hardware without paying a single cent in API fees.
Offline, self-hosted, open-source models for privacy and security. ASQS runs natively against open-source models you host yourself (via tools like Ollama). For a bank, a defense contractor, or anyone under strict data-residency rules, this provides absolute data security: your code, your tests, and the exact context the bot assembles never leave your infrastructure — no third-party APIs, no data egress, no corporate compliance issues. You can even run embeddings locally, making the entire pipeline from indexing to execution fully air-gapped.
The cost of this flexibility is that local open-source models require dedicated local hardware, and teams running fully offline should expect to spend more iterations in the repair loop. The point is that it's your choice to make, not ours.
10. Seeing what happened: agent sessions, the UI, and audit reports
An autonomous system you can't inspect is a system you can't trust. So every run is recorded as a structured agent session, not just a log file, with four levels:
- a run session for the overall lifecycle (indexing → planning → generating → validating → repairing → a terminal state like stable, unstable, or aborted);
- a gap session per selected gap, tracking its generated, fixed, or discarded artifacts;
- attempts, an append-only record of every tool call with input/output summaries, duration, and status;
- feedback, normalized observations from each phase (including security, architecture, and performance findings).
This trace is surfaced in a React web UI (the subject of Part 3). Operators get a runs browser with live-updating status and a streaming log console, an agent-session list, a drill-down view with Gaps, Attempts, and Feedback tabs, and an interactive code-graph explorer for browsing the symbol graph itself.
The UI is also multi-tenant, which is what makes ASQS manageable at organization scale. Work is organized as tenants → projects → runs: one ASQS instance can serve many teams, each tenant owning its own projects, repositories, and pinned configuration. A platform team can operate quality for the entire company from a single deployment, while each team keeps its own policies and its own view — no separate bot per team, no shared-config tangle.
Finally, for the moments when "what did the bot actually do?" needs a real answer, you can download a full audit report for any run. It is a complete, machine-readable record of every step — and crucially, it includes the exact context each step sent to the LLM provider, the prompts, the errors the fixer saw, and the decisions taken along the way. That single artifact serves three audiences at once: an engineer debugging a bad generation, a security or compliance reviewer verifying exactly what data was sent where (especially relevant when weighing cloud vs. local models), and anyone trying to reproduce an issue. Reports can be exported on demand for archival.
11. Small incremental updates: keeping changes reviewable and runs fast
A major friction point in automated code generation is the "dump and run" problem — a bot opening a pull request with 5,000 lines of modified code that no human can realistically review. ASQS prevents this by operating entirely in small incremental updates.
This incremental design applies to the entire lifecycle:
- Incremental indexing: On subsequent runs, ASQS doesn't re-index the entire codebase. It analyzes git deltas and only parses modified or added files, keeping indexing times under a few seconds.
- Incremental gap planning: You can cap the number of gap generations per run (e.g., using `max_gaps`). ASQS then prioritizes the most central gaps, filling them method-by-method in small, reviewable batches.
- Incremental documentation: Rather than rewriting the entire codebase's docs or the repo overview document, ASQS computes narrative diffs and updates them incrementally, preserving any manual modifications.
- Safe shipping and discards: When a run finishes, ASQS pushes to a separate branch and opens a single, clean pull request. If certain tests fail to stabilize in the sandbox, ASQS discards just those failing paths and commits only the stable ones, ensuring your repository stays green.
Three concrete examples
1. A failing test that repairs itself. ASQS generates a test that references OrderRepository.findById but uses the wrong return type, so it won't compile. The sandbox reports the compiler error. The fixer receives that exact error, corrects the type, and the re-run passes. What lands in the PR is a green test — the broken intermediate never leaves the sandbox.
2. A policy that enforces itself. A team sets coverage_gate.min_delta: 0.0 and weights risk above raw coverage. From then on, every run prioritizes the riskiest untested code and refuses to open a PR that would lower coverage — the "don't ship if coverage drops" rule is now mechanical, not a code-review reminder.
3. A privacy-first deployment. A regulated team points generation_provider, fixer_provider, doc_provider, and embedding_provider at a self-hosted model and confirms, via a downloaded audit report, that no run made an external API call. They get autonomous test generation with zero data egress.
Misconceptions and trade-offs
- "The LLM does the work." It writes the text, but planning, retrieval, validation, gating, and policy do most of the engineering. Swap the model and the system still functions; remove the sandbox and it becomes untrustworthy.
- The repair loop has a cost. Each fix attempt is another model call and another build. That's why attempts are capped — there's a real trade-off between persistence and spend/latency.
- End-to-end tests are inherently flakier than unit tests (timing, browsers, environments). ASQS supports them with dedicated profiles and a browser-equipped sandbox, but the closer you get to full-stack E2E, the more variance you should expect.
- Local models trade capability for control. Running fully offline is a genuine option, but expect more repair iterations than with a frontier model.
- Gates and policy reduce noise; they don't eliminate it. A test that compiles, passes, looks reasonable, and quietly asserts the wrong thing can still slip through to human review — which is exactly why human review remains in the loop.
Conclusion and a next step
The headline isn't that ASQS uses an LLM — almost everything does now. It's how much machinery surrounds the LLM to make its output dependable and its behavior governable: a symbol graph to choose targets, hybrid retrieval with MMR (plus your team's own skill files and docs) to assemble the right context, behavior-preserving seams that make untestable code testable, a sandbox-and-repair loop to guarantee the code runs, quality gates to strip out worthless tests, policy-as-configuration to enforce your standards, per-step model choice (including fully local models) to control cost and privacy, and a complete audit trail so humans can verify every decision.
A practical next step, even outside ASQS: write down the quality rules your team wishes it enforced — "every public method tested," "every controller has an E2E test," "don't ship below baseline coverage." Those sentences are exactly the kind of policy a system like ASQS can turn from a wiki page into an enforced default.
Part 3 opens the toolbox: the Go backend, Postgres with pgvector, the LLM provider layer, the polyglot indexers, and the multi-tenant React control plane — and why each technology was chosen.
References and further reading
ASQS is a proprietary system we build and operate. However, we have open-sourced the core engine which covers the core ASQS; you can find the repository at asqs-core. The links below point to the third-party technologies and foundational techniques it builds on.
- Lewis et al., "Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks," NeurIPS 2020. arXiv:2005.11401 — https://arxiv.org/abs/2005.11401
- Carbonell & Goldstein, "The Use of MMR, Diversity-Based Reranking for Reordering Documents and Producing Summaries," SIGIR 1998 — https://doi.org/10.1145/290941.291025
- Malkov & Yashunin, "Efficient and Robust Approximate Nearest Neighbor Search Using Hierarchical Navigable Small World Graphs," IEEE TPAMI 2020. arXiv:1603.09320 — https://arxiv.org/abs/1603.09320
- Michael Feathers, Working Effectively with Legacy Code (Prentice Hall, 2004) — the origin of the "seam" concept used in section 5.
- Ollama (self-hosted open-source models) — https://ollama.com
- Playwright (end-to-end testing) — https://playwright.dev