[BUG]: verify_segment accepts empty, wrong-phase, or non-positive fork exclusions as MATCH

Open Beginner friendly
#385 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@Arnav0107 is already working on this.

Since Nov 26, 2026.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python, pytorch

Research direction

Start in simple/ovl.py at verify_segment() around lines 544–552, then read how excluded() parses control["exclude"]. Check the fork validation against the expected rules in this issue, including empty or wrong-phase exclusions and non-positive counts. Done when the supplied CPU reproduction rejects all four malformed cases while valid fork exclusions still match.

Written by the indexing model from the issue text.

Description

Summary

In simple/ovl.py, verify_segment() handles want["kind"] == "fork" by checking:

added = {key: v for key, v in want["control"].items() if key != "exclude"}
ok = (
    want["state"] == chain[k]["state"]
    and want["model"] == chain[k]["model"]
    and added == chain[k]["control"]
    and "exclude" not in chain[k]["control"]
    and all(s >= chain[k]["control"]["cursor"] for s, _ in excluded(want["control"]))
)

Because excluded(ctl) only reads ctl.get("exclude", {}).get(ctl["phase"], []) and the check never inspects exclude keys or n in [s, n], verify_segment() returns True (MATCH) for forged or malformed "fork" entries whose control["exclude"] is:

  • empty ({} or {"wikipedia": []}), where all(...) is vacuously True,
  • for a different phase ({"conversation": [[150, 25]]}), which excluded() ignores while phase == "wikipedia",
  • non-positive target counts ({"wikipedia": [[150, 0]]} or [[150, -5]]).

Source

  • simple/ovl.py (verify_segment, lines 544–552)

Reproduction (CPU)

import hashlib, json, os, sys, tempfile
from pathlib import Path
import torch

os.environ["OVL_DEVICE"] = "cpu"
sys.path.insert(0, "simple")
import ovl

with tempfile.TemporaryDirectory() as tmp:
    d = Path(tmp)
    model, opt = ovl.fresh()
    sd, opt_sd = model.state_dict(), opt.state_dict()
    m_dig, s_dig = ovl.model_digest(sd), ovl.state_digest(model, opt)
    ctl0 = {**ovl.initial_control(), "cursor": 100}
    e0 = {"index": 0, "kind": "initial", "control": ctl0, "state": s_dig, "model": m_dig, "previous": None}
    h0 = hashlib.sha256(json.dumps(e0, sort_keys=True).encode()).hexdigest()
    torch.save({"control": ctl0, "model": sd, "opt": opt_sd}, d / "ckpt-00000.pt")

    for bad_exclude in ({}, {"conversation": [[150, 25]]}, {"wikipedia": [[150, 0]]}, {"wikipedia": [[150, -5]]}):
        ctl1 = {**ctl0, "exclude": bad_exclude}
        e1 = {"index": 1, "kind": "fork", "control": ctl1, "state": s_dig, "model": m_dig, "previous": h0}
        torch.save({"control": ctl1, "model": sd, "opt": opt_sd}, d / "ckpt-00001.pt")
        print(bad_exclude, "->", ovl.verify_segment(None, d, [e0, e1], 0))

All four cases print True (segment 0->1 (fork): MATCH).

Expected Behavior

For want["kind"] == "fork", verify_segment() should require control["exclude"] to be a dict keyed only by {want["control"]["phase"]}, with at least one [s, n] range where s >= chain[k]["control"]["cursor"] and n > 0.

Dominant language
Python
Stars
27
Forks
72
Avg merge
2d 19h
Merged PRs (30d)
45

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AOSSIE-Org/OpenVerifiableLLM

All issues in AOSSIE-Org/OpenVerifiableLLM

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.