Skip to content

Fix: Keep kept-link schemes and tighten oracles - #125

Merged
ModeSevenIndustrialSolutions merged 4 commits into
lfreleng-actions:mainfrom
lfreleng-bot-forks:code-monkey/issue-123
Nov 23, 2026
Merged

ModeSevenIndustrialSolutions merged 4 commits into
lfreleng-actions:mainfrom
lfreleng-bot-forks:code-monkey/issue-123

Conversation

@lf-releng-code-monkey-bot

@lf-releng-code-monkey-bot lf-releng-code-monkey-bot Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Closes #123

Authored by an AI agent; human review required
Command Exit
uv run python -B -m unittest discover -s tests (at 16908dd, c79e4c6, f00d848, db26ee4) 0
uv pip install atheris 0
uv run --no-sync python fuzz/fuzz_verdict.py -max_total_time=60 0
uv run --no-sync python fuzz/fuzz_comment.py -max_total_time=60 0
uv run python -B -m unittest discover -s tests 0
uvx --from gitlint-core gitlint --commits 3c9f13f..HEAD 0
prek run --files docs/DESIGN.md fuzz/fuzz_comment.py fuzz/fuzz_verdict.py fuzz/github_markdown.py fuzz/sanitised_text.py scripts/review_policy.py tests/test_comment_review.py tests/test_fuzz_harnesses 0

The github-code-monkey-bot workflow opened this pull request.
Nobody has merged it; a maintainer must review it first.
Review findings on this pull request are answered by a later revision round of this workflow, up to ten rounds per antagonistic review round; after that a maintainer, or the next antagonistic review, takes on any finding that remains, and a maintainer reviews every round before merge.

Round 4 of revision, on its base.


Fixes #123: the six findings Copilot left on #112, plus the review rounds on this pull request.

What it does

  • contain_links (scripts/review_policy.py) no longer breaks a scheme inside an organisation URL it keeps. A kept link reaches to the next backtick, and only when no ASCII letter comes before it. A standalone ftp://, http:// or https:// URL is still broken. docs/DESIGN.md records the rule.
  • The link oracles (fuzz/github_markdown.py) check that each kept link reads as the source wrote it. They look at links kept in the result and links containment always keeps in the source. A zero-width space anywhere inside a scheme counts as an alteration.
  • fuzz/sanitised_text.py now accepts colon marks only inside source :: pairs. An uncut text must fit the limit, and a short cut is allowed only where rstrip took a space.
  • fuzz/fuzz_comment.py does not count & or outer whitespace as growth. written_code reads each line once, so it stays linear.

This round (4)

  • SCHEME_MARK keeps marks between any characters of a scheme, so f​tp:// inside a kept link is caught.
  • always_kept checks a source link after an earlier dot segment, and the bare root https://github.com/<org> followed only by trailing punctuation.
  • written_code finds each opener's closer from a single backward pass. A long closing line is no longer rescanned for every opener.

Every new negative control fails against the previous oracle, and each nearby input that containment breaks still passes.

What I ran

  • uv run python -B -m unittest discover -s tests at every commit: exit 0.
  • prek run --files <changed files> (aislop included): exit 0.
  • gitlint --commits 3c9f13f..HEAD: exit 0.
  • Atheris, 60 s per harness from the seeds: fuzz_verdict.py ran 71,942 inputs and fuzz_comment.py ran 9,219, with no failures.
  • Random cross-checks: 300k inputs of altered_links against contain_links found no false alarms. 300k inputs compared the new written_code with the old scan and found no difference.

For the reviewer

always_kept mirrors contain_run's rule, using the oracle's looser dot-segment pattern. When the two disagree, the oracle skips a link rather than flagging it. Nothing under .github/workflows/ changes.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A critical containment bypass leaves a trailing external autolink live, and fuzz oracles miss that regression while also accepting altered queries and invalid exact-limit truncation.

3 open issues
What changed in this PR

This PR addresses #123 by preserving schemes embedded in allowed organisation URLs and tightening the fuzz checks that validate sanitisation and comment rendering.

Changes:

  • Preserve embedded schemes within kept organisation links and document the rule.
  • Tighten checks for truncation, colon-pair spacing, link preservation, and code-block retention.
  • Add regression cases, wrong-result tests, and fuzz seeds for the reported failures.
