second-source 0.5.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. second_source/__init__.py +3 -0
  2. second_source/action/__init__.py +4 -0
  3. second_source/action/commands.py +88 -0
  4. second_source/action/event.py +89 -0
  5. second_source/action/inputs.py +118 -0
  6. second_source/action/main.py +203 -0
  7. second_source/action/publish.py +184 -0
  8. second_source/action/setup.py +143 -0
  9. second_source/action/sweep.py +85 -0
  10. second_source/action/wait.py +49 -0
  11. second_source/benchmark/__init__.py +1 -0
  12. second_source/benchmark/aidev.py +248 -0
  13. second_source/benchmark/aidev_local.py +85 -0
  14. second_source/benchmark/golden.py +314 -0
  15. second_source/benchmark/redact.py +45 -0
  16. second_source/benchmark/rescore.py +388 -0
  17. second_source/benchmark/runner.py +159 -0
  18. second_source/benchmark/sample.py +243 -0
  19. second_source/benchmark/stats.py +363 -0
  20. second_source/cli/__init__.py +1 -0
  21. second_source/cli/bench.py +427 -0
  22. second_source/cli/main.py +182 -0
  23. second_source/core/__init__.py +4 -0
  24. second_source/core/aggregate.py +102 -0
  25. second_source/core/checks.py +470 -0
  26. second_source/core/engine.py +98 -0
  27. second_source/core/evidence.py +29 -0
  28. second_source/core/expr.py +206 -0
  29. second_source/core/hashing.py +41 -0
  30. second_source/core/model.py +112 -0
  31. second_source/core/pack.py +156 -0
  32. second_source/packs/__init__.py +1 -0
  33. second_source/packs/coding/__init__.py +16 -0
  34. second_source/packs/coding/checks/ci_config_caution.yaml +23 -0
  35. second_source/packs/coding/checks/ci_result.yaml +133 -0
  36. second_source/packs/coding/checks/ci_weakening_caution.yaml +27 -0
  37. second_source/packs/coding/checks/deployed.yaml +36 -0
  38. second_source/packs/coding/checks/docs_updated.yaml +22 -0
  39. second_source/packs/coding/checks/fixes_issue.yaml +58 -0
  40. second_source/packs/coding/checks/fixes_issue_durable.yaml +60 -0
  41. second_source/packs/coding/checks/integrity_guard.yaml +34 -0
  42. second_source/packs/coding/checks/integrity_inspection.yaml +21 -0
  43. second_source/packs/coding/checks/lint_caution.yaml +22 -0
  44. second_source/packs/coding/checks/matching_jobs_caution.yaml +22 -0
  45. second_source/packs/coding/checks/not_reverted.yaml +38 -0
  46. second_source/packs/coding/checks/tests_added.yaml +25 -0
  47. second_source/packs/coding/checks/tests_added_guard.yaml +26 -0
  48. second_source/packs/coding/checks/tests_removed_caution.yaml +23 -0
  49. second_source/packs/coding/detection.py +94 -0
  50. second_source/packs/coding/diff_facts.py +665 -0
  51. second_source/packs/coding/extract.py +911 -0
  52. second_source/packs/coding/functions.py +241 -0
  53. second_source/packs/coding/pack.yaml +33 -0
  54. second_source/packs/coding/trusted_rules.yaml +50 -0
  55. second_source/pipeline.py +112 -0
  56. second_source/report/__init__.py +1 -0
  57. second_source/report/render.py +503 -0
  58. second_source/sources/__init__.py +1 -0
  59. second_source/sources/github/__init__.py +4 -0
  60. second_source/sources/github/auth.py +48 -0
  61. second_source/sources/github/cache.py +67 -0
  62. second_source/sources/github/client.py +261 -0
  63. second_source/sources/github/mappers.py +454 -0
  64. second_source/sources/github/source.py +385 -0
  65. second_source/sources/github/urls.py +51 -0
  66. second_source-0.5.0.dist-info/METADATA +311 -0
  67. second_source-0.5.0.dist-info/RECORD +71 -0
  68. second_source-0.5.0.dist-info/WHEEL +4 -0
  69. second_source-0.5.0.dist-info/entry_points.txt +2 -0
  70. second_source-0.5.0.dist-info/licenses/LICENSE +202 -0
  71. second_source-0.5.0.dist-info/licenses/NOTICE +9 -0
