tilie_server.routers.claim_provenance#
The MatchClaims’ provenance: read for given MatchClaims, and a belief written.
A MatchClaim’s provenance is TimeToShare’s provenance entry: how it was made
(paradata) and who believes it. The editor holds a MatchClaim table for its
session only and never writes it; it asks the server for the provenance of
the MatchClaims it shows (POST /api/match-claims/provenance) and, when
its user states a belief in one, for the table that records it
(POST /api/match-claims/belief), which the user saves in the place of
the old file. The repository’s decisions/0031-match-claim-provenance.md
fixes both routes.
Both requests are a JSON object of parameters behind its length, followed
by the request of POST /api/match-claims unchanged: the manifest file
and the Parquet file the editor holds. The table is checked against the
manifest as that route checks it.
- tilie_server.routers.claim_provenance.PARQUET_MEDIA_TYPE = 'application/vnd.apache.parquet'#
The media type of the belief route’s answer, a Parquet file.
- tilie_server.routers.claim_provenance.PROVENANCE_PARAMETERS = ('claims',)#
The parameters of the provenance route.
- tilie_server.routers.claim_provenance.BELIEF_PARAMETERS = ('claim', 'actor', 'belief', 'date')#
The parameters of the belief route, in the order they are checked.
- tilie_server.routers.claim_provenance.provenance_model()[source]#
Return timetoalign’s
Provenance,actor_iriandbelief_context.
- tilie_server.routers.claim_provenance.split_parameters(body, names, optional=())[source]#
Split a request into its parameters and what follows them.
- Parameters:
body (bytes) – The request’s body: the parameters’ length in bytes (a little-endian 32-bit integer), the parameters as a JSON object in UTF-8, then the rest of the request (for the MatchClaim routes the body
POST /api/match-claimstakes).names (tuple[str, ...]) – The parameters the route requires.
optional (tuple[str, ...]) – The parameters the route takes besides, each of which a request may leave out.
- Raises:
Refusal – 422, if the body is shorter than its prefix or than the length it states, the parameters are no JSON object, or one is missing or unknown (at the parameter’s name).
- Return type:
- tilie_server.routers.claim_provenance.read_request(body, names, bounds)[source]#
The parameters, the posted table (read within
bounds), the manifest (file form),timetoshare.tables, timetoalign’sMatchClaimFieldand the table as timetoalign gives it back, once the table’s checks accept the table.
- tilie_server.routers.claim_provenance.claim_rows(table)[source]#
Each MatchClaim’s row, by its ID (the checks hold every ID once).
- tilie_server.routers.claim_provenance.row_of(rows, claim, path)[source]#
The row of the MatchClaim
claim.
- tilie_server.routers.claim_provenance.provenance_answer(body, bounds)[source]#
The provenance of the MatchClaims a request names, its table read within
bounds.- Returns:
{"claims": [{"id", "provenance"}]}in the order the request names them,provenancethe entry the MatchClaim is read with (its row’s own, else the file’s), its absent members left out, orNonefor a MatchClaim stated without one. Each belief’s actor is the IRI timetoalign compares it as, expanded under the manifest’s@context, as the MatchClaims route answers actors.- Raises:
Refusal – As
read_request(); 422 ifclaimsis no list, or names a MatchClaim the table lacks (at["claims", index]); astilie_server.claim_columns.manifest_bundle().- Parameters:
body (bytes)
bounds (TableBounds)
- Return type:
- tilie_server.routers.claim_provenance.checked_actor(actor)[source]#
An actor a request names: a non-empty string.
- tilie_server.routers.claim_provenance.checked_date(date)[source]#
The day a request states for a belief: a calendar date written
YYYY-MM-DD.
- tilie_server.routers.claim_provenance.checked_belief(parameters, rows)[source]#
The believed MatchClaim’s ID, the actor, the belief and its date.
- Raises:
Refusal – 422 at the parameter at fault: a MatchClaim the table lacks, an actor that is no non-empty string, a belief that is none of TimeToShare’s three words, a date that is no calendar date written
YYYY-MM-DD.- Parameters:
- Return type:
- tilie_server.routers.claim_provenance.believed_table(table, believed)[source]#
The posted table with the provenance of the table timetoalign wrote.
believedis the posted table’s MatchClaims as timetoalign holds them after recording a belief: the same rows in the same order, the columns the table type declares. Its provenance column replaces the posted one, and the file’s provenance for every row is the onebelievedstates, if any (timetoalign keeps a shared entry only while it is every row’s). Every other column, the columns the table type does not declare included, and the file’s other metadata are kept.
- tilie_server.routers.claim_provenance.succeeding(tables, old, new)[source]#
Refuse
newunless it succeedsold.Every MatchClaim of
oldis innewwith the same timelines, events, anchors and every other value but its provenance (TimeToShare’ssuccession_problems).
- tilie_server.routers.claim_provenance.belief_answer(body, bounds)[source]#
The Parquet file of the posted table with the posted belief recorded, the table read within
bounds.timetoalign records the belief: the manifest is read as an
AlignmentBundle, the table’s MatchClaims are added to it, and itsadd_match_claim_beliefreplaces the actor’s earlier belief in the MatchClaim, actors compared as IRIs under every prefix the manifest’s@contextdeclares. The new table is checked against the manifest as a posted one is, and against the posted table by the succession rule, before it is written.- Raises:
Refusal – As
read_request(),checked_belief()andtilie_server.claim_columns.manifest_bundle(); 422 with timetoalign’s message if it refuses the MatchClaims or the belief, with the problems if the new table fails its checks or the succession rule.- Parameters:
body (bytes)
bounds (TableBounds)
- Return type:
- tilie_server.routers.claim_provenance.match_claim_provenance(body, bounds)[source]#
Answer the provenance of the MatchClaims named, of the posted table.
The body is the parameters’ length in bytes (a little-endian 32-bit integer), the parameters
{"claims": [<MatchClaim ID>, …]}as JSON, then the bodyPOST /api/match-claimstakes. The answer is JSON{"claims": [{"id", "provenance"}]}. Refusals answer as that route’s, the parameters’ at their name.- Parameters:
body (Annotated[bytes, Depends(dependency=~tilie_server.manifests.posted_body, use_cache=True, scope=function)])
bounds (Annotated[TableBounds, Depends(dependency=~tilie_server.routers.match_claims.table_bounds, use_cache=True, scope=None)])
- Return type:
Response
- tilie_server.routers.claim_provenance.match_claim_belief(body, bounds)[source]#
Answer the posted table with an actor’s belief in one MatchClaim.
The body is the parameters’ length in bytes (a little-endian 32-bit integer), the parameters
{"claim", "actor", "belief", "date"}as JSON, then the bodyPOST /api/match-claimstakes. The answer is the newmatch_claims.parquet; nothing is written on the server. Refusals answer as that route’s, the parameters’ at their name.- Parameters:
body (Annotated[bytes, Depends(dependency=~tilie_server.manifests.posted_body, use_cache=True, scope=function)])
bounds (Annotated[TableBounds, Depends(dependency=~tilie_server.routers.match_claims.table_bounds, use_cache=True, scope=None)])
- Return type:
Response