feat(calendar): NIP-52 semantics, educational attributes, calendars/RSVPs, author info, hidden sources #1

Merged
laoc merged 9 commits from feat/calendar-nip52-semantics into main 2026-11-03 22:12:41 +00:00
Owner

search_calendar_events aligned with NIP-52 and the updated edufeed calendar wiki / edufeed-app v0.14.

Semantics the model no longer has to know: effectiveEnd (NIP-52 end rules, same as the relay index), allDay, lastDay, endTzid inheritance, days (D tags), explicit inclusive/strict bounds on the time-range parameters.

Educational attributes (registrationRequired, price/free, attendanceMode, educationalLevel with labels), namedParticipants, communities, calendarRefs — read with exactly the rules of edufeed-app's calendar-attributes.js (first valid tag wins, plain-decimal price grammar, attendance mode by last path segment, concept label de → en → first → URI tail). New filters free, registrationRequired, attendanceMode, educationalLevel, references (#a), participants (#p); these need the relay branch for the facets.

All four kinds: 31924 calendars (calendars) and 31925 RSVPs (rsvps, invalid status ignored, fb dropped when declined, a must reference an event) instead of being silently dropped; kinds restricted to NIP-52 kinds; limit caps the whole result; total counts all items.

Authors and hidden sources: every event carries author {pubkey, name, bot} from the relay's kind-0 index (cached, short negative TTL); CALENDAR_HIDDEN_PUBKEYS (same entry forms as the app) hides bulk mirrors by default, includeHiddenSources: true returns them, the response reports the count. A bot flag alone hides nothing.

Bug fixed: the client re-applied #g locally as an exact match while the relay answers it as a prefix, so geohash queries discarded nearly every result.

Depends on nope-relay feat/calendar-nip52-end-and-attributes for the attribute/reference facets; works against today's relay otherwise.

🤖 Generated with Claude Code

`search_calendar_events` aligned with NIP-52 and the updated edufeed calendar wiki / edufeed-app v0.14. **Semantics the model no longer has to know**: `effectiveEnd` (NIP-52 end rules, same as the relay index), `allDay`, `lastDay`, `endTzid` inheritance, `days` (`D` tags), explicit inclusive/strict bounds on the time-range parameters. **Educational attributes** (`registrationRequired`, `price`/`free`, `attendanceMode`, `educationalLevel` with labels), `namedParticipants`, `communities`, `calendarRefs` — read with exactly the rules of edufeed-app's `calendar-attributes.js` (first valid tag wins, plain-decimal price grammar, attendance mode by last path segment, concept label de → en → first → URI tail). New filters `free`, `registrationRequired`, `attendanceMode`, `educationalLevel`, `references` (`#a`), `participants` (`#p`); these need the relay branch for the facets. **All four kinds**: 31924 calendars (`calendars`) and 31925 RSVPs (`rsvps`, invalid status ignored, `fb` dropped when declined, `a` must reference an event) instead of being silently dropped; `kinds` restricted to NIP-52 kinds; `limit` caps the whole result; `total` counts all items. **Authors and hidden sources**: every event carries `author {pubkey, name, bot}` from the relay's kind-0 index (cached, short negative TTL); `CALENDAR_HIDDEN_PUBKEYS` (same entry forms as the app) hides bulk mirrors by default, `includeHiddenSources: true` returns them, the response reports the count. A `bot` flag alone hides nothing. **Bug fixed**: the client re-applied `#g` locally as an exact match while the relay answers it as a prefix, so geohash queries discarded nearly every result. Depends on nope-relay `feat/calendar-nip52-end-and-attributes` for the attribute/reference facets; works against today's relay otherwise. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
search_calendar_events returned raw `start`/`end` tags and nothing else, so
a model had to know NIP-52 to read them: `end` is exclusive and omitted for
one-day and instantaneous events, a legacy `end == start` is a one-day
event, `end_tzid` inherits `start_tzid`. Every event now carries
`effectiveEnd` (Unix seconds when it is over, the same rule nope-relay
indexes), `allDay` and, for 31922, the inclusive `lastDay`; the tool
description spells the rules out.