File Description
tests/​test_review_policy.py Tests embedded schemes and standalone URL containment.
tests/​test_fuzz_harnesses.py Adds negative controls and boundary cases for the oracles.
tests/​test_comment_review.py Updates expectations for truncating a kept URL run.
scripts/​review_policy.py Preserves later schemes within a kept URL run.
fuzz/​sanitised_text.py Tightens colon-spacing and truncation checks.
fuzz/​github_markdown.py Models embedded schemes and detects altered kept links.
fuzz/​fuzz_verdict.py Adds link-preservation checks and stricter length validation.
fuzz/​fuzz_comment.py Refines code-retention bounds and checks kept links.
docs/​DESIGN.md Documents preservation of schemes inside allowed URLs.

Review effort: Balanced

Comment thread scripts/review_policy.py Resolved
Comment thread fuzz/github_markdown.py Resolved
Comment thread fuzz/sanitised_text.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The preservation check misses allowed links that stop autolinking, so both harnesses accept a broken outer URL and altered query; source-based checks and negative controls are needed.

1 open issue

Review effort: Balanced

Comment thread fuzz/github_markdown.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The truncation verifier can incorrectly accept a missing zero-width-space mark, and repeated scanning of long whitespace suffixes can substantially slow comment fuzzing.

2 open issues

Review effort: Balanced

Comment thread fuzz/fuzz_comment.py Resolved
Comment thread fuzz/sanitised_text.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved findings show that whitespace-heavy suffixes can still stall fuzzing and both link oracles can accept incorrectly altered URLs.

3 open issues

Review effort: Balanced

Comment thread fuzz/fuzz_comment.py Resolved
Comment thread fuzz/github_markdown.py Resolved
Comment thread fuzz/github_markdown.py Resolved
lf-releng-code-monkey-bot Bot and others added 4 commits November 23, 2026 14:59
Add tests for six wrong results the issue reports: a scheme inside a
kept organisation link broken by contain_links, and fuzz oracles that
accept a colon mark outside a "::" pair, an uncut text over the limit,
a cut text that fits it, "&amp;" growth beside code and outer
whitespace counted against the comment limit. Each is marked as an
expected failure until the fix that makes it pass.

Two existing tests change: one relied on the loose cut oracle
accepting a cut that sanitise never makes, and one asserted that a
scheme inside a single run of organisation URLs breaks. Both pass
before and after the fixes.

Review round: Copilot reported three more wrong results, now tested
here too. The kept-link test adds a scheme after a backtick and after
an ASCII letter, which GitHub links on its own; the contained oracle
test adds those and a scheme left whole behind two ZWSPs; the cut
test adds an exact-limit text whose cut eats its last mark.

Round two: Copilot found the oracle blind to a kept link that loses
its own scheme, as it then links nowhere in the result. The contained
oracle test now breaks the outer scheme of a kept link, alone and
with the inner one, through both harnesses, and checks that links
containment may break (a dot segment, no slash after the
organisation, a letter before the scheme) still pass.

Round three: Copilot found a cut one short of the limit accepted
when the source's space came right after a "@" or "<", though
sanitise keeps the zero-width space due there. The cut test now
checks that boundary and the inputs either side of it.

Round four: Copilot found the oracle blind to a mark between two
characters of a scheme inside a kept link, and to two links
containment keeps that the source-side check skipped: one after a
dot segment earlier in the run, and a bare organisation root. The
contained oracle test now breaks each, through both harnesses, and
checks that a dot segment after the scheme, or a quote or a backtick
after the root, still lets containment break the link.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: lf-releng-code-monkey-bot[bot] <332050256+lf-releng-code-monkey-bot[bot]@users.noreply.github.com>
contain_links broke every scheme in a run, so a scheme inside an
organisation URL it keeps, as in search?q=ftp://server, gained a
zero-width space and the link no longer read as written. GitHub links
the whole run to the next whitespace, so once a scheme stays, every
later scheme in the same run is part of that link and stays too.

Both fuzz harnesses now check that each link contain_links keeps reads
as the source wrote it, and seed the reported input. DESIGN.md records
the rule.

Review round, two Copilot findings on this change:

- contain_run kept every later scheme in a run once a kept link began,
  so a scheme after a backtick, which may close a code span, or after
  an ASCII letter, which GitHub links on its own, stayed live. A kept
  link now reaches only to the next backtick, and only when no ASCII
  letter precedes it (LINKED_RE). The autolinks oracle gives each
  kept link the same reach, and altered_links checks the schemes
  inside it against the written text, so the oracle no longer hides
  such a scheme.