@@ -0,0 +1,133 @@
1
+ # L4: "All tests pass" / "Build succeeds" / "Lint passes" — do the CI jobs on the referenced
2
+ # commit agree?
3
+ #
4
+ # One definition serves all three claim types; job_matches(claim.type, name) picks the jobs
5
+ # that count (test jobs for TESTS_PASS, build jobs for BUILD_OK, lint jobs for LINT_OK).
6
+ #
7
+ # Re-runs: the source keys each result by commit and job name and uses the run id as the
8
+ # version, so de-duplication keeps only the newest run of every job. A flaky job that failed
9
+ # and then passed on re-run counts as passed.
10
+ # Cancelled, timed-out, skipped and neutral results are neither passes nor failures (a timeout
11
+ # is usually the runner, not the code).
12
+ #
13
+ # Local claims ("tests pass locally", scope=local): passing CI corroborates them, but failing
14
+ # CI does not prove them false, because local and CI environments differ. They get the
15
+ # distinct UNVERIFIABLE reason CI_FAILED_LOCAL_CLAIM, which the benchmark reports separately.
16
+ #
17
+ # Subset claims ("targeted tests pass", "unit tests for X pass", ✅ `pytest tests/test_x.py`,
18
+ # ✅ `biome lint`, scope=subset) work the same way: matching CI jobs that pass corroborate
19
+ # them, but a failing job may be one the claim never covered (an E2E suite, another package),
20
+ # so failure gives UNVERIFIABLE with reason CI_FAILED_SUBSET_CLAIM.
21
+ #
22
+ # No CI data at all on the commit (NO_CI_RECORDS) is reported apart from CI that ran without a
23
+ # matching job (NO_MATCHING_CI_JOBS): GitHub deletes old workflow runs, so for older PRs the
24
+ # evidence is simply gone, which says nothing about job naming.
25
+ #
26
+ # Waiting (bounded by `timeout_hours`): the check waits while a matching job is running, while
27
+ # any GitHub Actions workflow on the judged commit has not finished (queued, waiting on
28
+ # `needs:` jobs that have no check run yet, or held for approval, as Copilot and fork PRs are
29
+ # until someone clicks "Approve and run"), or, with no matching job yet, while other CI on the
30
+ # commit still runs. A commit with no CI seen at all waits only a short grace period
31
+ # (`start_grace_minutes`, counted from the commit's own time): workflow runs appear the moment
32
+ # a commit is pushed, so this mostly concerns external CI. The waiting window runs from the
33
+ # commit's time or, when later, from when a workflow run on it was triggered: a commit pushed
34
+ # long after it was made still gets its CI waited for. A commit whose CI has all finished
35
+ # without a matching job is decided at once instead of sitting at "Waiting for CI" for hours.
36
+ # Second Source's own runs are never CI evidence: the Action leaves out its own workflow's runs
37
+ # and their check runs (by workflow file), and the names "Second Source" / "second-source" are
38
+ # ignored too. A workflow waiting for an environment approval (`waiting`, a deployment gate)
39
+ # does not hold the claim. If a workflow is still unfinished when the window ends, passing
40
+ # jobs do not verify the claim (CI_TIMEOUT): a job still to come could fail.
41
+ #
42
+ # Editable texts (PR body and title) are read in their final form, but the PR may have gained
43
+ # commits after it was opened: Copilot opens with an empty "Initial plan" commit and rewrites
44
+ # the body as it works, while other agents write the body once and humans add commits later.
45
+ # Such claims carry the commit at PR creation (`ref`) and the final head (`final_ref`):
46
+ # - VERIFIED needs the matching jobs to pass on the final head;
47
+ # - CONTRADICTED needs matching jobs to fail on both commits, so the claim was false at every
48
+ # point we can see;
49
+ # - a failure on only one of them is UNVERIFIABLE (CLAIM_COMMIT_AMBIGUOUS).
50
+ # This is a heuristic: intermediate commits are not looked at, and the body may have been last
51
+ # edited at one of them. It errs towards UNVERIFIABLE, never towards CONTRADICTED.
52
+ # Claims with a single commit (commit messages, comments, PRs without later commits) behave as
53
+ # before: `final_ref` is absent and both views are the same commit.
54
+ id: coding.ci_result
55
+ version: 1.9.0
56
+ kind: state
57
+ level: L4
58
+ applies_to: [TESTS_PASS, BUILD_OK, LINT_OK]
59
+ params:
60
+ # How long to wait for CI before giving up on a running or missing job.
61
+ timeout_hours: {type: int, default: 6, min: 1, max: 48}
62
+ # How long a commit with no CI at all may wait for its first CI record.
63
+ start_grace_minutes: {type: int, default: 10, min: 1, max: 120}
64
+ evidence:
65
+ checks:
66
+ record_type: check_result
67
+ where: >-
68
+ has(claim.attributes.ref) && (e.ref == claim.attributes.ref ||
69
+ (has(claim.attributes.final_ref) && e.ref == claim.attributes.final_ref))
70
+ workflows:
71
+ record_type: ci_workflow_run
72
+ where: >-
73
+ has(claim.attributes.ref) && (e.ref == claim.attributes.ref ||
74
+ (has(claim.attributes.final_ref) && e.ref == claim.attributes.final_ref))
75
+ derive:
76
+ start: "has(claim.attributes.ref) ? claim.attributes.ref : ''"
77
+ final: "has(claim.attributes.final_ref) ? claim.attributes.final_ref : start"
78
+ relevant: "checks.filter(c, job_matches(claim.type, c.name))"
79
+ at_ref: "relevant.filter(c, c.ref == start)"
80
+ at_final: "relevant.filter(c, c.ref == final)"
81
+ failed_ref: "at_ref.filter(c, c.status == 'completed' && has(c.conclusion) && c.conclusion == 'failure')"
82
+ failed_final: "at_final.filter(c, c.status == 'completed' && has(c.conclusion) && c.conclusion == 'failure')"
83
+ failed_somewhere: "size(failed_ref) > 0 || size(failed_final) > 0"
84
+ failed_everywhere: "size(failed_ref) > 0 && size(failed_final) > 0"
85
+ running: "at_final.filter(c, c.status != 'completed')"
86
+ passed: "at_final.filter(c, c.status == 'completed' && has(c.conclusion) && c.conclusion == 'success')"
87
+ total: "size(at_final)"
88
+ passed_count: "size(passed)"
89
+ local: "has(claim.attributes.scope) && claim.attributes.scope == 'local'"
90
+ subset: "has(claim.attributes.scope) && claim.attributes.scope == 'subset'"
91
+ # Wait for CI from when the judged commit appeared: the final head may be much newer than
92
+ # the PR (a push to an old PR), and its CI starts only then.
93
+ started: "has(claim.attributes.final_at) ? claim.attributes.final_at : claim.made_at"
94
+ deadline: "started + duration(string(params.timeout_hours) + 'h')"
95
+ grace_end: "started + duration(string(params.start_grace_minutes) + 'm')"
96
+ # Our own check run and job sit on the head commit too; they are not CI evidence.
97
+ ci_records: "checks.filter(c, !(c.name in ['Second Source', 'second-source']))"
98
+ ci_running_final: "ci_records.filter(c, c.ref == final && c.status != 'completed')"
99
+ workflows_pending: >-
100
+ workflows.filter(w, w.ref == final && w.name != 'Second Source' &&
101
+ ((w.status != 'completed' && w.status != 'waiting') ||
102
+ (has(w.conclusion) && w.conclusion == 'action_required')))
103
+ ci_seen_final: >-
104
+ size(ci_records.filter(c, c.ref == final)) > 0 ||
105
+ size(workflows.filter(w, w.ref == final && w.name != 'Second Source')) > 0
106
+ # Worth waiting for: a matching job still running, a workflow not finished (its jobs may
107
+ # match), or no matching job yet while other CI runs or none has appeared within the grace.
108
+ window: "duration(string(params.timeout_hours) + 'h')"
109
+ in_window: >-
110
+ now < deadline || workflows.exists(w, w.ref == final && w.name != 'Second Source' &&
111
+ has(w.created_at) && now < w.created_at + window)
112
+ awaiting: >-
113
+ in_window && (size(running) > 0 || size(workflows_pending) > 0 || (total == 0 &&
114
+ (size(ci_running_final) > 0 || (!ci_seen_final && now < grace_end))))
115
+ outcomes:
116
+ - {when: "'check_result' in stale", result: UNVERIFIABLE, reason: SOURCE_STALE}
117
+ - {when: "!has(claim.attributes.ref)", result: UNVERIFIABLE, reason: NO_COMMIT_REFERENCE}
118
+ # The final head's CI has not reported yet: wait rather than judge on the opening commit.
119
+ - when: "has(claim.attributes.final_ref) && awaiting"
120
+ result: PENDING
121
+ reason: AWAITING_CI
122
+ - {when: "failed_somewhere && local", result: UNVERIFIABLE, reason: CI_FAILED_LOCAL_CLAIM}
123
+ - {when: "failed_somewhere && subset", result: UNVERIFIABLE, reason: CI_FAILED_SUBSET_CLAIM}
124
+ - {when: "failed_everywhere", result: CONTRADICTED, reason: CI_JOB_FAILED}
125
+ - {when: "failed_somewhere", result: UNVERIFIABLE, reason: CLAIM_COMMIT_AMBIGUOUS}
126
+ # CI may not have started yet, or may still be running.
127
+ - {when: "awaiting", result: PENDING, reason: AWAITING_CI}
128
+ - {when: "size(ci_records) == 0", result: UNVERIFIABLE, reason: NO_CI_RECORDS}
129
+ - {when: "size(relevant) == 0", result: UNVERIFIABLE, reason: NO_MATCHING_CI_JOBS}
130
+ - {when: "size(running) > 0 || size(workflows_pending) > 0", result: UNVERIFIABLE, reason: CI_TIMEOUT}
131
+ - {when: "passed_count == 0", result: UNVERIFIABLE, reason: NO_CI_RESULTS}
132
+ - {otherwise: true, result: VERIFIED, reason: ALL_MATCHING_CI_JOBS_PASSED}
133
+ explain: "{passed_count} of {total} matching CI jobs passed"
@@ -0,0 +1,27 @@
1
+ # Optional guard: CI made to tolerate test failures, or a build command made to skip tests.
2
+ #
3
+ # continue-on-error at job level on a job that runs tests, and -DskipTests / -x test added to an
4
+ # existing build, package or deploy command, can make "tests pass" mean less. Both depend on
5
+ # reading workflow structure from a diff and have legitimate uses (a non-blocking experimental
6
+ # job, a build step that tests elsewhere), so they are cautions until benchmark run 2 measures
7
+ # their precision. The narrow forms (on the test step or a test/verify/check command itself)
8
+ # withdraw through coding.integrity_guard (docs/packs/coding.md).
9
+ id: coding.ci_weakening_caution
10
+ version: 1.1.0
11
+ kind: state
12
+ role: guard
13
+ required: false
14
+ level: L4
15
+ applies_to: [TESTS_PASS]
16
+ evidence:
17
+ summary:
18
+ record_type: changed_files_summary
19
+ derive:
20
+ # Field reads are guarded by has(): an older or newer summary must not error.
21
+ s: "size(summary) > 0 ? summary[0] : {}"
22
+ tolerated: "has(s.ci_failures_tolerated) ? s.ci_failures_tolerated : 0"
23
+ build_skips: "has(s.build_tests_skipped) ? s.build_tests_skipped : 0"
24
+ outcomes:
25
+ - {when: "tolerated > 0", result: UNVERIFIABLE, reason: CI_TOLERATES_TEST_FAILURES}
26
+ - {when: "build_skips > 0", result: UNVERIFIABLE, reason: BUILD_SKIPS_TESTS}
27
+ - {otherwise: true, result: VERIFIED, reason: NO_CI_WEAKENING}
@@ -0,0 +1,36 @@
1
+ # L4: "Deployed to staging" — does a deployment of the referenced commit to that environment
2
+ # show success in GitHub's deployment records?
3
+ #
4
+ # Repositories that do not use GitHub deployments give UNVERIFIABLE, never CONTRADICTED.
5
+ # Environment names are normalised on both sides (env_matches), so "prod" meets "production".
6
+ # A failure contradicts only when nothing is still deploying and the source saw every deployment
7
+ # of the commit (`complete`): a success may hide among deployments the source did not list.
8
+ id: coding.deployed
9
+ version: 2.0.0
10
+ kind: state
11
+ level: L4
12
+ applies_to: [DEPLOYED]
13
+ params:
14
+ timeout_hours: {type: int, default: 2, min: 1, max: 24}
15
+ evidence:
16
+ deployments:
17
+ record_type: deployment_status
18
+ where: >-
19
+ has(claim.attributes.ref) && e.ref == claim.attributes.ref &&
20
+ env_matches(e.environment, claim.attributes.environment)
21
+ derive:
22
+ succeeded: "deployments.exists(d, d.state == 'success')"
23
+ failed: "deployments.exists(d, d.state in ['failure', 'error'])"
24
+ active: "deployments.exists(d, d.state in ['in_progress', 'queued', 'pending'])"
25
+ complete: "deployments.all(d, has(d.complete) && d.complete)"
26
+ deadline: "claim.made_at + duration(string(params.timeout_hours) + 'h')"
27
+ outcomes:
28
+ - {when: "'deployment_status' in stale", result: UNVERIFIABLE, reason: SOURCE_STALE}
29
+ - {when: "!has(claim.attributes.ref)", result: UNVERIFIABLE, reason: NO_COMMIT_REFERENCE}
30
+ - {when: "succeeded", result: VERIFIED, reason: DEPLOYMENT_SUCCEEDED}
31
+ - {when: "active && now < deadline", result: PENDING, reason: DEPLOYING}
32
+ - {when: "failed && !active && complete", result: CONTRADICTED, reason: DEPLOYMENT_FAILED}
33
+ - {when: "failed", result: UNVERIFIABLE, reason: DEPLOYMENT_FAILED_UNCLEAR}
34
+ - {when: "size(deployments) == 0", result: UNVERIFIABLE, reason: NO_DEPLOYMENT_RECORDS}
35
+ - {otherwise: true, result: UNVERIFIABLE, reason: DEPLOYMENT_UNCLEAR}
36
+ explain: "Deployment succeeded: {succeeded}"
@@ -0,0 +1,22 @@
1
+ # L4: "Updated the docs/README" — does the PR actually change documentation files?
2
+ #
3
+ # Never CONTRADICTED. Documentation can live in code (docstrings, XML doc comments, roxygen,
4
+ # Doxygen), and "documentation" in a sentence often means exactly that; finding no doc file is
5
+ # not proof (see tests_added.yaml for the audit behind this).
6
+ id: coding.docs_updated
7
+ version: 2.0.0
8
+ kind: state
9
+ level: L4
10
+ applies_to: [DOCS_UPDATED]
11
+ evidence:
12
+ files:
13
+ record_type: changed_file
14
+ derive:
15
+ doc_files: "files.filter(f, f.status != 'removed' && is_doc_path(f.path))"
16
+ doc_file_count: "size(doc_files)"
17
+ outcomes:
18
+ - {when: "'changed_file' in stale", result: UNVERIFIABLE, reason: SOURCE_STALE}
19
+ - {when: "size(files) == 0", result: UNVERIFIABLE, reason: NO_FILE_LIST}
20
+ - {when: "doc_file_count > 0", result: VERIFIED, reason: DOC_FILES_CHANGED}
21
+ - {otherwise: true, result: UNVERIFIABLE, reason: NO_DOC_FILES_FOUND}
22
+ explain: "{doc_file_count} documentation file(s) changed"
@@ -0,0 +1,58 @@
1
+ # L4: "Fixes #123" — once the PR is merged, was the issue closed by that merge?
2
+ #
3
+ # An issue reference without a repository ("#123") means the PR's own repository.
4
+ # Repository names are compared case-insensitively (same_repo).
5
+ # An issue that was already closed before the merge proves nothing about this PR, so it is
6
+ # UNVERIFIABLE rather than VERIFIED.
7
+ # GitHub closes linked issues automatically only when a PR merges into the default branch. An
8
+ # issue still open after a merge into another branch (a feature or release branch) is expected,
9
+ # so it is UNVERIFIABLE (NOT_DEFAULT_BRANCH), not CONTRADICTED.
10
+ id: coding.fixes_issue
11
+ version: 2.0.0
12
+ kind: state
13
+ level: L4
14
+ applies_to: [FIXES_ISSUE]
15
+ params:
16
+ # Allowed clock difference between the merge and the issue closing (GitHub closes linked
17
+ # issues right after the merge, but timestamps can differ slightly).
18
+ tolerance_minutes: {type: int, default: 5, min: 0, max: 60}
19
+ evidence:
20
+ issues:
21
+ record_type: issue_state
22
+ where: >-
23
+ e.number == claim.attributes.issue &&
24
+ same_repo(e.repo, claim.attributes.repo != '' ? claim.attributes.repo : episode.attributes.repo)
25
+ prs:
26
+ record_type: pr_state
27
+ derive:
28
+ merged: "prs.exists(p, p.merged)"
29
+ closed_unmerged: "prs.exists(p, p.state == 'closed' && !p.merged)"
30
+ merge_times: "prs.filter(p, p.merged && has(p.merged_at)).map(p, p.merged_at)"
31
+ issue_open: "issues.exists(i, i.state == 'open')"
32
+ other_branch: >-
33
+ prs.exists(p, has(p.base_ref) && has(p.default_branch) && p.base_ref != p.default_branch)
34
+ tolerance: "duration(string(params.tolerance_minutes) + 'm')"
35
+ # GitHub closes the issue itself only for a closing keyword in the PR body or a commit
36
+ # message, for an issue of the same repository. Anywhere else (a title, a comment, another
37
+ # repository) an open issue may simply never have been linked: not proof.
38
+ auto_close: "claim.origin in ['body', 'commit'] && claim.attributes.repo == ''"
39
+ outcomes:
40
+ - {when: "'issue_state' in stale || 'pr_state' in stale", result: UNVERIFIABLE, reason: SOURCE_STALE}
41
+ - {when: "size(prs) == 0", result: UNVERIFIABLE, reason: NO_PR_STATE}
42
+ # A PR closed without merging never landed its fix.
43
+ - {when: "closed_unmerged", result: UNVERIFIABLE, reason: PR_NOT_MERGED}
44
+ - {when: "!merged", result: PENDING, reason: NOT_MERGED_YET}
45
+ - {when: "size(merge_times) == 0", result: UNVERIFIABLE, reason: NO_MERGE_TIME}
46
+ - {when: "size(issues) == 0", result: UNVERIFIABLE, reason: ISSUE_NOT_ACCESSIBLE}
47
+ - {when: "issue_open && other_branch", result: UNVERIFIABLE, reason: NOT_DEFAULT_BRANCH}
48
+ # GitHub closes linked issues moments after the merge; a check that runs on the merge event
49
+ # can see the issue still open.
50
+ - {when: "issue_open && now < merge_times[0] + tolerance", result: PENDING, reason: CLOSE_PENDING}
51
+ - {when: "issue_open && !auto_close", result: UNVERIFIABLE, reason: NOT_AUTO_CLOSED}
52
+ - {when: "issue_open", result: CONTRADICTED, reason: ISSUE_STILL_OPEN}
53
+ - when: "issues.exists(i, has(i.closed_at) && i.closed_at >= merge_times[0] - tolerance)"
54
+ result: VERIFIED
55
+ reason: ISSUE_CLOSED_BY_MERGE
56
+ - {when: "issues.exists(i, has(i.closed_at))", result: UNVERIFIABLE, reason: ISSUE_ALREADY_CLOSED}
57
+ - {otherwise: true, result: UNVERIFIABLE, reason: NO_CLOSE_TIME}
58
+ explain: "Merged: {merged}; issue still open: {issue_open}"
@@ -0,0 +1,60 @@
1
+ # L5: "Fixes #123" stays true — the issue is not reopened within a window after the merge.
2
+ # Repository names are compared case-insensitively (same_repo).
3
+ # An issue that is open (never closed) after a merge into a non-default branch is expected:
4
+ # GitHub only auto-closes issues for default-branch merges (see fixes_issue.yaml).
5
+ # A reopen contradicts the fix only while the issue stays open. Maintainers also reopen an
6
+ # issue to verify a fix or to wait for a release, then close it again crediting the same PR;
7
+ # a reopened-then-closed issue may also have been fixed by a later PR. Either way the evidence
8
+ # is ambiguous, so it is UNVERIFIABLE (run-2 audit: 2 of 5 reopen contradictions were wrong).
9
+ id: coding.fixes_issue_durable
10
+ version: 2.3.0
11
+ kind: temporal
12
+ level: L5
13
+ applies_to: [FIXES_ISSUE]
14
+ params:
15
+ window_days: {type: int, default: 30, min: 7, max: 90}
16
+ # GitHub closes the issue moments after the merge; until then an open issue is not proof
17
+ # (the same grace as coding.fixes_issue, so the two checks never disagree on it).
18
+ tolerance_minutes: {type: int, default: 5, min: 0, max: 60}
19
+ evidence:
20
+ issues:
21
+ record_type: issue_state
22
+ where: >-
23
+ e.number == claim.attributes.issue &&
24
+ same_repo(e.repo, claim.attributes.repo != '' ? claim.attributes.repo : episode.attributes.repo)
25
+ prs:
26
+ record_type: pr_state
27
+ derive:
28
+ merge_times: "prs.filter(p, p.merged && has(p.merged_at)).map(p, p.merged_at)"
29
+ window: "duration(string(params.window_days * 24) + 'h')"
30
+ tolerance: "duration(string(params.tolerance_minutes) + 'm')"
31
+ other_branch: >-
32
+ prs.exists(p, has(p.base_ref) && has(p.default_branch) && p.base_ref != p.default_branch)
33
+ # GitHub closes the issue itself only for a closing keyword in the PR body or a commit
34
+ # message, for an issue of the same repository. Anywhere else (a title, a comment, another
35
+ # repository) an open issue may simply never have been linked: not proof.
36
+ auto_close: "claim.origin in ['body', 'commit'] && claim.attributes.repo == ''"
37
+ outcomes:
38
+ - {when: "'issue_state' in stale || 'pr_state' in stale", result: UNVERIFIABLE, reason: SOURCE_STALE}
39
+ - {when: "size(merge_times) == 0", result: UNVERIFIABLE, reason: NOT_MERGED}
40
+ - {when: "size(issues) == 0", result: UNVERIFIABLE, reason: ISSUE_NOT_ACCESSIBLE}
41
+ # Merges into another branch first: GitHub never closed the issue for them, so an open issue
42
+ # says nothing about the fix, reopened or not.
43
+ - {when: "issues.exists(i, i.state == 'open') && other_branch", result: UNVERIFIABLE, reason: NOT_DEFAULT_BRANCH}
44
+ # Reopened and still open contradicts only a reference GitHub itself closed: for a title,
45
+ # comment or cross-repository reference the PR was never linked to the issue, so its reopen
46
+ # says nothing about this PR (found by the randomised oracle tests).
47
+ - when: "issues.exists(i, has(i.last_reopened_at) && i.last_reopened_at > merge_times[0] && i.state == 'open') && auto_close"
48
+ result: CONTRADICTED
49
+ reason: ISSUE_REOPENED
50
+ - when: "issues.exists(i, has(i.last_reopened_at) && i.last_reopened_at > merge_times[0])"
51
+ result: UNVERIFIABLE
52
+ reason: REOPENED_THEN_CLOSED
53
+ - {when: "issues.exists(i, i.state == 'open') && !auto_close", result: UNVERIFIABLE, reason: NOT_AUTO_CLOSED}
54
+ - when: "issues.exists(i, i.state == 'open') && now < merge_times[0] + tolerance"
55
+ result: PENDING
56
+ reason: CLOSE_PENDING
57
+ - {when: "issues.exists(i, i.state == 'open')", result: CONTRADICTED, reason: ISSUE_OPEN}
58
+ - {when: "now < merge_times[0] + window", result: PENDING, reason: IN_WINDOW}
59
+ - {otherwise: true, result: VERIFIED, reason: ISSUE_STAYED_CLOSED}
60
+ explain: "Watched for {window_days} days after merge"
@@ -0,0 +1,34 @@
1
+ # Guard: did this PR weaken the evidence behind "tests pass"? (role: guard, required)
2
+ #
3
+ # CI passing proves little if the same PR skipped the failing tests, made CI ignore test
4
+ # failures, or lowered the coverage gate: on pull_request events GitHub runs the PR's own copy
5
+ # of the workflow. These three signals are deliberately narrow (unconditional skip
6
+ # markers, weakening lines next to a test command, a lower number for the same coverage key),
7
+ # so they withdraw the verification: VERIFIED becomes UNVERIFIABLE with the reason. A guard can
8
+ # never accuse (the loader allows only VERIFIED and UNVERIFIABLE outcomes).
9
+ #
10
+ # If the file list could not be read, the guard does not withdraw anything; the optional
11
+ # integrity_inspection guard shows "not inspected" instead (a rate limit must not silently erase
12
+ # verifications). Facts come from packs/coding/diff_facts.py.
13
+ id: coding.integrity_guard
14
+ version: 1.2.0
15
+ kind: state
16
+ role: guard
17
+ level: L4
18
+ applies_to: [TESTS_PASS]
19
+ evidence:
20
+ summary:
21
+ record_type: changed_files_summary
22
+ derive:
23
+ known: "size(summary) > 0 && !('changed_files_summary' in stale)"
24
+ # Every field read is guarded by has(): an older or newer summary must not error.
25
+ s: "known ? summary[0] : {}"
26
+ skips: "has(s.test_skips_net) ? s.test_skips_net : 0"
27
+ weakened: "has(s.test_cmd_weakened) ? s.test_cmd_weakened : 0"
28
+ gate_lowered: "has(s.coverage_gate_lowered) && s.coverage_gate_lowered"
29
+ outcomes:
30
+ - {when: "skips > 0", result: UNVERIFIABLE, reason: PR_SKIPS_TESTS}
31
+ - {when: "weakened > 0", result: UNVERIFIABLE, reason: PR_WEAKENS_TEST_COMMAND}
32
+ - {when: "gate_lowered", result: UNVERIFIABLE, reason: PR_LOWERS_COVERAGE_GATE}
33
+ - {otherwise: true, result: VERIFIED, reason: NO_TEST_TAMPERING_FOUND}
34
+ explain: "{skips} test(s) newly skipped, {weakened} weakened test command(s)"
@@ -0,0 +1,21 @@
1
+ # Optional guard: the integrity guards could not look (file list unreadable, or GitHub sent no
2
+ # diff for a test, CI or test-config file). Shown so a clean result is not over-trusted.
3
+ id: coding.integrity_inspection
4
+ version: 1.2.0
5
+ kind: state
6
+ role: guard
7
+ required: false
8
+ level: L4
9
+ applies_to: [TESTS_PASS, TESTS_ADDED]
10
+ evidence:
11
+ summary:
12
+ record_type: changed_files_summary
13
+ derive:
14
+ # Field reads are guarded by has(): an older or newer summary must not error.
15
+ s: "size(summary) > 0 ? summary[0] : {}"
16
+ missing: "'changed_files_summary' in stale || size(summary) == 0"
17
+ # A summary without the field (another source, an old snapshot) was not inspected either.
18
+ partial: "!missing && (has(s.uninspected) ? s.uninspected > 0 : true)"
19
+ outcomes:
20
+ - {when: "missing || partial", result: UNVERIFIABLE, reason: NOT_INSPECTED}
21
+ - {otherwise: true, result: VERIFIED, reason: INSPECTED}
@@ -0,0 +1,22 @@
1
+ # Optional guard for "lint passes": suppressions added in source, or lint configuration changed.
2
+ id: coding.lint_caution
3
+ version: 1.1.0
4
+ kind: state
5
+ role: guard
6
+ required: false
7
+ level: L4
8
+ applies_to: [LINT_OK]
9
+ evidence:
10
+ summary:
11
+ record_type: changed_files_summary
12
+ derive:
13
+ # Field reads are guarded by has(): an older or newer summary must not error.
14
+ s: "size(summary) > 0 ? summary[0] : {}"
15
+ known: "size(summary) > 0"
16
+ suppressions: "known ? (has(s.lint_suppressions_added) ? s.lint_suppressions_added : 0) : 0"
17
+ config: "known && (has(s.lint_config_changed) ? s.lint_config_changed : false)"
18
+ outcomes:
19
+ - {when: "suppressions > 0", result: UNVERIFIABLE, reason: LINT_SUPPRESSIONS_ADDED}
20
+ - {when: "config", result: UNVERIFIABLE, reason: LINT_CONFIG_CHANGED}
21
+ - {otherwise: true, result: VERIFIED, reason: NO_LINT_CHANGES}
22
+ explain: "{suppressions} lint suppression(s) added"
@@ -0,0 +1,22 @@
1
+ # Optional guard: some CI jobs matching the claim were skipped on the judged commit.
2
+ # One passing job plus several skipped ones still verifies "tests pass"; say so. (Skipped means
3
+ # conclusion skipped or neutral; a job skipped by an `if:` reports success to branch protection.)
4
+ id: coding.matching_jobs_caution
5
+ version: 1.0.0
6
+ kind: state
7
+ role: guard
8
+ required: false
9
+ level: L4
10
+ applies_to: [TESTS_PASS, BUILD_OK, LINT_OK]
11
+ evidence:
12
+ checks:
13
+ record_type: check_result
14
+ derive:
15
+ start: "has(claim.attributes.ref) ? claim.attributes.ref : ''"
16
+ final: "has(claim.attributes.final_ref) ? claim.attributes.final_ref : start"
17
+ skipped: "checks.filter(c, c.ref == final && job_matches(claim.type, c.name) && c.status == 'completed' && has(c.conclusion) && c.conclusion in ['skipped', 'neutral'])"
18
+ skipped_count: "size(skipped)"
19
+ outcomes:
20
+ - {when: "skipped_count > 0", result: UNVERIFIABLE, reason: MATCHING_JOB_SKIPPED}
21
+ - {otherwise: true, result: VERIFIED, reason: NO_MATCHING_JOB_SKIPPED}
22
+ explain: "{skipped_count} matching CI job(s) skipped"
@@ -0,0 +1,38 @@
1
+ # L5: a merged change stays merged — no revert of the merge commit within a window.
2
+ # Applies to the implicit MERGE_HOLDS claim that every merged agent PR makes.
3
+ #
4
+ # Only merges into the default branch are watched. A PR merged into a feature or release branch
5
+ # (often deleted later) has no meaningful branch to scan, so it is UNVERIFIABLE
6
+ # (NOT_DEFAULT_BRANCH) instead of a scan error or a misleading "not reverted".
7
+ #
8
+ # A revert that was itself reverted ("Revert "Revert ..."") put the change back: whether the
9
+ # change "held" is then ambiguous, so it is UNVERIFIABLE (REVERT_UNDONE), never CONTRADICTED.
10
+ id: coding.not_reverted
11
+ version: 2.0.0
12
+ kind: temporal
13
+ level: L5
14
+ applies_to: [MERGE_HOLDS]
15
+ params:
16
+ # The GitHub source scans 30 days after the merge (sources/github/source.py, REVERT_WINDOW).
17
+ # A longer window here also needs a longer scan there, or later reverts would be missed.
18
+ window_days: {type: int, default: 30, min: 7, max: 90}
19
+ evidence:
20
+ reverts:
21
+ record_type: revert
22
+ where: "e.reverted_sha == claim.attributes.merge_sha"
23
+ prs:
24
+ record_type: pr_state
25
+ derive:
26
+ other_branch: >-
27
+ prs.exists(p, has(p.base_ref) && has(p.default_branch) && p.base_ref != p.default_branch)
28
+ standing: "reverts.filter(r, !(has(r.undone) && r.undone))"
29
+ revert_count: "size(reverts)"
30
+ window_end: "claim.made_at + duration(string(params.window_days * 24) + 'h')"
31
+ outcomes:
32
+ - {when: "other_branch", result: UNVERIFIABLE, reason: NOT_DEFAULT_BRANCH}
33
+ - {when: "'revert' in stale", result: UNVERIFIABLE, reason: SOURCE_STALE}
34
+ - {when: "size(standing) > 0", result: CONTRADICTED, reason: REVERTED}
35
+ - {when: "revert_count > 0", result: UNVERIFIABLE, reason: REVERT_UNDONE}
36
+ - {when: "now < window_end", result: PENDING, reason: IN_WINDOW}
37
+ - {otherwise: true, result: VERIFIED, reason: NOT_REVERTED}
38
+ explain: "{revert_count} revert(s) found within {window_days} days"
@@ -0,0 +1,25 @@
1
+ # L4: "Added tests" — does the PR actually add or change test files?
2
+ # A test file counts if it was added or modified with at least one added line.
3
+ #
4
+ # Never CONTRADICTED. Finding no test file is not proof: tests can live inside source files
5
+ # (Rust #[cfg(test)], in-source vitest, Racket module+ test), and a sentence that only looks
6
+ # like a claim ("creates test directories") rarely comes with test files either. The run-2
7
+ # audit found 8 of 36 "no test file" contradictions were really false claims, so absence is
8
+ # reported as UNVERIFIABLE with its reason in words.
9
+ id: coding.tests_added
10
+ version: 2.0.0
11
+ kind: state
12
+ level: L4
13
+ applies_to: [TESTS_ADDED]
14
+ evidence:
15
+ files:
16
+ record_type: changed_file
17
+ derive:
18
+ test_files: "files.filter(f, f.status != 'removed' && f.additions > 0 && is_test_path(f.path))"
19
+ test_file_count: "size(test_files)"
20
+ outcomes:
21
+ - {when: "'changed_file' in stale", result: UNVERIFIABLE, reason: SOURCE_STALE}
22
+ - {when: "size(files) == 0", result: UNVERIFIABLE, reason: NO_FILE_LIST}
23
+ - {when: "test_file_count > 0", result: VERIFIED, reason: TEST_FILES_CHANGED}
24
+ - {otherwise: true, result: UNVERIFIABLE, reason: NO_TEST_FILES_FOUND}
25
+ explain: "{test_file_count} test file(s) added or changed"
@@ -0,0 +1,26 @@
1
+ # Guard: are the "added tests" themselves switched off? (role: guard, required)
2
+ # A PR that adds test files whose new tests are skipped has not added running tests.
3
+ id: coding.tests_added_guard
4
+ version: 1.2.0
5
+ kind: state
6
+ role: guard
7
+ level: L4
8
+ applies_to: [TESTS_ADDED]
9
+ evidence:
10
+ summary:
11
+ record_type: changed_files_summary
12
+ derive:
13
+ known: "size(summary) > 0 && !('changed_files_summary' in stale)"
14
+ # Every field read is guarded by has(): an older or newer summary must not error.
15
+ s: "known ? summary[0] : {}"
16
+ skips: "has(s.test_skips_net) ? s.test_skips_net : 0"
17
+ added: "has(s.test_cases_added) ? s.test_cases_added : 0"
18
+ # New cases in files where one marker skips a whole group (describe.skip, a skipped test
19
+ # class, a module-level pytestmark).
20
+ suite_skipped: "has(s.suite_skipped_cases) ? s.suite_skipped_cases : 0"
21
+ outcomes:
22
+ - when: "added > 0 && ((skips > 0 && added <= skips) || suite_skipped >= added)"
23
+ result: UNVERIFIABLE
24
+ reason: ADDED_TESTS_ARE_SKIPPED
25
+ - {otherwise: true, result: VERIFIED, reason: ADDED_TESTS_NOT_SKIPPED}
26
+ explain: "{added} test case(s) added, {skips} newly skipped"
@@ -0,0 +1,23 @@
1
+ # Optional guard: test cases removed while the code they test stays.
2
+ # Most deleted tests go with deleted code, so this fires only when at least two more test cases
3
+ # were removed than added, no source file was deleted and the source did not shrink.
4
+ id: coding.tests_removed_caution
5
+ version: 1.1.0
6
+ kind: state
7
+ role: guard
8
+ required: false
9
+ level: L4
10
+ applies_to: [TESTS_PASS]
11
+ evidence:
12
+ summary:
13
+ record_type: changed_files_summary
14
+ derive:
15
+ # Field reads are guarded by has(): an older or newer summary must not error.
16
+ s: "size(summary) > 0 ? summary[0] : {}"
17
+ known: "size(summary) > 0"
18
+ net_removed: "known ? (has(s.test_cases_removed) ? s.test_cases_removed : 0) - (has(s.test_cases_added) ? s.test_cases_added : 0) : 0"
19
+ code_kept: "known && !(has(s.code_removed) ? s.code_removed : false) && (has(s.code_net) ? s.code_net : 0) >= 0"
20
+ outcomes:
21
+ - {when: "net_removed >= 2 && code_kept", result: UNVERIFIABLE, reason: PR_REMOVES_TESTS}
22
+ - {otherwise: true, result: VERIFIED, reason: NO_TESTS_REMOVED}
23
+ explain: "{net_removed} more test case(s) removed than added"