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_iri and belief_context.

Raises:

Refusal – 501, if the installed timetoalign lacks them.

Return type:

tuple[Any, Callable[[str, Any], str], Callable[[Any], Any]]

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-claims takes).

  • 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:

tuple[dict[str, Any], bytes]

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’s MatchClaimField and the table as timetoalign gives it back, once the table’s checks accept the table.

Raises:

Refusal – As split_parameters(), and as the table route for the rest of the body.

Parameters:
Return type:

tuple[dict[str, Any], Any, Mapping[str, Any], Any, Any, Any]

tilie_server.routers.claim_provenance.claim_rows(table)[source]#

Each MatchClaim’s row, by its ID (the checks hold every ID once).

Parameters:

table (Any)

Return type:

dict[str, int]

tilie_server.routers.claim_provenance.row_of(rows, claim, path)[source]#

The row of the MatchClaim claim.

Raises:

Refusal – 422 at path if claim is no ID of the table.

Parameters:
Return type:

int

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, provenance the entry the MatchClaim is read with (its row’s own, else the file’s), its absent members left out, or None for 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 if claims is no list, or names a MatchClaim the table lacks (at ["claims", index]); as tilie_server.claim_columns.manifest_bundle().

Parameters:
Return type:

dict[str, Any]

tilie_server.routers.claim_provenance.checked_actor(actor)[source]#

An actor a request names: a non-empty string.

Raises:

Refusal – 422 at ["actor"] otherwise.

Parameters:

actor (Any)

Return type:

str

tilie_server.routers.claim_provenance.checked_date(date)[source]#

The day a request states for a belief: a calendar date written YYYY-MM-DD.

Raises:

Refusal – 422 at ["date"] otherwise.

Parameters:

date (Any)

Return type:

str

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:

tuple[str, str, str, str]

tilie_server.routers.claim_provenance.believed_table(table, believed)[source]#

The posted table with the provenance of the table timetoalign wrote.

believed is 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 one believed states, 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.

Parameters:
Return type:

Any

tilie_server.routers.claim_provenance.succeeding(tables, old, new)[source]#

Refuse new unless it succeeds old.

Every MatchClaim of old is in new with the same timelines, events, anchors and every other value but its provenance (TimeToShare’s succession_problems).

Raises:

Refusal – 422 with every breach as the table problems, message the first one’s.

Parameters:
Return type:

None

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 its add_match_claim_belief replaces the actor’s earlier belief in the MatchClaim, actors compared as IRIs under every prefix the manifest’s @context declares. 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() and tilie_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:
Return type:

bytes

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 body POST /api/match-claims takes. 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 body POST /api/match-claims takes. The answer is the new match_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