- SCHEME_MARK removed one ZWSP only, so a scheme behind two ZWSPs in
  the result passed as unaltered. It now removes a run of them.

Round two, one Copilot finding: altered_links read kept links from
the result alone, so breaking a kept link's own scheme, with or
without the scheme inside it, left no link to check and both
harnesses passed. It now also reads them from the source: a link
there naming https://github.com/<org>/ in a run with no dot segment,
which contain_links always keeps, must read as written in the result.

Round four, two Copilot findings:

- SCHEME_MARK kept a mark only after a scheme's colon, so one between
  "f" and "tp" in a kept link's query passed. It now keeps marks
  between any two characters of a scheme, "://" included.
- The source-side check skipped a whole run holding a dot segment,
  though containment ignores one before a URL's scheme, and wanted a
  slash after the organisation, though containment keeps a root with
  only trailing punctuation after it. always_kept now looks for a dot
  segment from the scheme on, and accepts that root.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: lf-releng-code-monkey-bot[bot] <332050256+lf-releng-code-monkey-bot[bot]@users.noreply.github.com>
The verdict harness accepted three wrong results from sanitise. A
colon mark passed wherever a colon came next, not only inside a "::"
pair the source wrote. A match uncut passed at any length, even past
the limit. A prefix one short of the limit passed as a cut even where
rstrip had taken no space. one_line also let any text run three
characters past the limit, cut or not.

The oracle now allows a colon mark only inside a source "::" pair,
holds an uncut text to the limit, and takes a short cut only where
rstrip took the source's space or a mark's. one_line allows the extra
three characters only to a cut ending in "...". A seed carries the
reported run of colons.

Review round, one Copilot finding on this change: at the exact limit
verify_text asked zwsp_due whether a mark was still owed, but a cut
whose kept text already ends on that mark owes none, so a whole
600-character text with "..." appended passed. mark_left now asks
whether the kept text still lacks the mark.

Round three, one Copilot finding: a cut one short of the limit took
the source's next space as the character rstrip removed, even where
a zero-width space came first. For "a" * 598 + "@ b" it accepted
"a" * 598 + "@..." though sanitise keeps "@" and the mark. space_cut
now refuses the cut while mark_left finds that mark still owed.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: lf-releng-code-monkey-bot[bot] <332050256+lf-releng-code-monkey-bot[bot]@users.noreply.github.com>
verify_code_kept skipped bodies it should have checked. Its growth
bound let "&amp;" grow by four characters, but disarm_html leaves an
"&amp;" as written. It also counted outer whitespace against the
limit, though comment_text strips that whitespace before it fits the
body. Either way, a body sure to keep its code went unchecked.

The ENTITY pattern now skips "&amp;", and the bound measures the
stripped body. The code blocks are still read from the body before the
strip, as the scanner reads them. Seeds carry both reported inputs.

Review round three, one Copilot finding: the stripped-length bound
admits a long blank suffix, which written_code then rescanned for
every unclosed opener. Round four, one more: a long closing line,
spaces then a U+3000, was rescanned the same way. written_code now
reads each line once, from the last back, keeping the nearest closer
for each fence character and width, so no opener rescans the lines
after it. A closer still allows only blanks and tabs after its run, so
a U+3000 there leaves the line prose, as comment_text reads it;
Copilot's round-three suggestion of text.rstrip() would have made it
a closer. A test times both shapes; being a timing test, it lands
with the fix rather than as an expected failure.

Co-authored-by: Copilot <[email protected]>
Signed-off-by: lf-releng-code-monkey-bot[bot] <332050256+lf-releng-code-monkey-bot[bot]@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human validation is needed because the revised Markdown containment boundary and offline oracles share assumptions about GitHub autolink and code-span behavior without independently testing GitHub rendering.

No open issues 🎉

Review effort: Balanced

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Antagonistic review by agent: no line-level findings; the summary below is the verdict.

The containment change and tightened fuzz oracles appear sound on static review. No actionable defects found in the diff or its dependent call sites.

Antagonistic round 1 of 3.


Automated antagonistic review by lf-releng-antagonistic-review-bot[bot] using model gpt-6-astra; see the run. This is not a human review and never an approval: a maintainer must still review and approve this pull request.

@ModeSevenIndustrialSolutions
ModeSevenIndustrialSolutions merged commit 6123df8 into lfreleng-actions:main Nov 23, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix: Keep allowed URLs and tighten fuzz oracles

2 participants