Skip to content

Commit 98a0439

Browse files
committed
fix(review): Codex R18 review follow-ups — G2 audit guardrail + G6 copy
Independent code review by Codex (2026-07-21) surfaced two issues in the R18 fixes: 1. G2 guardrail bug — `tierForced` was only set to `true` when the forced tier value happened to DIFFER from the classifier's decision. So `altimate-code review --force-tier=full` on a PR the classifier would naturally rate `full` still runs the debug bypass (silently exercises the flag path in orchestrate.ts) but emits an envelope with no `tierForced`, no `tierClassified`, and no "forced via" reason — breaking the audit-trail invariant we documented in the R18 commit. Fix: `tierForced = input.forceTier !== undefined`. Whenever the caller passed the flag, the envelope now records the bypass regardless of whether the forced value matched the natural one. The leading reason string now also names the forced value. Verified on js4 (naturally `full`): `--force-tier=full` now produces `tierForced: true, tierClassified: "full", tierReasons: ["forced via --force-tier=full (classifier said full)", ...]`. 2. G6 cosmetic copy issue — the schema.yml test-removal detector's body claimed "Removing a `unique` test on a mart-layer key is how silent duplicate rows ship" for EVERY unique-test removal, even when the schema.yml lives outside a mart layer (e.g. js2's `models/schema.yml` sits at the top level, not under `models/marts/`). Fix: detect the layer from the file path (`marts?` or `reporting` → "mart-layer"; otherwise "declared") and interpolate that into the body. The finding is still accurate for genuine mart-layer removals; the copy no longer misattributes for staging or top-level schema files. Neither change alters what findings are surfaced, only the audit envelope shape (G2) and finding body prose (G6). No test-file changes; smoke tests on js2 + js4 confirm both.
1 parent e68d785 commit 98a0439

2 files changed

Lines changed: 19 additions & 7 deletions

File tree

‎packages/opencode/src/altimate/review/dbt-patterns.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,11 @@ export function detectSchemaYmlPatterns(file: ChangedFile, rubric: Rubric): Find
910910
// Uniqueness OR not_null on an id/key column = warning (silent-dup / null-PK
911911
// risk); other not_null / relationships removals = suggestion.
912912
const sev: Severity = isUniquenessSignal || notNullOnLikelyPK ? "warning" : "suggestion"
913+
// Detect layer from file path so the finding body doesn't misattribute
914+
// (Codex-R18-review noted the previous copy said "mart-layer key" on
915+
// every unique removal regardless of the schema.yml's actual layer).
916+
const isMartLayer = /(^|\/)(marts?|reporting)\//.test(file.path)
917+
const layerLabel = isMartLayer ? "mart-layer" : "declared"
913918
const key = `${r.model}.${r.column}`
914919
const isFirstForModel = !seenModel.has(r.model)
915920
seenModel.add(r.model)
@@ -921,7 +926,7 @@ export function detectSchemaYmlPatterns(file: ChangedFile, rubric: Rubric): Find
921926
body:
922927
`The \`${r.test}\` data test was removed from column \`${r.column}\` on model \`${r.model}\`. ` +
923928
(isUniquenessSignal
924-
? `Removing a \`unique\` test on a mart-layer key is how silent duplicate rows ship — ` +
929+
? `Removing a \`unique\` test on a ${layerLabel} key is how silent duplicate rows ship — ` +
925930
`downstream joins fan out, aggregates double-count, and no test catches it. Restore ` +
926931
`the test, or explicitly document why the grain no longer needs to be unique on this column.`
927932
: notNullOnLikelyPK

‎packages/opencode/src/altimate/review/orchestrate.ts‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,14 +1101,21 @@ export async function runReview(input: OrchestrateInput): Promise<VerdictEnvelop
11011101
isComplexOf: (f) => ctxByPath.get(f.path)?.complex ?? false,
11021102
})
11031103
const classifiedTier = tierResult.tier
1104-
// G2 — --force-tier overrides the classifier. Envelope records both the forced
1105-
// tier and the original classification so audits can see the bypass; the
1106-
// reasons list gets a leading "forced" marker so downstream doesn't confuse
1107-
// the forced tier for a natural one.
1104+
// G2 — --force-tier overrides the classifier. Envelope records both the
1105+
// forced tier and the original classification whenever the flag is passed
1106+
// (regardless of whether the forced value happens to match the classifier),
1107+
// so audits can see the bypass every time the flag was used. The reasons
1108+
// list gets a leading "forced" marker so downstream doesn't confuse the
1109+
// forced tier for a natural one. Codex-R18-review fix — the earlier
1110+
// `!== classifiedTier` gate silently hid the bypass when the forced tier
1111+
// matched the classifier's result.
11081112
const tier = input.forceTier ?? classifiedTier
1109-
const tierForced = input.forceTier !== undefined && input.forceTier !== classifiedTier
1113+
const tierForced = input.forceTier !== undefined
11101114
const tierReasons = tierForced
1111-
? [`forced via --force-tier (classifier said ${classifiedTier})`, ...tierResult.reasons]
1115+
? [
1116+
`forced via --force-tier=${input.forceTier} (classifier said ${classifiedTier})`,
1117+
...tierResult.reasons,
1118+
]
11121119
: tierResult.reasons
11131120

11141121
const lanes = new Set(input.config.reviewers.length ? input.config.reviewers : TIER_LANES[tier])

0 commit comments

Comments
 (0)