Game-rule checks for runs answered through "Report a run"
Reported and Reddit-comment runs now get the checks the community form gets in core/atlas/coding.py, as data_flags (the run is kept): - first dragon outside the documented pool for the company/direction - a bond or burn by a dragon the encounter does not have (new encounter_colours table in core/spec/form.yaml; Orange/Brown after the two Greens allowed, as a Green's rescue) - a Green on a valley run - a cadet outcome off its scream path, fight answers or a post-fight path on a run that did not help, a second fight move without assessing - died before the hour, yet reached the tree/valley or an encounter planner/policy.yaml drop_flagged: flagged runs of sources read from free text (reddit comment) stay out of the route model; provenance notes do not count as flags. No effect today: the source is not in `sources` yet. On the first 82 scraped runs: 6 flagged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -278,7 +278,7 @@ class RedditComments(unittest.TestCase):
|
||||
"answers": {"company": "Alone", "outcome": "Incinerated at a bonding encounter", "outcome_color": "Red"}}]}),
|
||||
encoding="utf-8")
|
||||
manual = TMP / "reddit_comments_manual.yaml"
|
||||
manual.write_text("reject: [c2]\nfix: {c1: {outcome_color: Blue, direction: null}}\n"
|
||||
manual.write_text("reject: [c2]\nfix: {c1: {outcome_color: Blue, branch: 'Valley: passed the Red, the meadow', direction: null}}\n"
|
||||
"add: [{id: c9, thread: abc, posted: '2026-11-16', "
|
||||
"answers: {company: Two squadmates, direction: West (toward the scent), outcome: Died before the hour}}]\n",
|
||||
encoding="utf-8")
|
||||
@@ -286,12 +286,53 @@ class RedditComments(unittest.TestCase):
|
||||
self.assertEqual([r["run_id"] for r in rows], ["comment-c1", "comment-c3", "comment-c9"])
|
||||
c1, c3, c9 = rows
|
||||
self.assertEqual((c1["source"], c1["outcome_color"], c1["direction"], c1["hour"], c1["enc_Blue"]),
|
||||
("reddit comment", "Blue", "Unknown", "Tree", "Bonded!"))
|
||||
("reddit comment", "Blue", "Unknown", "Valley", "Bonded!"))
|
||||
self.assertEqual(c1["data_flags"], "read from a Reddit comment")
|
||||
self.assertEqual(c3["data_flags"], "read from a Reddit comment automatically, not checked by hand")
|
||||
self.assertEqual((c9["company"], c9["direction"], c9["hour"]), ("2 Squadmates", "West", "DIED before the hour"))
|
||||
self.assertEqual(validate.problems(rows, runs.DICT), [])
|
||||
|
||||
def test_game_rules_flag_impossible_runs(self):
|
||||
def flags(**answers):
|
||||
return runs.answers_row("x", "reddit comment", None, answers)["data_flags"]
|
||||
ok = flags(company="Alone", direction="East (toward the roar)", first_sighting="Orange",
|
||||
scream="Kept walking (ignored it)", resolution="Wounded cadet: tourniquet",
|
||||
branch="Tree: climbed down slowly to the two Greens", outcome="Bonded", outcome_color="Brown")
|
||||
self.assertEqual(ok, "") # Brown after the Greens: a Green's rescue
|
||||
cases = {
|
||||
"first sighting Orange not in documented pool for Alone/Center":
|
||||
dict(company="Alone", direction="Toward the forest centre", first_sighting="Orange", outcome="Died before the hour"),
|
||||
"Brown at the Shadow (rare) encounter, which has only Black/Blue":
|
||||
dict(branch="Tree: the shadow (Blue or Black)", outcome="Bonded", outcome_color="Brown"),
|
||||
"Red at the Passed the Red: meadow encounter":
|
||||
dict(branch="Valley: passed the Red, the meadow", outcome="Incinerated at a bonding encounter", outcome_color="Red"),
|
||||
"Green recorded on a Valley run":
|
||||
dict(hour="Went to the valley centre", outcome="Bonded", outcome_color="Green"),
|
||||
"does not follow 'Ignore the scream'":
|
||||
dict(scream="Kept walking (ignored it)", resolution="Bullies: my squadmate's revenge", outcome="Died before the hour"),
|
||||
"fight answers on a run that did not help":
|
||||
dict(scream="Kept walking (ignored it)", combat_first="Pause to assess", outcome="Died before the hour"),
|
||||
"a path after the fight on a run without a fight":
|
||||
dict(scream="Investigated, and walked away", post_path="West", outcome="Died before the hour"),
|
||||
"a second fight move without pausing to assess":
|
||||
dict(scream="Investigated, and helped my squadmate", combat_first="Charge the smaller cadet",
|
||||
combat_second="Engage the smaller cadet", outcome="Died before the hour"),
|
||||
"died before the hour, yet reached":
|
||||
dict(scream="Investigated, and helped my squadmate", resolution="I died in the fight", outcome="Bonded", outcome_color="Red"),
|
||||
}
|
||||
for expected, answers in cases.items():
|
||||
self.assertIn(expected, flags(**answers), expected)
|
||||
|
||||
def test_flagged_comment_runs_stay_out_of_the_route_model(self):
|
||||
sys.path.insert(0, str(ROOT / "planner"))
|
||||
import build_policy
|
||||
rows = [{"source": "reddit comment", "data_flags": "read from a Reddit comment automatically, not checked by hand"},
|
||||
{"source": "reddit comment", "data_flags": "read from a Reddit comment; Green recorded on a Valley run (no Greens in the valley)"},
|
||||
{"source": "reddit spreadsheet", "data_flags": "multiple wings"},
|
||||
{"source": "reported", "data_flags": "Green recorded on a Valley run (no Greens in the valley)"}]
|
||||
kept = build_policy.drop_flagged(rows)
|
||||
self.assertEqual([r["source"] for r in kept], ["reddit comment", "reddit spreadsheet", "reported"])
|
||||
|
||||
def test_delivered_not_extracted(self):
|
||||
spec = read_yaml("collection/pipeline.yaml")["sources"]["reddit_comments"]
|
||||
with self.assertRaises(extract.Skip):
|
||||
|
||||
Reference in New Issue
Block a user