Graph tools
The tools an agent calls to build a graph: classify, add premises, and finish a run.
Each tool is one write to a run directory (session.write): it takes the run's lock, applies its
operation to the current state, and is logged. A tool never writes graph JSON and never sets a credence:
records go through the assembler, so every base and strength is the rubric's. A refused record is a
result, not an error: it comes back with its code, the core's message and a fix saying what to
change, and is kept in the run's rejections; the agent may simply call again.
classifytypes, splits and links chunks. A node already typed may be typed again, which first returns it to unassigned (assemble), but not once a check targets it: a failed check cannot be escaped by making its node a type no check applies to. A chunk already split cannot be split again.add_premisesadds the implicit premises of conclusions, as the premise records do.run_checkschecks and runs proposals of the maths check types (checks.run_maths), and adds a check node for each that runs, with its files in the run. A check is never withdrawn or run again on its target, nor run again on another target as another encoding of the same step.judge_citationreads a citation's source itself, finds the agent's passage in it, and records a check that passes or fails as the agent judged only when the source is tied to the reference (citation); any other source gives anerror, which moves no credence.finish_runderives every assessed node's verdict from the checks that observe it, runs the core's check at theassessedlevel with rubric credences, and marks the run finished; the run's outputs are written then. Any later write marks it unfinished again.
start_run and get_state are in session.
add_premises(run, records, *, model, agent=None, note=None)
¶
Add the implicit premises of conclusions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run
|
Path
|
The run directory. |
required |
records
|
Sequence[Any]
|
Premise records, each |
required |
model
|
str
|
The model making the call, as the harness reports it. |
required |
agent
|
str | None
|
A name for the agent. |
None
|
note
|
str | None
|
Free text kept with the call. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
|
dict[str, Any]
|
refused record with its code and message; and |
Raises:
| Type | Description |
|---|---|
RunError
|
If the rubric takes no premises, or the call as a whole is refused. |
Source code in src/credencegraph_extract/tools.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | |
checked(graph)
¶
Return the nodes a check targets: the sources of observes relations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
Graph
|
The graph. |
required |
Returns:
| Type | Description |
|---|---|
set[str]
|
Their ids. |
Source code in src/credencegraph_extract/tools.py
143 144 145 146 147 148 149 150 151 152 | |
classify(run, records, *, model, agent=None, note=None)
¶
Type, split and link chunks of a run's document.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run
|
Path
|
The run directory. |
required |
records
|
Sequence[Any]
|
Classify records, each |
required |
model
|
str
|
The model making the call, as the harness reports it. |
required |
agent
|
str | None
|
A name for the agent, for runs with several. |
None
|
note
|
str | None
|
Free text kept with the call, never used in inference. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
|
dict[str, Any]
|
message and |
Raises:
| Type | Description |
|---|---|
RunError
|
If the call as a whole is refused ( |
Source code in src/credencegraph_extract/tools.py
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 | |
finish_run(run, *, model, agent=None, note=None)
¶
Derive the verdicts, check the graph with the core, and write the run's outputs.
It may be called again after later writes, which mark the run unfinished.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run
|
Path
|
The run directory. |
required |
model
|
str
|
The model making the call, as the harness reports it. |
required |
agent
|
str | None
|
A name for the agent. |
None
|
note
|
str | None
|
Free text kept with the call. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
|
dict[str, Any]
|
credences, and |
Source code in src/credencegraph_extract/tools.py
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 | |
judge_citation(run, target, reference, source, passage, *, supports, model, agent=None, note=None, fetcher=fetch)
¶
Record a citation check: read the source, find the passage, and decide whether the source is tied to the reference.
The tool reads the source itself; it never takes the text from the agent. A local source is a file
of the run's copy of the cited works; a URL is fetched under the fetch policy (fetch). What was
read (the file or URLs, the digests of the bytes and of their text, where the passage is, and what
ties the source to the reference) is logged with the call, not the bytes, which are kept in
sources/ only when the run stores its sources. The check passes or fails, as the agent judged,
only when the passage is in the source and the source is tied to the reference
(citation.tie); otherwise it is an error, which moves no credence. A target whose citation
check passed or failed takes no other; one whose checks erred may be checked again.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run
|
Path
|
The run directory. |
required |
target
|
str
|
The citing node. |
required |
reference
|
str
|
The id of the bibliography entry ( |
required |
source
|
str
|
A file of the run's cited works, by name or path, or an |
required |
passage
|
str
|
The passage of the source the target rests on, verbatim. |
required |
supports
|
bool
|
Whether the passage supports the target. |
required |
model
|
str
|
The model making the call, as the harness reports it. |
required |
agent
|
str | None
|
A name for the agent. |
None
|
note
|
str | None
|
Free text kept with the call. |
None
|
fetcher
|
Callable[[str], Any]
|
Fetches a URL under the fetch policy; |
fetch
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
|
dict[str, Any]
|
|
Raises:
| Type | Description |
|---|---|
RunError
|
If an argument is not of its type, or the call as a whole is refused. |
Source code in src/credencegraph_extract/tools.py
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 | |
run_checks(run, proposals, *, model, agent=None, note=None)
¶
Check and run proposals of the maths check types: recompute-numbers and rederive-maths.
A check, once run, is part of the run: it cannot be withdrawn or run again on the same target, nor run again on another target in another encoding of the same step. The versions of the code that runs the checks are recorded with the call.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run
|
Path
|
The run directory. |
required |
proposals
|
Sequence[Any]
|
Check proposals, each |
required |
model
|
str
|
The model making the call, as the harness reports it. |
required |
agent
|
str | None
|
A name for the agent. |
None
|
note
|
str | None
|
Free text kept with the call. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
|
dict[str, Any]
|
that errs is followed by its numeric fallback when the rubric declares one); and |
dict[str, Any]
|
each refused proposal with its code, message and |
Raises:
| Type | Description |
|---|---|
RunError
|
If the call as a whole is refused. |
Source code in src/credencegraph_extract/tools.py
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | |