Desk door: raised_at nil outside UTC year 0..9999; retraction in the non-decider test; doc and comment fixes

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Eureka 2026-11-11 21:16:52 +00:00
commit 7620875596
4 changed files with 37 additions and 11 deletions

View file

@ -277,7 +277,7 @@ fn the_binary_serves_both_doors_and_survives_restart() {
let catalog = format!("{:?}", exchange(&desk, &framed(&catalog_request())).expect("a catalog"));
assert!(catalog.contains("huginn.desk_request.v1") && catalog.contains("huginn.desk_response.v1"), "{catalog}");
assert!(!catalog.contains("huginn.mind_request.v1"), "{catalog}");
// The reads answer, store nothing, and carry the whole record to a subject the deciders do not name.
// The reads answer and store nothing; a decider reading its own list is told the ids.
let (list, listed_at) = match ask(&desk, "m-r1", &forks_request("x", &["x"])) {
DeskResponse::Forks { list, as_of } => (list, as_of),
other => panic!("{other:?}"),

View file

@ -796,6 +796,18 @@ mod tests {
answer(&mut mind, BEN, &deciders, &fork(1), &hash, Some("Ben's note"));
answer(&mut mind, CORA, &deciders, &fork(1), &hash, Some("Cora's note"));
answer(&mut mind, BEN, &deciders, &fork(1), &hash, Some("Ben again"));
// Ben retracts Anna's first answer: a Retraction row, so the non-decider view must null it too.
let retraction = ForkAnswerRequest {
schema_version: RequestSchema::V0,
fork_id: fork(1),
options_hash: hash.clone(),
answer: None,
retracted: true,
retracts: Some("n1".into()),
answered_at: "2026-09-16T11:00:00Z".into(),
request_id: request_id(),
};
mind.desk_answer(&list(&deciders), s(BEN), DeskAuthority::Member, retraction, now());
mind
}
@ -826,7 +838,8 @@ mod tests {
assert!(card.deciders.is_empty(), "withheld, never no deciders");
assert_eq!(card.decider_count, 2);
}
assert_eq!(read.record.answers.len(), 4);
assert_eq!(read.record.answers.len(), 5);
assert!(read.record.answers.iter().any(|shown| shown.outcome == "Retraction"), "the retraction row is there and nulled too");
assert!(read.record.answers.iter().all(|shown| shown.answerer.is_none()), "the key is written, null");
assert_eq!(read.record.answerer_count, 3, "Anna, Ben and the refused Cora");
// The other fork has no answers: zero answerers.
@ -843,7 +856,7 @@ mod tests {
assert_eq!(as_decider.card.deciders, [ANNA, BEN]);
assert_eq!(as_decider.card.decider_count, 2);
let named: Vec<_> = as_decider.record.answers.iter().map(|shown| shown.answerer.as_deref().unwrap()).collect();
assert_eq!(named, [ANNA, BEN, CORA, BEN]);
assert_eq!(named, [ANNA, BEN, CORA, BEN, BEN]);
assert_eq!(as_decider.record.answerer_count, 3);
// Nothing else differs between the two views.
let blind = ForkEntry {
@ -928,6 +941,19 @@ mod tests {
assert_eq!(raised_at(&mind, &id).as_deref(), Some("2026-11-08T14:20:05Z"), "the source's time, in UTC, not the import's");
}
/// CultLib's instant has four year digits: a time whose UTC year leaves 0..=9999 is served nil.
#[test]
fn an_import_time_outside_year_0_to_9999_in_utc_is_nil() {
for committed_at in ["0000-01-01T00:00:00+05:00", "9999-12-31T23:59:59-05:00"] {
let mut mind = seeded();
let id = imported_question(&mut mind, committed_at);
assert_eq!(raised_at(&mind, &id), None, "{committed_at}");
}
let mut mind = seeded();
let id = imported_question(&mut mind, "9999-12-31T23:59:59Z");
assert_eq!(raised_at(&mind, &id).as_deref(), Some("9999-12-31T23:59:59Z"));
}
#[test]
fn an_unparseable_import_time_is_nil() {
let mut mind = seeded();

View file

@ -77,12 +77,14 @@ impl<'i> Docs<'i> {
/// When the document was first admitted, in UTC: an imported document's source receipt
/// (`imported_from.committed_at`) wins over this mind's own `admitted_at`. `None` when the
/// document is not held at this snapshot or the time does not parse as RFC3339 (an import's
/// `committed_at` is only checked as non-empty text at admission).
/// `committed_at` is only checked as non-empty text at admission). Also `None` when the UTC year is
/// outside 0..=9999: CultLib's instant pattern has four year digits, and a local time near the edge
/// can convert out of range.
pub(crate) fn first_admitted_at(&self, kind: PipelineKind, id: &str) -> Option<chrono::DateTime<chrono::Utc>> {
let row = self.image.id_of(kind, id).filter(|row| self.visible(*row))?;
let admission = &self.image.row(row).view.admission;
let text = admission.provenance.imported_from.as_ref().map_or(admission.admitted_at.as_str(), |source| source.committed_at.0.as_str());
chrono::DateTime::parse_from_rfc3339(text).ok().map(|time| time.with_timezone(&chrono::Utc))
chrono::DateTime::parse_from_rfc3339(text).ok().map(|time| time.with_timezone(&chrono::Utc)).filter(|time| (0..=9999).contains(&chrono::Datelike::year(time)))
}
pub(crate) fn find(&self, kind: PipelineKind, id: &str) -> Option<&PipelineDocument> {

View file

@ -10,11 +10,9 @@ planned and not built: the listing gate that decides which forks a reader sees (
`cut-desk-feed-listing` in the `eureka-substrate` campaign).
**Not live: the listing gate.** On `main` today every showable question is returned to every
reader, whatever the call's `deciders` say (pinned by
`the_whole_record_comes_back_whoever_the_deciders_list_leaves_out` in `desk_wire/reads.rs`).
The default of not listed, described under Listing below, holds only once `cut-desk-feed-listing`
lands. Until then, neither Bifrost's receiver nor the ops root-run (`desk-door-ops-root-run`) may
go live on a Mind that holds private questions.
reader, whatever the call's `deciders` say. The default of not listed, described under Listing below,
holds only once `cut-desk-feed-listing` lands. Until then, neither Bifrost's receiver nor the ops
root-run (`desk-door-ops-root-run`) may go live on a Mind that holds private questions.
This page is the wire contract for the consumer, Bifrost's `UnixSocketDeskDoor` (Bifrost PR #67,
`docs/desk-feed-design.md`). The golden bytes are in `crates/huginn-mind/tests/fixtures/desk-feed/`.
@ -206,7 +204,7 @@ An empty list is never served in place of a failure. `open_count: 0` means zero
## Card fields
`raised_at` is a required card key whose value is an RFC3339 string or nil (CultLib #115, `af914253`).
Nil means unknown. A string is the question's first-admission time, which never moves. It is outside
Nil means unknown. A string is the question's first-admission time, which never moves: a UTC `Z` instant at seconds resolution (the form CultLib requires), and nil when the time is unknown, does not parse, or its UTC year is outside 0..9999. It is outside
`options_hash`, which keeps its five members, so the hash vectors do not change. Huginn derives it
from the question's admission: the `committed_at` of the receipt that first admitted the question, or
for an imported question the source mind's `committed_at` (`imported_from.committed_at`). A value that