uttrflow / uttrflow/uttrflow-swift

Comment and word-match audit updates silently accept new violations in previously clean files

Open
#828 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
4
Forks
17
Avg merge
3h 32m
Merged PRs (30d)
277

Description

## Problem

Both `Scripts/comment_audit.py` and `Scripts/loose_match_audit.py` promise that ordinary `--update` refuses a higher per-file count. Their update branches only check files already present in `baseline["files"]`:

```python
if path in recorded and count > recorded[path]
```

Clean files are omitted from that map. Consequently, a new violation in a previously clean or newly added file is not considered a rise. `--update` silently records it without requiring the explicit `--after-merge` override. The subsequent audit passes.

This is particularly broad for the current comment baseline, whose `files` map is empty: no newly introduced multiline comment block is protected by the update-time check.

## Verified reproduction

At main `5c310667cd35c44abd8bbd26c19b0905471287b4`, ran each unchanged script in a separate temporary directory with its current baseline copied unchanged and a synthetic `Sources/Example/New.swift`.

- Comment audit input: two adjacent `//` comment lines and a struct declaration.
- Word-match audit input: `let stem = String(word.prefix(3))`.

For both scripts:

1. Ordinary check exits 1 and reports the new violation.
2. `--update` exits 0 and records the new file with count 1.
3. Ordinary check exits 0 without changing the violating source.

Only temporary baselines were modified. No production baseline was weakened.

## Impact

The documented maintenance command can turn an actual quality regression into a passing baseline. This defeats the promised per-file ratchet during routine baseline refreshes; normal check mode itself does correctly detect the new violation before that refresh.

## Acceptance criteria

- With an existing baseline, treat an absent file as a recorded count of zero when deciding whether a count increased.
- Ordinary `--update` refuses that increase and leaves the baseline unchanged in both scripts.
- Keep first-time initialization and the explicit `--after-merge` behavior intentional and distinguishable from an ordinary refresh.
- Test new files, existing clean files, increases in already-listed files, decreases and the explicit override.

Contributor guide

Open the contributing guide

Research direction

Start with the update branches in Scripts/comment_audit.py and Scripts/loose_match_audit.py, then reproduce the behavior using temporary baselines and Sources/Example/New.swift as described. Add coverage for new and existing clean files, increases, decreases, initialization, and --after-merge; done means ordinary --update rejects increases and leaves the baseline unchanged in both scripts.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, swift
Domain
testing, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.