| 1 | """Jobs Page Secret Signals: the written rules, and the labelled set's arithmetic. |
| 2 | |
| 3 | The first half pins the instruction text the model reads. The second half runs |
| 4 | ``tests/fixtures/jobs_signals_labelled.json`` through ``tests/jobs_signals_rule``, |
| 5 | which pins the decision rule and the labels' consistency with it. Neither half |
| 6 | tests whether a model picks or classifies signals correctly; only a live run |
| 7 | compared against the labels shows that (see docs/reference/eval.md). |
| 8 | """ |
| 9 | |
| 10 | import json |
| 11 | import re |
| 12 | from pathlib import Path |
| 13 | |
| 14 | import pytest |
| 15 | |
| 16 | from tests import jobs_signals_rule as rule |
| 17 | from tests.skill_contract import ROUTES, reference_text, root_text, routing_table |
| 18 | |
| 19 | CONDITION = "Hiring intent or an engine ## Hiring Signals, ## Jobs Digest or ## Patent Digest block" |
| 20 | ROUTED = ("hiring-signals", "patent-signals") |
| 21 | SECTION_HEADING = "## Jobs Page Secret Signals (default company runs)\n" |
| 22 | CLOSING = "These are open postings, not hires or announcements." |
| 23 | LABELLED = json.loads( |
| 24 | (Path(__file__).parent / "fixtures" / "jobs_signals_labelled.json").read_text(encoding="utf-8") |
| 25 | ) |
| 26 | BOARDS = {board["company"]: board for board in LABELLED["boards"]} |
| 27 | |
| 28 | |
| 29 | def _section(): |
| 30 | text = reference_text("hiring-signals") |
| 31 | assert SECTION_HEADING in text, "hiring-signals.md has no default-run section" |
| 32 | return text.split(SECTION_HEADING, 1)[1].split("\n## ", 1)[0] |
| 33 | |
| 34 | |
| 35 | def _rule(marker): |
| 36 | """The paragraph of the default-run section that opens with ``marker``.""" |
| 37 | section = _section() |
| 38 | assert marker in section, f"missing rule: {marker}" |
| 39 | return section.split(marker, 1)[1].split("\n\n**", 1)[0] |
| 40 | |
| 41 | |
| 42 | # --- routing and the synthesis gate ------------------------------------------------- |
| 43 | |
| 44 | |
| 45 | def test_a_jobs_digest_in_the_engine_output_routes_the_reference(): |
| 46 | # One row routes the jobs reference and the patent reference together. |
| 47 | assert ROUTES[CONDITION] == ROUTED |
| 48 | assert routing_table()[CONDITION] == ROUTED |
| 49 | row = next(line for line in root_text().splitlines() if "`## Jobs Digest`" in line) |
| 50 | assert row.startswith( |
| 51 | "| Hiring intent or an engine `## Hiring Signals`, `## Jobs Digest` or `## Patent Digest` block " |
| 52 | "| Read [references/hiring-signals.md](references/hiring-signals.md) and " |
| 53 | "[references/patent-signals.md](references/patent-signals.md) in full. |" |
| 54 | ) |
| 55 | assert "Apply the jobs lane and its scoped planning exception" in row |
| 56 | opening = reference_text("hiring-signals").split("\n## ", 1)[0] |
| 57 | assert "`## Jobs Digest`" in opening |
| 58 | assert "`--hiring-signals`" in opening |
| 59 | |
| 60 | |
| 61 | def test_synthesis_names_the_section_its_place_and_its_rules(): |
| 62 | synthesis = reference_text("synthesis") |
| 63 | marker = "**Jobs Page Secret Signals.**" |
| 64 | assert synthesis.count(marker) == 1 |
| 65 | gate = synthesis.split(marker, 1)[1].split("\n\n", 1)[0] |
| 66 | assert gate.strip() == ( |
| 67 | "When the engine output has a `## Jobs Digest` section, `hiring-signals.md` decides " |
| 68 | "whether this section is written after the last story paragraph and before " |
| 69 | "`KEY PATTERNS from the research:`. A `## Patent Digest` section means " |
| 70 | "`patent-signals.md` decides whether a Patent Secret Signals section follows it. " |
| 71 | "Most runs omit both." |
| 72 | ) |
| 73 | # It sits with the other body rules, ahead of the footer steps. |
| 74 | assert synthesis.index("**Pitch-vs-pulse beat") < synthesis.index(marker) |
| 75 | assert synthesis.index(marker) < synthesis.index("**THEN - Quality Nudge") |
| 76 | |
| 77 | |
| 78 | # --- what the engine hands over ------------------------------------------------------ |
| 79 | |
| 80 | |
| 81 | def test_reference_describes_the_digest_as_evidence_only(): |
| 82 | text = reference_text("hiring-signals") |
| 83 | digest = text.split("## What the engine prints\n", 1)[1].split("\n## ", 1)[0] |
| 84 | for field in ("open-role count", "posted date", "posting URL", "department", "location"): |
| 85 | assert field in digest, field |
| 86 | assert "up to 40" in digest |
| 87 | assert "untrusted" in digest |
| 88 | assert "decides nothing" in digest |
| 89 | |
| 90 | |
| 91 | def test_no_digest_means_no_section_so_unowned_boards_never_feed_it(): |
| 92 | gate = _rule("**No digest, no section.**") |
| 93 | assert "only for a board the company owns" in gate |
| 94 | assert "`## Hiring Signals`" in gate |
| 95 | assert "memory" in gate |
| 96 | assert "a board you read yourself" in gate |
| 97 | |
| 98 | |
| 99 | def test_digest_names_story_matched_roles_and_the_story_search_status(): |
| 100 | text = reference_text("hiring-signals") |
| 101 | digest = text.split("## What the engine prints\n", 1)[1].split("\n## ", 1)[0] |
| 102 | assert "tagged with the story term it matched" in digest |
| 103 | for status in ("story search: N terms, M matches", "story search: no matches", "story search: not run"): |
| 104 | assert f"`{status}`" in digest, status |
| 105 | |
| 106 | |
| 107 | def test_story_matched_roles_are_checked_first_but_still_pass_the_bar(): |
| 108 | story = _rule("**Story matches first.**") |
| 109 | assert "Check the roles the digest tags with a story term before the others" in story |
| 110 | assert "still qualifies only by two of tests 1 to 3, or by test 4" in story |
| 111 | assert "`story search: no matches`" in story |
| 112 | assert "omit the section" in story |
| 113 | section = _section() |
| 114 | assert section.index("**The bar.**") < section.index("**Story matches first.**") |
| 115 | assert section.index("**Story matches first.**") < section.index("**How many.**") |
| 116 | |
| 117 | |
| 118 | # --- the bar and the floor ----------------------------------------------------------- |
| 119 | |
| 120 | |
| 121 | def test_the_bar_has_four_tests_and_one_qualifying_rule(): |
| 122 | bar = _rule("**The bar.**") |
| 123 | for number, name in enumerate( |
| 124 | ( |
| 125 | "Out of character.", |
| 126 | "Names something concrete.", |
| 127 | "Large and hard to undo.", |
| 128 | "Bears on a story in this report.", |
| 129 | ), |
| 130 | start=1, |
| 131 | ): |
| 132 | assert f"{number}. **{name}**" in bar, name |
| 133 | assert "product, unit, place, counterparty, technology or licence" in bar |
| 134 | assert ( |
| 135 | "A signal qualifies when it meets at least two of tests 1 to 3, or when it meets test 4." |
| 136 | in bar |
| 137 | ) |
| 138 | |
| 139 | |
| 140 | def test_the_bar_carries_one_passing_one_failing_and_one_story_example(): |
| 141 | bar = _rule("**The bar.**") |
| 142 | assert "Gas Supply and Transport Lead" in bar |
| 143 | assert "SMB account executive" in bar |
| 144 | assert "67 open roles based in China" in bar |
| 145 | |
| 146 | |
| 147 | def test_at_most_two_signals_and_one_is_enough(): |
| 148 | count = _rule("**How many.**") |
| 149 | assert "At most two signals in the section" in count |
| 150 | assert "One qualifying signal is enough to write the section." in count |
| 151 | assert "With none, write nothing about jobs in the body" in count |
| 152 | assert "a cluster is one of the two" in count |
| 153 | # The old floor is gone from the whole reference. |
| 154 | text = reference_text("hiring-signals") |
| 155 | for old in ("at least two signals qualify", "two-signal floor", "At most five signals", "**The floor.**"): |
| 156 | assert old not in text, old |
| 157 | assert rule.MIN_SIGNALS == 1 and rule.MAX_SIGNALS == 2 |
| 158 | |
| 159 | |
| 160 | def test_a_cluster_of_three_or_more_postings_is_one_signal(): |
| 161 | cluster = _rule("**Clusters.**") |
| 162 | assert "A cluster counts as one signal." in cluster |
| 163 | assert "Three or more postings in the digest that share one specific, concrete focus" in cluster |
| 164 | assert "a customer type, a place, a named program, or a function that is new for this company" in cluster |
| 165 | assert "even when no single posting would" in cluster |
| 166 | assert "out of character (test 1) or bears on a story in this report (test 4)" in cluster |
| 167 | assert "Two postings are not a cluster" in cluster |
| 168 | assert "General Accounts Federal and SLED team" in cluster |
| 169 | assert rule.MIN_CLUSTER_POSTINGS == 3 |
| 170 | |
| 171 | |
| 172 | def test_each_signal_says_what_is_hired_for_and_why_it_is_interesting(): |
| 173 | paragraph = _rule("**Each signal paragraph**") |
| 174 | assert "is two sentences" in paragraph |
| 175 | assert "lead with what the role is" in paragraph |
| 176 | assert "**What the company is hiring for.**" in paragraph |
| 177 | assert "**Why it is interesting.**" in paragraph |
| 178 | assert "what the hire would let the company do, or what it suggests and why that matters this month" in paragraph |
| 179 | assert "tied to a story in this report when one exists" in paragraph |
| 180 | assert '"which suggests", "that points to"' in paragraph |
| 181 | assert "never as an announced fact" in paragraph |
| 182 | assert "never say the company is building, will ship or has decided anything" in paragraph |
| 183 | assert "say how many postings there are and cite two of them" in paragraph |
| 184 | assert rule.CLUSTER_POSTINGS_CITED == 2 and rule.MAX_PARAGRAPH_SENTENCES == 2 |
| 185 | assert rule.MAX_QUOTE_WORDS == 12 |
| 186 | |
| 187 | |
| 188 | def test_section_length_is_a_lead_in_two_short_paragraphs_at_most_and_the_closing_line(): |
| 189 | length = _rule("**Length.**") |
| 190 | assert "The lead-in running into the first signal" in length |
| 191 | assert "at most two signal paragraphs of two sentences each" in length |
| 192 | assert "Nothing more." in length |
| 193 | assert rule.max_section_paragraphs() == 3 |
| 194 | |
| 195 | |
| 196 | # --- the web check ------------------------------------------------------------------ |
| 197 | |
| 198 | |
| 199 | def test_web_check_precedes_any_unreported_or_secret_wording(): |
| 200 | check = _rule("**Check the web first.**") |
| 201 | assert "Isolated web search" in check |
| 202 | assert "`research-runbook.md`" in check |
| 203 | assert re.search(r"Before a signal is described as unreported[^.]*a secret", check) |
| 204 | assert "Never call a signal unreported without that check." in check |
| 205 | |
| 206 | |
| 207 | def test_section_is_omitted_when_the_host_cannot_search(): |
| 208 | assert "If the host has no web search, omit the section." in _rule("**Check the web first.**") |
| 209 | |
| 210 | |
| 211 | def test_public_but_missing_signals_are_worded_as_public(): |
| 212 | check = _rule("**Check the web first.**") |
| 213 | assert '"already announced"' in check |
| 214 | assert '"public, but not in this month\'s conversation"' in check |
| 215 | assert "never as unreported or as a secret" in check |
| 216 | |
| 217 | |
| 218 | # --- format -------------------------------------------------------------------------- |
| 219 | |
| 220 | |
| 221 | def test_format_is_a_lead_in_then_one_list_free_paragraph_per_signal(): |
| 222 | fmt = _rule("**Format.**") |
| 223 | assert "`**Jobs Page Secret Signals** - `" in fmt |
| 224 | assert "as the engine printed them" in fmt |
| 225 | assert "runs straight into the first signal" in fmt |
| 226 | assert "carries the board's open-role count and its new-in-window count as a clause" in fmt |
| 227 | assert "not a sentence of its own" in fmt |
| 228 | assert "Leave the new-in-window count out when the `Board:` line has none" in fmt |
| 229 | assert "the open-role count too when the `Board:` line prints none" in fmt |
| 230 | assert "one short paragraph per signal" in fmt |
| 231 | assert "no bullets, no numbered list, no `##` header" in fmt |
| 232 | |
| 233 | |
| 234 | def test_each_signal_is_quoted_named_and_linked_as_printed(): |
| 235 | fmt = _rule("**Format.**") |
| 236 | assert fmt # the lead-in rule is still there |
| 237 | paragraph = _rule("**Each signal paragraph**") |
| 238 | assert "quote the posting's own words" in paragraph |
| 239 | assert "name the role" in paragraph |
| 240 | assert "exactly as the digest printed it" in paragraph |
| 241 | |
| 242 | |
| 243 | def test_section_closes_with_the_exact_disclaimer(): |
| 244 | assert f'"{CLOSING}"' in _rule("**Format.**") |
| 245 | |
| 246 | |
| 247 | def test_format_example_is_list_free_and_ends_on_the_disclaimer(): |
| 248 | example = _section().split("```\n", 1)[1].split("\n```", 1)[0] |
| 249 | lines = [line for line in example.splitlines() if line.strip()] |
| 250 | assert lines[0].startswith("**Jobs Page Secret Signals** - ") |
| 251 | assert lines[-1] == CLOSING |
| 252 | for line in lines: |
| 253 | assert not re.match(r"\s*(?:[-*•]\s|\d+[.)\\]|#)", line), line |
| 254 | # The lead-in running into a single-posting signal, a cluster signal, the closing line. |
| 255 | assert len(lines) == rule.max_section_paragraphs() |
| 256 | opening = rule.sentences(lines[0])[0] |
| 257 | assert "{N} open roles" in opening and "({M} posted in the window)" in opening |
| 258 | for paragraph in lines[:-1]: |
| 259 | assert len(rule.sentences(paragraph)) == rule.MAX_PARAGRAPH_SENTENCES, paragraph |
| 260 | assert rule.paragraph_ok(paragraph), paragraph |
| 261 | assert lines[0].count("]({posting URL})") == 1 |
| 262 | assert lines[1].count("]({posting URL})") == rule.CLUSTER_POSTINGS_CITED |
| 263 | |
| 264 | |
| 265 | def test_standout_may_be_a_key_pattern_and_the_footer_stays_the_engines(): |
| 266 | extra = _rule("**Key patterns and footer.**") |
| 267 | assert "all of tests 1 to 3" in extra |
| 268 | assert "one KEY PATTERNS line" in extra |
| 269 | assert "Never add a signal count to the footer" in extra |
| 270 | |
| 271 | |
| 272 | def test_section_stays_out_of_comparison_recommendations_and_exec(): |
| 273 | scope = _rule("**Where it is left out.**") |
| 274 | for name in ("COMPARISON", "RECOMMENDATIONS", "`exec`"): |
| 275 | assert name in scope, name |
| 276 | |
| 277 | |
| 278 | # --- the labelled set ---------------------------------------------------------------- |
| 279 | |
| 280 | |
| 281 | def test_labelled_set_covers_the_four_boards_and_the_nvidia_cluster(): |
| 282 | assert set(BOARDS) == { |
| 283 | "Anthropic", "Stripe", "SpaceX", "Nvidia", "Nvidia, public sector cluster", |
| 284 | } |
| 285 | |
| 286 | |
| 287 | @pytest.mark.parametrize("company", sorted(BOARDS)) |
| 288 | def test_labels_are_well_formed(company): |
| 289 | board = BOARDS[company] |
| 290 | assert board["expected_section"] in {"present", "absent"} |
| 291 | for candidate in board["candidates"]: |
| 292 | assert candidate["role"] |
| 293 | assert set(candidate["tests"]) <= {1, 2, 3, 4}, candidate["role"] |
| 294 | assert candidate["public"] in {True, False, None}, candidate["role"] |
| 295 | assert candidate["expected"] in {"qualifies", "does not qualify"}, candidate["role"] |
| 296 | assert candidate["quote"] is None or candidate["quote"].strip(), candidate["role"] |
| 297 | if rule.BEARS_ON_STORY in candidate["tests"]: |
| 298 | assert board["report_story"], f"{candidate['role']} bears on a story the board lacks" |
| 299 | |
| 300 | |
| 301 | @pytest.mark.parametrize("company", sorted(BOARDS)) |
| 302 | def test_each_labelled_signal_gets_its_expected_outcome(company): |
| 303 | for candidate in BOARDS[company]["candidates"]: |
| 304 | expected = candidate["expected"] == "qualifies" |
| 305 | assert bool(rule.qualifying([candidate])) is expected, candidate["role"] |
| 306 | if "cluster" in candidate: |
| 307 | assert len(candidate["cluster"]) >= rule.MIN_CLUSTER_POSTINGS, candidate["role"] |
| 308 | assert candidate["focus"], candidate["role"] |
| 309 | |
| 310 | |
| 311 | @pytest.mark.parametrize("company", sorted(BOARDS)) |
| 312 | def test_each_labelled_board_gets_its_expected_section(company): |
| 313 | board = BOARDS[company] |
| 314 | expected = board["expected_section"] == "present" |
| 315 | assert rule.section_present(board["candidates"]) is expected |
| 316 | |
| 317 | |
| 318 | def test_expected_signals_per_board(): |
| 319 | def kept(company): |
| 320 | return [c["role"] for c in rule.qualifying(BOARDS[company]["candidates"])] |
| 321 | |
| 322 | assert kept("Anthropic") == [ |
| 323 | "Gas Supply and Transport Lead, US and Canada", |
| 324 | "Hardware Systems Architect", |
| 325 | "M&A Tax Director", |
| 326 | "Public Sector Sales Lead, France", |
| 327 | ] |
| 328 | assert kept("Stripe") == ["Engineering Manager, Money as a Service (MaaS)"] |
| 329 | assert kept("SpaceX") == [ |
| 330 | "Supervisor, Hospitality (Moon Corps)", |
| 331 | "Starmind roles", |
| 332 | "Sr. Core Integration Engineer, Starlink Mobile", |
| 333 | ] |
| 334 | assert len(kept("Nvidia")) == 2 |
| 335 | |
| 336 | |
| 337 | def test_stripe_has_one_signal_and_one_is_enough(): |
| 338 | stripe = BOARDS["Stripe"]["candidates"] |
| 339 | assert rule.signals_shown(stripe) == 1 |
| 340 | assert rule.signals_shown(stripe, hiring_signals_run=True) == 1 |
| 341 | |
| 342 | |
| 343 | def test_boards_with_more_qualifying_signals_show_two(): |
| 344 | for company in ("Anthropic", "SpaceX"): |
| 345 | assert rule.signals_shown(BOARDS[company]["candidates"]) == 2 |
| 346 | |
| 347 | |
| 348 | def test_nvidia_public_sector_cluster_is_one_signal_and_the_section_is_written(): |
| 349 | # A real "Jensen Huang" run got this digest and wrote no section: no |
| 350 | # single posting qualified, and one signal was below the old floor. |
| 351 | board = BOARDS["Nvidia, public sector cluster"] |
| 352 | cluster, alone, _other = board["candidates"] |
| 353 | assert len(cluster["cluster"]) == 4 |
| 354 | assert rule.qualifying(board["candidates"]) == [cluster] |
| 355 | assert not rule.qualifies(alone["tests"]) |
| 356 | assert rule.section_present(board["candidates"]) |
| 357 | assert rule.signals_shown(board["candidates"]) == board["expected_signals"] == 1 |
| 358 | assert "Congress" in board["report_story"] |
| 359 | |
| 360 | |
| 361 | @pytest.mark.parametrize("company", sorted(BOARDS)) |
| 362 | def test_no_board_gets_a_section_without_web_search(company): |
| 363 | candidates = BOARDS[company]["candidates"] |
| 364 | assert not rule.section_present(candidates, web_search=False) |
| 365 | assert not rule.section_present(candidates, web_search=False, hiring_signals_run=True) |
| 366 | |
| 367 | |
| 368 | def test_starmind_is_kept_but_worded_as_public(): |
| 369 | spacex = {c["role"]: c for c in BOARDS["SpaceX"]["candidates"]} |
| 370 | assert rule.qualifies(spacex["Starmind roles"]["tests"]) |
| 371 | assert rule.wording(spacex["Starmind roles"]) == "public" |
| 372 | assert not rule.standout(spacex["Starmind roles"]) |
| 373 | assert rule.wording(spacex["Supervisor, Hospitality (Moon Corps)"]) == "unreported" |
| 374 | assert rule.standout(spacex["Supervisor, Hospitality (Moon Corps)"]) |
| 375 | assert not rule.qualifies(spacex["SpaceXSI roles"]["tests"]) |
| 376 | |
| 377 | |
| 378 | def test_nvidia_china_roles_qualify_only_through_the_report_story(): |
| 379 | nvidia = BOARDS["Nvidia"] |
| 380 | china = nvidia["candidates"][0] |
| 381 | assert china["tests"] == [4] |
| 382 | assert "China" in nvidia["report_story"] |
| 383 | assert rule.qualifies(china["tests"]) |
| 384 | assert not rule.qualifies([]) |
| 385 | |
| 386 | |
| 387 | def test_rule_arithmetic_at_the_edges(): |
| 388 | assert not rule.qualifies([1]) |
| 389 | assert not rule.qualifies([3]) |
| 390 | assert rule.qualifies([1, 3]) |
| 391 | assert rule.qualifies([4]) |
| 392 | assert rule.qualifies([2, 4]) |
| 393 | seven = [{"tests": [1, 2, 3], "public": False}] * 7 |
| 394 | assert rule.signals_shown(seven) == rule.MAX_SIGNALS == 2 |
| 395 | assert rule.signals_shown([{"tests": [], "public": None}]) == 0 |
| 396 | # Out of character alone: three postings sharing a focus qualify, two do not. |
| 397 | assert rule.qualifies([1], postings=3) |
| 398 | assert not rule.qualifies([1], postings=2) |
| 399 | assert not rule.qualifies([2], postings=5) |
| 400 | assert rule.wording({"public": None}) == "check first" |
| 401 | assert not rule.standout({"tests": [1, 2, 3], "public": None}) |
| 402 | |
| 403 | |
| 404 | PARAGRAPHS = {paragraph["case"]: paragraph for paragraph in LABELLED["paragraphs"]} |
| 405 | |
| 406 | |
| 407 | @pytest.mark.parametrize("case", sorted(PARAGRAPHS)) |
| 408 | def test_each_labelled_paragraph_gets_its_expected_verdict(case): |
| 409 | paragraph = PARAGRAPHS[case] |
| 410 | assert paragraph["expected"] in {"valid", "invalid"} |
| 411 | assert rule.paragraph_ok(paragraph["text"]) is (paragraph["expected"] == "valid"), case |
| 412 | |
| 413 | |
| 414 | def test_a_three_sentence_paragraph_is_rejected(): |
| 415 | three = PARAGRAPHS["Three sentences"]["text"] |
| 416 | assert len(rule.sentences(three)) == 3 |
| 417 | assert not rule.paragraph_ok(three) |
| 418 |