Checks
The checks an agent runs on the assessed nodes: what they accept, how they run, and what they record.
The targets are the document and analyst nodes of a type with assess = true. An agent proposes
checks of the types the runner implements (tools.run_checks and tools.judge_citation):
recompute-numbers: an arithmetic expression over numerals of the cited chunks, and the reported result. Every numeral, the result included, must be one the cited chunks' text contains, compared exactly as the decimal each writes, so the agent cannot supply a number the document does not, not even one a float cannot tell apart from a number it does. The expression is evaluated exactly; it passes when it falls within the rounding the reported result's own digits imply.rederive-maths: a step between equation chunks encoded as two sympy expressions over declared symbols,lhsandrhs, that the step claims are equal. It passes when sympy simplifies their difference to 0, fails when sympy shows the difference is never 0, and is anerrorotherwise.rederive-maths-numeric: run, as a check of its own, only whenrederive-mathserrs and the rubric declares it: the same encoding compared at 32 points drawn in the symbols' domains, from a generator seeded by the encoding. The seed and the points are recorded with the check.citation-support: the tool reads the cited source, finds the passage the agent quotes, and records the agent's judgement of whether it supports the node (judged); seecitation.
A proposal the runner cannot run, being malformed, of an unknown type, on a node the type does not
target, with a numeral the cited chunks do not contain, a second of its type on one node, or the same
step as another check on another target, is refused with a code and, where it can say, what to change
(fix). Two checks of one type on one node, or of one step however it is written, would fail or
pass together, so they must not count as two observations.
Each check run becomes an evidence node c-NNN of its check type, numbered in the order run,
joined to its target by the check edge target --observes--> c-NNN with the check type's
sensitivity and false_pass. Its statement comes from a fixed template, never from the agent.
attributes.check is the check record and attributes.observed is true for a pass and
false for a fail; an errored check has no observed, so it is recorded but changes no credence.
Each check's inputs, the tool's output and a log are written into checks/c-NNN/. The verdict on
each target is derived from its checks, never asked of the agent (assess): fails if any
failed, else holds if any passed, else undetermined if any ran, else not_assessed,
because no check type the runner implements may run on the node, or none was run.
Result
dataclass
¶
What a check found.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
str
|
The check type. |
target |
str
|
The node the check bears on. |
artifact |
Mapping[str, Any]
|
What the check was run against, as the check record's |
inputs |
Mapping[str, Any]
|
The exact thing evaluated. |
result |
str
|
|
detail |
str
|
What the tool found, in words. |
output |
Mapping[str, Any]
|
The tool's output, written to the check's directory. |
sources |
tuple[SourceAnchor, ...]
|
Anchors of the external works checked against. |
libraries |
tuple[str, ...]
|
The libraries the method used, named as in the run's versions. |
model |
Mapping[str, Any] | None
|
The model that took part, as the call reported it, or |
Source code in src/credencegraph_extract/checks.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
add_checks(graph, rubric, results, versions)
¶
Add each result to a graph as a check node with its check edge, numbered after the graph's checks.
A check node c-NNN takes the first number the graph does not have. Its attributes.check is
the check record, and attributes.observed is true for a pass and false for a fail; an
errored check has no observed. The edge target --observes--> c-NNN carries the check type's
sensitivity and false_pass. Verdicts are not set: assess derives them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
Graph
|
The graph. |
required |
rubric
|
Rubric
|
The rubric, which declares every result's check type. |
required |
results
|
Sequence[Result]
|
The results, in the order they are numbered. |
required |
versions
|
Mapping[str, str]
|
The versions of the code that ran the checks, by name, as |
required |
Returns:
| Type | Description |
|---|---|
Graph
|
The graph with the checks; the files of each check's directory, by path in the run; and one |
dict[str, bytes]
|
entry per check: its id, type, target and result. |
Source code in src/credencegraph_extract/checks.py
763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 | |
applicable(rubric, kind)
¶
Return the check types the model may propose for a node type: proposed by the runner, declared and targeting it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rubric
|
Rubric
|
The rubric. |
required |
kind
|
str
|
The node type. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
The check type names, in the order of |
Source code in src/credencegraph_extract/checks.py
151 152 153 154 155 156 157 158 159 160 161 | |
assess(graph, rubric)
¶
Set the verdict of every node the checks assess, from the checks that observe it.
A target's verdict comes from the results of the check nodes its observes relations lead to,
never from a model: fails, holds or undetermined as verdict gives it, else
not_assessed because no implemented check type may run on the node, or none was run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
Graph
|
The graph. |
required |
rubric
|
Rubric
|
The rubric. |
required |
Returns:
| Type | Description |
|---|---|
Graph
|
The graph with |
Source code in src/credencegraph_extract/checks.py
996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 | |
citation_refusal(graph, rubric, target, reference)
¶
Refuse a citation check the check pass would refuse, or one on a target whose citation check already passed or failed.
The target must be a node the rubric runs citation-support on, and it, or a node it is part of,
must cite the reference, a bibliography entry of the document. A citation check that passed or
failed stays: another on the same target is refused. One that erred moved no credence, so another
may follow it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
Graph
|
The graph. |
required |
rubric
|
Rubric
|
The rubric. |
required |
target
|
Any
|
The node the check bears on. |
required |
reference
|
Any
|
The id of the bibliography entry. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
The rejection, with its code, message, record and, where the refusal knows what to change, a |
dict[str, Any] | None
|
|
Source code in src/credencegraph_extract/checks.py
874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 | |
directory_digest(files)
¶
Return the digest of a check's directory: of one line <name> <digest> per file, sorted by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
files
|
Mapping[str, bytes]
|
The files by name. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The digest. |
Source code in src/credencegraph_extract/checks.py
552 553 554 555 556 557 558 559 560 561 562 | |
fix(code, record)
¶
Say what to change in a refused proposal, as an instruction to the model, or None beyond the error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str
|
The rejection code. |
required |
record
|
Any
|
The proposal. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The instruction. |
Source code in src/credencegraph_extract/checks.py
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | |
judged(graph, target, reference, observation, *, passage, supports, untied, model)
¶
Return the result of a citation check from what the tool read and what the agent judged.
The check is an error when the quoted passage is not in the source's text, or when the source
is not tied to the reference (untied says why): an errored check moves no credence. Otherwise
it passes when the agent judged that the passage supports the target, and fails when not.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
Graph
|
The graph. |
required |
target
|
str
|
The citing node. |
required |
reference
|
str
|
The bibliography entry. |
required |
observation
|
Mapping[str, Any]
|
What the tool read: |
required |
passage
|
str
|
The passage the agent quoted. |
required |
supports
|
bool
|
The agent's judgement. |
required |
untied
|
str | None
|
Why the source is not tied to the reference, or |
required |
model
|
str | None
|
The model the call reported. |
required |
Returns:
| Type | Description |
|---|---|
Result
|
The result. |
Source code in src/credencegraph_extract/checks.py
931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 | |
plain(value)
¶
Return a value as JSON gives it back: a graph's read-only mappings and its tuples become dicts and lists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
A value made of JSON types, mappings and sequences. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The value in JSON types only. |
Source code in src/credencegraph_extract/checks.py
493 494 495 496 497 498 499 500 501 502 | |
rerun(graph, rubric, check)
¶
Run a recorded deterministic check again, from the inputs its record holds.
The recorded inputs are checked as the run checked the proposal, numeral faithfulness included,
and evaluated by the current code; rederive-maths-numeric draws its points again from the
encoding's seed. A record that can no longer be run gives the result error, with the reason as
its detail.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
Graph
|
The graph the check node is in. |
required |
rubric
|
Rubric
|
The rubric of the run. |
required |
check
|
Node
|
A check node of a type in |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The check record the re-run gives, with the recorded |
dict[str, bytes]
|
by name. When the code and the record agree, the record equals |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the node is not a check of a type in |
Source code in src/credencegraph_extract/checks.py
505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 | |
run_maths(graph, rubric, proposals, versions)
¶
Check and run proposals of the maths check types, one tool call's worth, after the checks a graph has.
Each proposal is checked (_plan), in the order given, and is refused when it
repeats the target and type of a check the graph has or an earlier proposal, or the same step on
another target (_admit). A citation-support proposal is refused: the citation tool runs it.
The admitted ones run in the order given; a rederive-maths that errs is followed by its numeric
fallback when the rubric declares one. Verdicts are not set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
Graph
|
The graph, with the checks already run. |
required |
rubric
|
Rubric
|
The rubric. |
required |
proposals
|
Sequence[Any]
|
The proposals. |
required |
versions
|
Mapping[str, str]
|
The versions of the code that runs them. |
required |
Returns:
| Type | Description |
|---|---|
Graph
|
The graph with the new checks; the files of their directories; each new check's id, type, |
dict[str, bytes]
|
target, result and detail; and the refused proposals, each with its code, message and, where |
list[dict[str, Any]]
|
the refusal knows what to change, a |
Source code in src/credencegraph_extract/checks.py
830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 | |
targets(graph, rubric)
¶
Return the nodes the checks assess: document and analyst nodes of a type with assess = true.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
Graph
|
The graph. |
required |
rubric
|
Rubric
|
The rubric. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
Their ids, in document order. |
Source code in src/credencegraph_extract/checks.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
verdict(results)
¶
Return the verdict the results of a node's checks give, or None when no check ran.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
Sequence[str]
|
The results. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
|
Source code in src/credencegraph_extract/checks.py
1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 | |