Repository navigation
features review model passes
Active contributors: Vassiliy Kuzenkov (also recorded as bondiano), Eduard.
The application schedules bounded model tasks; the pure core defines prompts and validates replies. Assessment answers planned requirements, discovery and audit propose candidates, and verification tries to refute those candidates before they become findings.
The template constants in crates/sych-core/src/analysis/prompts.rs are the current contracts, even where older inline comments mention earlier versions.
| Pass | Template | Route role | Purpose |
|---|---|---|---|
| Standalone assessment | assessment@4 |
Reviewer | One planned obligation, criterion by criterion |
| Combined review | review@7 |
Reviewer | Assessment of fully shown obligations plus discovery |
| Risk audit | risk_audit@7 |
RiskAuditor | Separate search for violations of one HIGH/CRITICAL obligation |
| Discovery | discovery@8 |
Reviewer | Defects, rule violations and optional nits across a packet batch |
| Verification | verify@6 |
Verifier | Confirm, reject or leave each candidate unresolved |
All use the same run router and analysis ledger. Attempts, repairs and recovery share budgets.analysis, not independent per-pass allowances. Provider chains, routing, prices and reservations are documented in Models.
flowchart TD
Planned["Applicable obligations: required first, then risk"] --> Whole{"Discovery batch shows obligation whole?"}
Whole -->|Yes| Combined["Combined review"]
Whole -->|No| Assess["Assessment per verification chunk"]
Combined --> Barrier["Finish assessment stage"]
Assess --> Barrier
Barrier --> Audit["Independent high-risk audits"]
Barrier --> Search["Remaining discovery batches"]
Barrier --> Reviewed["Candidates from combined review"]
Audit --> Answers["Answer context asks"]
Search --> Answers
Reviewed --> Verify["Verify candidates"]
Answers --> Verify
Verify --> Again{"Unresolved and more context?"}
Again -->|Yes, once| Round2["Answer and verify unresolved candidates again"]
Again -->|No| Merge["Merge outcomes and overlapping findings"]
Round2 --> Merge
Engine::run in crates/sych-app/src/analysis/mod.rs schedules only obligations initially UNKNOWN/NOT_ASSESSED. It orders required obligations first, then descending risk, with stable order for ties.
Adjacent discovery packets are batched while their shown bytes fit context.max_tokens_per_request; the primary reviewer profile can further bound shown tokens and packet count through max_shown_tokens_per_call and max_units_per_call. These are packet-based batches, so chunks of one unit can occupy multiple positions.
A batch can assess an obligation in its discovery call only if every fragment of every verification chunk lies inside a shown span of that batch with the same side, path and blob, and no required span was excluded. Combined calls rank by their highest-priority assessed obligation and share one queue with standalone assessments. An obligation split beyond the batch still gets assessments of its own.
An absent or repeated obligation assessment in a combined reply becomes UNKNOWN/MODEL_FAILED with “no single assessment.” A verification packet containing REQUIRED_OVER_BUDGET is recorded as skipped without spending a call; Planning and reduction retains its context-limit UNKNOWN.
Let D be the number of standalone discovery batches and A the configured maximum attempts. When an attempt cap exists, discovery's reserved share is min(D, floor((A - 1) / 2)), with saturating subtraction. Assessment leaves that share plus one verifier attempt when the share is nonzero; audit leaves the share plus one. Standalone discovery leaves one verifier attempt. This gives required assessment priority without allowing many requirements to consume every search attempt.
Independent calls run at most budgets.analysis.max_parallel_calls at once. All assessment-bearing calls finish before the audit/discovery/verification stage. crates/sych-app/src/analysis/parts.rs starts tasks in planned order, frees a slot as soon as a task completes and merges outputs in planned order.
Stable merging is not a claim that concurrency removes nondeterminism: under a tight cap, a later task can reserve budget before an earlier task's repair or next chunk. Atomic ledger reservations still enforce the shared budget. Model replies themselves are nondeterministic.
Discovery sees numbered BASE/HEAD spans, change metadata and the unit's obligations. Its rules prioritize boundary inputs, early-return/error paths, state across calls and non-default configuration. A defect must name a concrete trigger and trace HEAD to the wrong outcome; a premise contradicted by shown code should be dropped.
The prompt targets at most four defects/rule violations, with nits additional and at most three per review unit. The engine's hard safety cap is 20 candidates per reply. Extras are rejected as CANDIDATE_OVERFLOW, producing LIMIT_REACHED and partial coverage.
validate in crates/sych-core/src/analysis/discovery.rs rejects a draft whole if any anchor, evidence ID or obligation ID is invented, if its claim is blank, or if no anchor resolves. It does not delete bad references and pretend the remaining proof was the model's answer. Candidates anchored only in configured review.fixture_paths become rejected drafts, since labelled fixture defects are data, not production findings.
Risk audit uses each HIGH/CRITICAL obligation's verification chunk and does not see discovery output. It still runs when discovery finds nothing. “Independent” means separate input/output flow here, not statistically independent model errors. Audit candidates use the same discovery validation and verifier.
Open questions are trimmed, deduplicated and copied into the result as open question: …. They do not by themselves change execution outcome or coverage. The same selected-list normalization applies to candidate conditions/causal chains, assessment missing inputs/limitations and verdict limitations; it does not rewrite every free-text scalar.
Discovery asks are answered once through typed broker operations before verification; discovery is not called again on those answers. The verifier sees the same source plus answers, accepted rules and candidate text explicitly labelled as unverified DATA. See Evidence and context for search windows, source-side summaries and moved-code metadata.
Before round one, the engine adds:
- Cross-file summaries for names lost by candidates' removed BASE anchors.
- HEAD searches for effects the ledger classifies removed or unresolved in a candidate's file. It uses the target's last name, 3 to 64 bytes, at most four unique searches, registered effects first. A ledger-recognized moved effect needs no such search.
The verifier must return exactly one verdict per candidate. Missing/repeated verdicts become UNRESOLVED and get a history entry with proposed status PENDING.
| Confirmation check | Result when it fails |
|---|---|
| All references resolve and at least one anchor remains | UNRESOLVED |
| Basis is admissible | UNRESOLVED |
| No imported known diagnostic overlaps the anchors without a comparable novelty baseline |
UNRESOLVED/DUPLICATES_EXISTING_DIAGNOSTIC limitation |
HIGH/CRITICAL has STATIC_TRACE and at least two distinct resolved anchors |
UNRESOLVED/HIGH_RISK_WITHOUT_TRACE limitation |
EXECUTED_COUNTEREXAMPLE cannot be asserted by the model because it executes nothing. A preference cannot support a defect or rule violation. Nits/improvements are at most LOW. Rejecting a nit drops it rather than escalating it into a defect.
The source rules additionally ask the verifier to look for wrappers, guards, recovery paths and intentional changes. A deleted guard must be judged with the field/type/function removed alongside it, not from absence of the old name alone. These are reasoning instructions; anchor and support checks enforce admissibility, not semantic truth.
Only unresolved candidates are eligible for round two. If the verifier asked no valid questions, the engine derives HEAD searches from identifiers in backticks in those claims: up to two per candidate and four unique queries overall, using 3-to-64-byte identifier-like strings.
If there are asks and unresolved candidates, the answers are added and the unresolved subset is verified once more. A failed second call keeps first-round verdicts; it still records the failed pass and gap. Further questions from the second reply do not start another loop.
Candidate verdict histories preserve proposed and engine-accepted status, explanation, alternatives checked, resolved anchors/evidence, engine problems and accepted attempt ID. A checkpoint reply has no new attempt ID. This is the trail to inspect when a plausible candidate was rejected or remained unknown.
crates/sych-core/src/analysis/verify.rs creates findings only from admissibly confirmed verdicts. Each carries the limitation “CONFIRMED by the verification policy on the shown spans; not a proof of the whole program.”
Overlapping confirmed findings are reported once, most severe first. The absorbed claim is retained in also with its category, severity, explanation, trigger, consequence and anchors; linked obligation/evidence IDs join the kept finding. Its fingerprint and ID remain the kept finding's, preventing duplicate publication for the same lines without losing the other claim.
An optional suggestion must resolve to lines of a shown HEAD span. A bad suggestion is dropped with a limitation, not used to discard an otherwise valid finding. Accepting a suggestion's location is not proving its replacement correct. GitHub rendering/publication belongs to Server.
crates/sych-app/src/analysis/redo.rs distinguishes recoverable batch shape/provider refusals from final failures:
| Situation | Engine recovery |
|---|---|
| Multi-packet review/discovery truncated or timed out | Record attempts as SPLIT; reassess a combined review's obligations separately and return its packets to discovery; cut discoveries are searched in halves down to single packets |
| Combined review refused by rate limit, transient error or no eligible route | Keep attempts as SPLIT; separately assess its obligations and send its units through discovery |
| General discovery refused | Once other searches finish, retry once after the shortest route cooldown if before the run deadline |
| Discovery denied input tokens while a sibling holds reservations | Retry sequentially once after the sibling stage settles |
| Final budget, quota/output limit, provider or schema failure | Record FAILED plus an explicit gap |
Recovered attempts still count. The first recoverable failure's unfinished assessments and gaps are not retained as permanent failure when the work succeeds later. These recovery paths do not grant new budgets.
Final limit/quota failures produce LIMIT_REACHED; other final failed passes produce RETRIES_EXHAUSTED, with partial coverage. Assessment failure keeps an actionable UNKNOWN such as BUDGET_EXHAUSTED, MODEL_FAILED or MODEL_QUOTA_EXHAUSTED. The reducer can consolidate one shared quota message without erasing individual obligation statuses.
crates/sych-app/src/analysis/replay.rs rebuilds a frozen discovery's original packet batch or audited-obligation context, reanswers its asks and reruns only verification. It resets candidate status/history. No new discovery or assessment runs, so replay's candidate/finding comparison is meaningful; its unassessed obligation statuses are not a quality result. Older frozen records without packet indices cannot be reconstructed and are skipped.
Normal successor runs can load parent checkpoints through crates/sych-app/src/review/checkpoints.rs. Eligibility belongs to the model checkpoint contract; the review records reused_from. An unreadable parent checkpoint store means fresh calls, not a failed review. See Models for content-keyed reuse.
| Source | Change here for |
|---|---|
crates/sych-core/src/analysis/prompts.rs |
Versioned templates and role instructions |
crates/sych-core/src/analysis/discovery.rs |
Candidate/ask contracts, fixture filtering and automatic refuting searches |
crates/sych-core/src/analysis/assess.rs |
Criterion and assessment validation |
crates/sych-core/src/analysis/verify.rs |
Verdict admissibility, history, merging and suggestions |
crates/sych-core/src/analysis/mod.rs |
Selected free-text list normalization |
crates/sych-app/src/analysis/mod.rs |
Stage order, batch construction and combined-call eligibility |
crates/sych-app/src/analysis/parts.rs |
Bounded concurrency and deterministic result merging |
crates/sych-app/src/analysis/passes.rs |
Calls, answered asks, pass records and verifier rounds |
crates/sych-app/src/analysis/redo.rs |
Split/refusal/reservation recovery |
crates/sych-app/src/analysis/replay.rs |
Frozen-candidate verifier comparisons |
Use crates/sych-app/tests/analysis.rs, crates/sych-app/tests/analysis_budget.rs and crates/sych-app/tests/batching.rs for scheduling/failure regressions; crates/sych-app/tests/engine_merges.rs for cross-chunk audits and overlapping findings; and crates/sych-app/tests/replay.rs plus crates/sych-app/tests/checkpoints.rs for reuse boundaries. Pure validator tests live in crates/sych-core/tests/analysis/main.rs and crates/sych-core/tests/analysis/verify.rs.
Domain measurements and author-count rules are in Review analysis. Preserve the source trust and validation conventions in Patterns and conventions when changing any pass.