The NIP-52-Edufeed attributes from the "Calendar events in edufeed" wiki
article are read with its rules (first tag wins, literal true/false,
numeric price with decimal comma, tolerant attendance-mode URIs, concept
triples with German labels) into `attributes`, plus `namedParticipants`
(`participant` tags) and `communities` (`h` tags). New filter parameters
`free`, `registrationRequired`, `attendanceMode` and `educationalLevel`
map to the relay's calendar facets (#price, #registrationRequired,
#eventAttendanceMode, #educationalLevel:id); an untagged event matches
none of them, since absence is "no statement".

Every event gets `author` {pubkey, name, bot} from the calendar relay's
kind-0 index, cached per author (misses included) for 10 minutes, so a
model can tell an event mirror from an organisation. On the production
relay 226 of the 250 newest calendar events come from the Bildungsserver
mirror; CALENDAR_HIDDEN_PUBKEYS (hex, npub or kind-30000 naddr entries,
as in edufeed-app) hides such bulk sources by default — results are
over-fetched to the relay page size and cut back to `limit` — and
`includeHiddenSources: true` brings them back. The response reports
`hiddenSources: {hidden, included, note}`. A `bot` flag alone hides
nothing: which sources flood a calendar is the operator's call.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
search_calendar_events silently dropped kinds 31924/31925 (the transform
only knew events with a `start`). Calendars now come back in `calendars`
(title, description, `eventRefs` in tag order) and RSVPs in `rsvps`
(status, `freeBusy` — dropped when declined, `eventRef`, `eventId`,
`eventAuthor`, note); an RSVP without a valid status is ignored, as NIP-52
requires. `kinds` is restricted to the four NIP-52 kinds. New `references`
(`#a`) and `participants` (`#p`) filters answer "who RSVP'd to event X",
"which calendars list X" and "events naming participant Y"; events expose
`calendarRefs`, the kind-31924 calendars they ask to be included in
(collaborative calendar requests). These need the relay's reference
facets (nope-relay feat/calendar-nip52-end-and-attributes).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
With kinds [31925] the handler returned every RSVP on the relay page
(up to 250, since the hidden-source drop over-fetches) and reported
total: 0 because only events were counted. The search core now lives in
src/calendar/search.ts (unit-testable with a fake client): `limit` caps
events, calendars and RSVPs alike, `total` is the number of items
returned across all three, and the tool handler only adds the relay
diagnostics.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The client re-applied `#g` locally through nostr-tools' matchFilters (an
exact match) while the calendar relay answers it as a geohash PREFIX, so
`geohash: "u33d"` discarded every event whose geohash was longer than
the prefix — nearly all of them. `#g` is now relay-only, like
`#start_after`.

Events expose their `D` day tags as `days` (NIP-52 requires them on
31923); eventToRsvp ignores an RSVP whose `a` does not reference a
31922/31923 coordinate (spec); an empty `eventAttendanceMode` emits no
attribute. Hidden sources now apply to calendars and RSVPs as well as
events, and are counted in `hiddenSources.hidden`.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
`limit` was applied per category, so kinds [31922,31923,31924,31925] with
limit 20 could return 60 items. It now caps the whole result: events
first, then calendars, then RSVPs. readPrice accepts plain decimals only
(Number() took "1e3", "0x10", "Infinity"; the relay's facet rejects them,
so `free: true` could never have found such an event). A failed profile
fetch caches bare author entries for 60s instead of the full 10-minute
TTL. Parameter comments and the kinds description state the inclusive /
strict bounds and that range, geohash and attribute filters exclude
non-event kinds.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
calendar-attributes.js lets the first VALID tag of a name win — an
invalid one is skipped, it does not shadow — and reads the attendance
mode by trimming and taking the last path segment of any URI form. The
MCP now does the same (it shadowed on the first tag and only stripped
http(s)://schema.org/), skips an empty educationalLevel:id, and falls
back to the deprecated `name` when `title` is present but empty (the
relay accepts such an event). eventToCalendarEvent only accepts
31922/31923, so a calendar or RSVP carrying a `start` is never emitted
as an event. Tool text and README no longer claim a geohash ignores the
topic: the relay now searches and post-filters one page by location.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
educationalLevel triples are now read exactly as calendar-attributes.js
reads them: ids and labels trimmed, an empty or repeated id resets the
current concept (so following labels attach to nothing), the first
non-empty label per language wins, and the display label is de → en →
first language → URI tail. A time-based `start` is digits with an
optional minus; a leading '+' is no longer parsed (the relay rejects it).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
laoc merged commit a27db6ef05 into main 2026-11-03 22:12:41 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
edufeed/nope-mcp!1
No description provided.