popoto.recipes.provenance_journal¶
popoto.recipes.provenance_journal
¶
Provenance journal -- append-only entries with confirm/supersede/retract (#560).
An agent is told, in a thread, "Tom said the launch slipped to the 30th." Two turns later Tom says "the 30th is wrong, it's the 27th." Stored as ordinary memory rows, the second statement overwrites the first: the original words are gone, nobody recorded who said either one, and there is no way to ask what the agent believed last Tuesday.
This module is the substrate that fixes that. Every capture is an immutable
:class:JournalEntry; every correction is a new entry pointing at the one it
corrects. Membership in the live belief set comes from the validity indexes
(#580), not from a chain walk, so JournalEntry.query.filter(
validity__current=True) is the working set and superseded entries stay fully
readable by key and by validity__as_of=<earlier>.
::
from popoto.recipes import ProvenanceJournal, JournalEntry
first = ProvenanceJournal.append(
agent_id="agent-1",
speaker="tom",
turn_id="t-41",
verbatim="the launch slipped to the 30th",
statement="Launch date is the 30th",
subjects=["launch"],
).entry
ProvenanceJournal.supersede(
first,
agent_id="agent-1",
speaker="tom",
turn_id="t-43",
verbatim="actually the 30th is wrong, it's the 27th",
statement="Launch date is the 27th",
)
JournalEntry.query.filter(validity__current=True) # the correction only
ProvenanceJournal.annotations_for(first) # the correction, again
ProvenanceJournal.chain(first) # [first, correction]
Field choices and why¶
entry_id (AutoKeyField)
Immutable UUID identity, assigned at __init__ -- so the record's Redis
key is concrete before save, which is what lets the append-only guard
check the right key, and what makes two independent appends unable to
collide.
agent_id (KeyField)
Partition key, mirroring DefaultMemory. Required non-null by
:meth:ProvenanceJournal.append: a None renders the literal string
"None" into the record key.
captured_at (FloatField)
Wall-clock capture time of the source turn. Deliberately not named
ingested_at. ValidityField.on_save hardcodes the save clock
into its own ingested_at ZSET and ignores any model field, so two
fields under one name would silently disagree and downstream readers would
get different answers depending on which they read. The validity ingest
axis is always the save clock; this field is the source turn's clock.
turn_id (IndexedField)
"Everything from turn T" in one query.
speaker (IndexedField)
"Everything attributed to S" in one query. Attribution, not authentication.
verbatim (StringField)
The exact source span. Privacy-sensitive -- the reason NeverRecordMixin
is mandatory on this model rather than optional.
statement (StringField)
The atomic natural-language claim distilled from the span.
subjects (TagField)
Multi-value: one entry can concern several people or topics. Convention
over schema and explicitly not a security boundary, inheriting
TagField's framing verbatim.
stated (BooleanField)
Stated (True) vs inferred (False). Downstream conflict resolution uses it
for precedence; this module only stores it.
kind (IndexedField)
assert / confirm / supersede / retract, validated against
:attr:Defaults.JOURNAL_KINDS. Indexed so "every retraction" is one query.
target (IndexedField)
The annotated entry's Redis key. A plain indexed scalar rather than a
Relationship: the target is already addressed by Redis key, and
Relationship's lazy-load machinery plus its heavier save buys nothing
here. Annotations are 1:1 with a target by design -- a correction spanning
several claims is N annotation entries.
validity (ValidityField)
The valid_from / invalid_at / ingested_at axes. This module
owns the valid-time axis; the interval and chain state itself stays owned
by ValidityField as derived index state.
One record type, not two¶
Annotations are JournalEntry rows distinguished by kind + target,
not a separate model. Annotations must themselves be annotatable (a retraction
of a mistaken retraction; a confirmation of a supersession), the validity chain
hashes are keyed by Redis key and are type-agnostic, and a single keyspace
keeps the live-membership query one filter() instead of a union of two.
The cost is honest and paid for explicitly: kind/target consistency is
runtime validation (in :meth:JournalEntry.pre_save and again in the
pre-flight), not a type-system guarantee.
Querying, with one sharp edge¶
filter(validity__current=True) and filter(validity__as_of=t) are the
supported validity lookups. filter(validity=t) -- a bare exact-value filter
on the field -- silently returns nothing: ValidityField.filter_query
handles only the two suffixed params. target, kind, speaker and
turn_id collide with nothing (the reserved field names are only limit,
order_by and values).
Atomicity, stated precisely¶
supersede/retract queue the annotation's save and the target's interval
close into one MULTI/EXEC. The property that holds is: no
interleaving reader observes the annotation without the close. The property
that does not hold, and is not claimed, is rollback -- Redis MULTI/EXEC
does not roll back sibling commands when one command errors at execute time. A
command-level error inside EXEC can therefore leave the annotation appended
with the target still open. The pre-flight below exists to make that window
unreachable in practice; the residual is a documented boundary, not an
impossibility claim.
Immutability, stated precisely¶
It is an ORM-layer contract, enforced by AppendOnlyMixin against every
Python write path in models/base.py. It does not hold against a raw Redis
client. Two TOCTOU shapes are known and documented rather than closed: two
processes saving the same key concurrently, and two saves of the same key
queued onto one pipeline (the guard's EXISTS cannot see a queued-but-
unexecuted command). See :mod:popoto.fields.append_only.
What blocked content leaves behind¶
"Nothing is destroyed" is scoped to what gets stored. A capture blocked by
the never-record firewall is dropped before storage and leaves only a
content-free tombstone in the $NR: keyspace, which is not part of the
journal and is returned by no journal query. The journal-side signal is a gap
in turn_id coverage, nothing more; no placeholder entry is written.
Deliberately not included¶
EmbeddingField
It requires an embedding provider (an API key or a local Ollama), so it
cannot be a zero-configuration default, and similarity search over the
journal is not this module's job.
Do not subclass :class:JournalEntry¶
Popoto's ModelBase metaclass does not inherit Field attributes from
a base model class: class SubEntry(JournalEntry): pass produces a model
with an empty field set, so every record it writes persists nothing. This is
an ORM-level limitation, not a journal one, and it is why this module ships no
subclass extension seam.
Two consequences, both load-bearing:
- To extend the annotation vocabulary, call
:meth:
JournalEntry.register_kind-- it extends the vocabulary in place and records whether the new kind carries atargetand whether it closes its target's validity interval. - To get a different field set (an
EmbeddingField, say) or a separate keyspace, declare your ownModelwith the same mixins and the same field set and point a :class:ProvenanceJournalsubclass at it. Copying the field set is required, not stylistic. :meth:ProvenanceJournal._writerefuses anentry_modelthat is missing them, so the failure is loud rather than a keyspace full of empty records.
All numeric behavior is left to the field defaults and to
popoto.fields.constants.Defaults; this module pins no constants of its own
beyond the stream bound noted on the class.
AnnotationResult
dataclass
¶
Outcome of one journal write, readable without touching Redis.
This type exists specifically so the validity-coupling kill switch cannot reproduce the silent-no-op shape recorded in #588: a caller must be able to tell "the target was closed" from "the target was not closed" without issuing a read.
Attributes:
| Name | Type | Description |
|---|---|---|
entry |
JournalEntry
|
The appended :class: |
target_closed |
Optional[bool]
|
Whether the target's validity interval was closed by this call.
|
coupling_enabled |
bool
|
The state of
:attr: |
pipeline |
Optional[Any]
|
The caller-supplied pipeline, returned unexecuted, or
|
close_index |
Optional[int]
|
Index of the queued interval-close command in the
caller-supplied pipeline, so |
Source code in src/popoto/recipes/provenance_journal.py
JournalEntry
¶
Bases: AppendOnlyMixin, NeverRecordMixin, EventStreamMixin, Model
One immutable, fully attributed provenance record.
Both a capture and an annotation: kind="assert" with no target is
an original claim; confirm/supersede/retract with a target
annotate another entry. See the module docstring for the field rationale.
Write through :class:ProvenanceJournal rather than constructing entries
directly -- the façade owns the pre-flight validation and the
one-transaction annotate-and-close sequence, and is the documented seam a
future refactor stays behind.
Example::
JournalEntry.query.filter(turn_id="t-41")
JournalEntry.query.filter(kind="retract", validity__current=True)
Source code in src/popoto/recipes/provenance_journal.py
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 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 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 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 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 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 | |
register_kind(name, *, targetless=False, closing=False)
classmethod
¶
Extend the annotation vocabulary in place.
The extension seam for downstream modules that need kinds the core four do not cover -- a merge/equivalence kind, a queue-able kind, an exposure kind. Registration is process-global and additive: it never removes or reclassifies a core kind, so the vocabulary can only grow.
This is a registration call rather than a model subclass on purpose.
Popoto's ModelBase metaclass does not inherit Field attributes,
so a JournalEntry subclass has an empty field set and persists
nothing -- see the module docstring.
Registering also records the kind's behaviour, which a plain
vocabulary list cannot: without targetless/closing a new kind
would be permanently target-required and permanently inert for
membership::
JournalEntry.register_kind("consolidate", closing=True)
ProvenanceJournal.append(
agent_id="a1", kind="consolidate", target=old,
statement="folded into the canonical claim",
) # closes old's interval, exactly like a supersede
The example says consolidate, not merge, because the registry
below is process-global and kind names are reserved by whichever module
registers them first: recipes/reconciliation.py claims both
merge and disjoin at its own import time, with
closing=False. Written as register_kind("merge", closing=True)
this example raises ValueError in any process that has imported
that module. Pick a name your own module owns.
The reader rule this seam is built around is unchanged: an entry whose
kind a reader does not recognize is inert for membership --
never silently treated as a supersede or a retract.
.. important::
The registry is process-global and is not persisted. Reading
an entry with an unregistered kind is fine -- it reads back with its
stored kind and is inert for membership, per the reader rule.
But writing one is not: transfer/import_.py restores records
through instance.save(), which runs pre_save validation, so
importing entries that use a registered kind into a process that has
not re-registered it fails with ValueError and classifies those
records ERRORED. A restoring or importing process must call
the same register_kind calls before importing. (Found in
PR #589 review.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The new kind. Must be a non-empty string outside
:attr: |
required |
targetless
|
bool
|
True for an original-capture kind that carries no
|
False
|
closing
|
bool
|
True if an entry of this kind closes its target's
validity interval, like |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
On an empty name, a core kind, a |
Source code in src/popoto/recipes/provenance_journal.py
344 345 346 347 348 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 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 | |
journal_kinds()
classmethod
¶
Return the annotation vocabulary: the core four plus registrations.
:attr:Defaults.JOURNAL_KINDS is read at call time (so a runtime
assignment to Defaults is honored rather than frozen at import),
followed by every :meth:register_kind name in registration order.
Source code in src/popoto/recipes/provenance_journal.py
kind_is_targetless(kind)
classmethod
¶
True if kind is an original capture that carries no target.
Source code in src/popoto/recipes/provenance_journal.py
kind_is_closing(kind)
classmethod
¶
True if an entry of kind closes its target's validity interval.
Source code in src/popoto/recipes/provenance_journal.py
pre_save(*args, **kwargs)
¶
Validate kind and the kind/target combination, then save.
Defence in depth behind :class:ProvenanceJournal's pre-flight: the
façade validates before it issues or queues anything, and this catches
an entry constructed directly.
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/popoto/recipes/provenance_journal.py
ProvenanceJournal
¶
Stateless façade over :class:JournalEntry -- the only supported API.
Every method is a classmethod; there is no instance state.
To extend the annotation vocabulary, call
:meth:JournalEntry.register_kind -- not a model subclass. Popoto's
ModelBase metaclass does not inherit Field attributes, so a
JournalEntry subclass has an empty field set and persists nothing.
:meth:_write refuses an entry_model missing the journal field set for
exactly that reason; a separate keyspace means declaring your own Model
with the same mixins and the same fields.
Treating this as the sole read and write API is a stated contract, not a style preference: the single-record-type decision is cheaply reversible only while the keyspace is empty (validity and chain keys are namespaced per model, and every record's Redis key embeds its class name), so a future split has to stay behind this façade.
Source code in src/popoto/recipes/provenance_journal.py
575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 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 828 829 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 872 873 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 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 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 994 995 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 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 | |
append(*, agent_id, statement='', verbatim='', payload='', speaker=None, turn_id=None, subjects=None, stated=True, captured_at=None, at=None, kind='assert', target=None, claim_type=None, pipeline=None)
classmethod
¶
Append one capture to the journal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent_id
|
str
|
Partition key. Required and non-null -- a |
required |
payload
|
str
|
Structured bookkeeping a recipe writes about its own
decision. Exempt from the never-record firewall, so pass
only values Popoto itself generated -- ids, keys, counters. It
does not satisfy the "a record needs content" check below:
a targetless entry still needs a |
''
|
statement
|
str
|
The atomic claim. Required unless |
''
|
verbatim
|
str
|
The exact source span. |
''
|
speaker
|
Optional[str]
|
Who said it. Attribution, not authentication. |
None
|
turn_id
|
Optional[str]
|
Conversation turn the capture came from. |
None
|
subjects
|
Optional[Sequence[str]]
|
Subject tags. |
None
|
stated
|
bool
|
True when stated outright, False when inferred. |
True
|
captured_at
|
Optional[float]
|
Wall-clock time of the source turn. Defaults to now. |
None
|
at
|
Optional[float]
|
Valid-from instant for the entry. Defaults to now. Set at
construction rather than passed to the supersede script -- see
the |
None
|
kind
|
str
|
Normally left at |
'assert'
|
target
|
Optional[Union[str, JournalEntry]]
|
Only for a non- |
None
|
claim_type
|
Optional[str]
|
The claim's type, from
|
None
|
pipeline
|
Optional[Pipeline]
|
Optional caller pipeline. Must be transactional. When
supplied it is returned unexecuted on
:attr: |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
AnnotationResult |
AnnotationResult
|
with |
AnnotationResult
|
changes another entry's membership. |
|
AnnotationResult
|
caller supplied the pipeline (nothing has executed yet). |
Raises:
| Type | Description |
|---|---|
JournalBlockedError
|
If any content is refused by the never-record firewall. Nothing is issued or queued. |
ValueError
|
On a missing |
TypeError
|
If |
AppendOnlyViolation
|
If the record's Redis key already exists. |
Source code in src/popoto/recipes/provenance_journal.py
602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 | |
confirm(target, *, agent_id, statement='', verbatim='', speaker=None, turn_id=None, subjects=None, stated=True, captured_at=None, at=None, pipeline=None)
classmethod
¶
Append a confirm annotation. Membership is unaffected.
A confirmation is evidence, not a membership change: the target keeps
its open interval, and :attr:AnnotationResult.target_closed is always
False. Downstream readers use the annotation count as corroboration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
Union[str, JournalEntry]
|
The entry being confirmed, or its Redis key. |
required |
agent_id
|
str
|
See :meth: |
required |
statement
|
str
|
See :meth: |
''
|
verbatim
|
str
|
See :meth: |
''
|
speaker
|
Optional[str]
|
See :meth: |
None
|
turn_id
|
Optional[str]
|
See :meth: |
None
|
subjects
|
Optional[Sequence[str]]
|
See :meth: |
None
|
stated
|
bool
|
See :meth: |
True
|
captured_at
|
Optional[float]
|
See :meth: |
None
|
at
|
Optional[float]
|
Valid-from instant. Must not precede the target's stored
|
None
|
pipeline
|
Optional[Pipeline]
|
See :meth: |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
AnnotationResult |
AnnotationResult
|
with |
AnnotationResult
|
the caller supplied the pipeline (nothing has executed yet). |
Raises:
| Type | Description |
|---|---|
JournalBlockedError
|
If content is refused by the firewall. |
ValueError
|
On a nonexistent, unsaved or cross-agent target, a
backdated |
Source code in src/popoto/recipes/provenance_journal.py
supersede(target, *, agent_id, statement='', verbatim='', speaker=None, turn_id=None, subjects=None, stated=True, captured_at=None, at=None, pipeline=None)
classmethod
¶
Append a supersede annotation and close the target's interval.
The annotation entry and the target's interval close are queued into
one MULTI/EXEC, so no interleaving reader sees the annotation
without the close. Rollback is not claimed -- see the module docstring.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
Union[str, JournalEntry]
|
The entry being corrected, or its Redis key. |
required |
agent_id
|
str
|
See :meth: |
required |
statement
|
str
|
The corrected claim. |
''
|
verbatim
|
str
|
The exact words of the correction. |
''
|
speaker
|
Optional[str]
|
See :meth: |
None
|
turn_id
|
Optional[str]
|
See :meth: |
None
|
subjects
|
Optional[Sequence[str]]
|
See :meth: |
None
|
stated
|
bool
|
See :meth: |
True
|
captured_at
|
Optional[float]
|
See :meth: |
None
|
at
|
Optional[float]
|
The instant the correction becomes true, and the instant the
target's interval closes. Defaults to now. Must not precede
the target's stored |
None
|
pipeline
|
Optional[Pipeline]
|
See :meth: |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
AnnotationResult |
AnnotationResult
|
|
AnnotationResult
|
switch is off, or when the target was already closed by a |
|
AnnotationResult
|
concurrent annotation (which is correct: both annotations are real |
|
AnnotationResult
|
provenance, one close applies). It is |
|
AnnotationResult
|
supplied the pipeline -- nothing has executed, so no truthful |
|
AnnotationResult
|
answer exists yet; read |
|
AnnotationResult
|
|
Raises:
| Type | Description |
|---|---|
JournalBlockedError
|
If content is refused by the firewall. The target is not closed and no chain link is written. |
ValueError
|
On a nonexistent, unsaved or cross-agent target, a
backdated |
Source code in src/popoto/recipes/provenance_journal.py
retract(target, *, agent_id, statement='', verbatim='', speaker=None, turn_id=None, subjects=None, stated=True, captured_at=None, at=None, pipeline=None)
classmethod
¶
Append a retract annotation and close the target's interval.
Mechanically identical to :meth:supersede; the difference is
semantic. A supersession replaces a claim with a better one, a
retraction withdraws it with no replacement, and both remove the target
from live membership while leaving it fully readable historically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
Union[str, JournalEntry]
|
The entry being withdrawn, or its Redis key. |
required |
agent_id
|
str
|
See :meth: |
required |
statement
|
str
|
Optional -- a retraction may be wordless. |
''
|
verbatim
|
str
|
See :meth: |
''
|
speaker
|
Optional[str]
|
See :meth: |
None
|
turn_id
|
Optional[str]
|
See :meth: |
None
|
subjects
|
Optional[Sequence[str]]
|
See :meth: |
None
|
stated
|
bool
|
See :meth: |
True
|
captured_at
|
Optional[float]
|
See :meth: |
None
|
at
|
Optional[float]
|
The instant the target stops being true. Defaults to now. |
None
|
pipeline
|
Optional[Pipeline]
|
See :meth: |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
AnnotationResult |
AnnotationResult
|
see :meth: |
Raises:
| Type | Description |
|---|---|
JournalBlockedError
|
If content is refused by the firewall. |
ValueError
|
On a nonexistent, unsaved or cross-agent target, a
backdated |
Source code in src/popoto/recipes/provenance_journal.py
annotations_for(entry)
classmethod
¶
Return every entry annotating entry, in one filter() call.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entry
|
Union[str, JournalEntry]
|
The annotated entry, or its Redis key. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
Union[QueryBuilder, list[JournalEntry]]
|
Matching :class: |
Union[QueryBuilder, list[JournalEntry]]
|
Empty for an unsaved or unannotated entry. |
Source code in src/popoto/recipes/provenance_journal.py
chain(entry)
classmethod
¶
Return the supersession chain through entry, oldest first.
A display and replay-verification read, not the membership query:
live membership comes from
filter(validity__current=True) with no chain walk at all. This
walks the validity chain hashes from any member outward, so the chain
is recoverable from its head, its tail, or anywhere in between.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
entry
|
Union[str, JournalEntry]
|
Any member of the chain, or its Redis key. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
list[Any]
|
:class: |
list[Any]
|
|
|
list[Any]
|
or an unresolvable key. |
Source code in src/popoto/recipes/provenance_journal.py
validate_kind_and_target(model, kind, target)
¶
Check one kind/target pair against model's vocabulary.
Shared by :meth:JournalEntry.pre_save and :class:ProvenanceJournal's
pre-flight so the two cannot drift apart.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Type[JournalEntry]
|
The :class: |
required |
kind
|
Any
|
The candidate kind. |
required |
target
|
Any
|
The candidate target Redis key, or |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, Optional[str]]
|
The validated |
Raises:
| Type | Description |
|---|---|
ValueError
|
On an out-of-vocabulary kind or an inconsistent pairing. |