diff --git a/.github/workflows/conformance.yml b/.github/workflows/conformance.yml new file mode 100644 index 0000000..842a6a5 --- /dev/null +++ b/.github/workflows/conformance.yml @@ -0,0 +1,19 @@ +name: Conformance + +on: + pull_request: + +permissions: + contents: read + +jobs: + conformance: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: actions/setup-node@v6 + with: + node-version: 24 + package-manager-cache: false + - run: npm ci + - run: npm run conformance:test diff --git a/01-terminology.md b/01-terminology.md index bbb271e..0ce11ec 100644 --- a/01-terminology.md +++ b/01-terminology.md @@ -50,9 +50,11 @@ Canonical form: `YYYY-MM-DD`. ## 1.11 Datetime value -A **datetime value** represents an instant in time. +An **instant** is a point in time written as an RFC 3339 datetime with an +offset. Its canonical form uses UTC with trailing `Z`. -Canonical form: ISO 8601 UTC with trailing `Z`. +A **floating datetime** is a calendar day and local clock time without an +offset. The field's role determines which datetime form is canonical (§3). ## 1.12 Target date diff --git a/03-temporal-semantics.md b/03-temporal-semantics.md index 3a12153..190b796 100644 --- a/03-temporal-semantics.md +++ b/03-temporal-semantics.md @@ -8,8 +8,9 @@ This section defines how implementations MUST interpret, compare, and serialize Implementations MUST support: -1. **Date values**: calendar day without time or timezone. -2. **Datetime values**: instant in time. +1. **Date values** represent calendar days without a time or timezone. +2. **Floating (local) datetime values** represent calendar days and clock times without an offset. They use the mdbase `local-date-time` format. +3. **Instant values** represent points in time. They use RFC 3339 `date-time` with `Z` or a numeric offset. ## 3.3 Canonical serialization @@ -21,17 +22,21 @@ Canonical date serialization is: YYYY-MM-DD ``` -### 3.3.2 Datetime +### 3.3.2 Instant -Canonical datetime serialization is UTC ISO 8601 with `Z`, for example: +Canonical instant serialization uses UTC with `Z`, for example: ```text 2026-02-20T13:45:00Z ``` -Canonical datetime writes MUST use second precision (`YYYY-MM-DDTHH:MM:SSZ`) and MUST NOT include fractional seconds. -Implementations MAY accept alternative inbound datetime forms but MUST normalize outbound canonical writes. -If an accepted inbound datetime includes fractional seconds, writers MUST normalize deterministically by truncating fractional precision to whole seconds. +Canonical instant writes MUST use second precision (`YYYY-MM-DDTHH:MM:SSZ`) and MUST truncate fractional seconds. + +### 3.3.3 Floating datetime + +Canonical timed `due` and `scheduled` writes MUST use `YYYY-MM-DDTHH:MM`, +with optional `:SS` and optional fractional seconds after `:SS`. For example, +write `2026-02-20T09:00` for a task due at 09:00 in the collection's time zone. ## 3.4 Parsing requirements @@ -44,17 +49,22 @@ Date parsing MUST reject invalid calendar dates. ### 3.4.2 Datetime parsing -Datetime parsing MUST reject malformed values. -In strict mode, datetime parsing MUST reject ambiguous local datetimes without offset (for example `2026-02-20T09:00:00` with no timezone offset). -In permissive mode, implementations MAY accept such values only under an explicitly documented compatibility policy and SHOULD emit a warning. +Datetime parsing MUST reject invalid calendar and clock values, such as +`2026-02-30T09:00` and `2026-02-20T24:00`. A floating datetime MUST use `T` +and the syntax in §3.3.3 without a `Z` or numeric offset. An instant MUST use +the RFC 3339 offset form. ### 3.4.3 Mixed input tolerance -Implementations MAY accept both date and datetime values for roles like `due` and `scheduled` if configured to do so. The accepted form MUST be documented. +Readers MUST accept dates, floating datetimes, and instants for `due` and +`scheduled`. Readers MUST accept instants and floating datetimes for +`date_created`, `date_modified`, and `time_entries` timestamps. Date-only +values are invalid for those timestamp roles in strict mode. ### 3.4.4 Inbound acceptance matrix -To avoid ambiguity, conforming parsers MUST follow this matrix. +Conforming parsers MUST follow this matrix for roles that accept the form's +value class (§3.4.3). Date forms: @@ -67,14 +77,15 @@ Datetime forms: | Form | Example | Strict | Permissive | |---|---|---|---| -| Canonical UTC | `2026-02-20T09:00:00Z` | accept | accept | -| ISO with explicit offset | `2026-02-20T09:00:00+10:00` | accept | accept | -| ISO with fractional seconds | `2026-02-20T09:00:00.250Z` | accept (normalize to second precision on write) | accept (normalize to second precision on write) | -| Offset-less local datetime | `2026-02-20T09:00:00` | reject (`invalid_datetime_value`) | MAY accept only under documented compatibility policy; SHOULD emit warning | +| UTC instant | `2026-02-20T09:00:00Z` | accept | accept | +| Instant with numeric offset | `2026-02-20T09:00:00+10:00` | accept | accept | +| Instant with fractional seconds | `2026-02-20T09:00:00.250Z` | accept | accept | +| Floating datetime | `2026-02-20T09:00`, `2026-02-20T09:00:00`, `2026-02-20T09:00:00.250` | accept for the roles listed in §3.4.3; reject for instant-only roles (`invalid_datetime_value`) | accept for the roles listed in §3.4.3; for instant-only roles MAY accept under documented compatibility policy and SHOULD emit a warning | | Space-separated datetime | `2026-02-20 09:00:00` | reject (`invalid_datetime_value`) | MAY accept only under documented compatibility policy; SHOULD emit warning | | Basic datetime (no separators) | `20260220T090000Z` | reject (`invalid_datetime_value`) | MAY accept only under documented compatibility policy; SHOULD emit warning | -When permissive-mode compatibility accepts a non-canonical form, canonical writes MUST still follow §3.3. +Canonical writes MUST follow the serialization for the field's role in §3.3, +including when permissive mode accepts a legacy form. ## 3.5 Day semantics vs instant semantics @@ -82,9 +93,11 @@ When permissive-mode compatibility accepts a non-canonical form, canonical write Date roles represent days, not instants, and MUST NOT be timezone-shifted. -### 3.5.2 Datetime roles +### 3.5.2 Instant roles -Datetime roles represent instants and MUST preserve instant equality through normalization. +Instant roles MUST preserve the instant when normalizing, subject to the +whole-second precision of canonical writes (§3.3.2). Resolve accepted +floating inputs under §3.6.3 before normalizing them. Example: @@ -128,6 +141,30 @@ When calculating day-level concepts (for example overdue/day grouping/calendar d This requirement prevents off-by-one day drift in positive and negative UTC offsets. +### 3.6.3 Resolving floating datetimes + +To resolve a stored floating datetime to an instant, use the collection's +IANA time zone in `settings.timezone`. In a daylight-saving overlap, choose +the earlier instant. In a gap, move the clock time forward by the length of +the gap. This follows RFC 5545 and Temporal's `compatible` disambiguation. +For example, in `America/New_York`, `2026-11-01T01:30` resolves to +`2026-11-01T05:30:00Z`, and `2026-03-08T02:30` resolves to +`2026-03-08T07:30:00Z`. Resolution leaves the stored value intact. + +At an mdbase date-time location, if `settings.timezone` is missing, mdbase +MUST keep a floating value as a string and emit a warning that the collection +needs a time zone. mdbase MUST NOT substitute the runtime zone. Fields such +as `due` and `scheduled` that allow both dates and datetimes remain strings +in mdbase queries. TaskNotes resolves their timed values when it needs an +instant, for example to schedule a relative reminder. + +Outside mdbase typing, a vault client without a configured collection zone +MAY use its documented vault or device zone. When `settings.timezone` is +set, the vault client MUST use it to resolve stored floating datetimes. +Without a collection zone or an applicable vault fallback, the floating +value remains unresolved for operations that require an instant. +The active runtime timezone in §3.6.1 governs day-level evaluation. + ## 3.7 Comparison rules ### 3.7.1 Date-to-date @@ -136,7 +173,8 @@ Compare by calendar day ordering. ### 3.7.2 Datetime-to-datetime -Compare by instant ordering. +For instant-level comparisons, resolve floating values under §3.6.3 and +compare by instant ordering. ### 3.7.3 Date-to-datetime @@ -147,12 +185,16 @@ If compared, implementations MUST document coercion policy. Recommended policy: ## 3.8 due and scheduled semantics -`due` and `scheduled` MAY be either date or datetime by configuration. +`due` and `scheduled` represent calendar days or local clock times. New or +explicitly changed timed values MUST be written as floating datetimes. +Previously stored instants remain valid on read. When writing a timed value +from an instant, use its calendar date and clock time in the collection's +zone or the applicable vault fallback (§3.6.3). Implementations MUST: -- preserve stored granularity unless explicit conversion is requested, -- avoid silently converting date to datetime during unrelated writes, +- preserve existing values on unrelated writes, +- preserve date-only or timed granularity unless explicit conversion is requested, - require documented explicit policy for date-to-datetime conversion operations, - apply consistent coercion policy in filters and status calculations. @@ -167,19 +209,24 @@ For non-recurring completion, writers MUST set `completed_date` using §5 semant ## 3.10 Created/modified timestamps -`date_created` and `date_modified` are datetime roles. +`date_created` and `date_modified` (`dateCreated` and `dateModified` in the +portable view) are instant roles. Readers MUST also accept floating values, +such as a value saved by the Obsidian properties editor, and resolve them +under §3.6.3 when an instant is needed. Writers MUST: -- set both on create, -- update `date_modified` on successful mutating operations that change persisted state, +- set both on create using the canonical instant format, +- update `date_modified` in canonical instant form on successful mutating operations that change persisted state, - preserve `date_created` unless explicit migration/edit operation changes it. ## 3.11 time_entries semantics ### 3.11.1 Timestamp format -`time_entries.startTime` and `time_entries.endTime` MUST be datetime instants in canonical form on write. +`time_entries.startTime` and `time_entries.endTime` MUST use the canonical +instant format on write. Readers MUST also accept floating values and +resolve them under §3.6.3 before validating ranges or calculating durations. ### 3.11.2 Range validity @@ -206,11 +253,11 @@ Implementations MUST document which derived view is used by each reporting surfa ## 3.12 reminder temporal semantics -Reminder time fields are governed by §10.3 and MUST follow canonical datetime and duration formats from this section. +Reminder time fields are governed by §10.3 and MUST follow the canonical instant and duration formats from this section. Rules: -- `reminders[].absoluteTime` MUST be a canonical datetime on write. +- `reminders[].absoluteTime` MUST be a canonical instant on write. - `reminders[].offset` MUST be a valid ISO 8601 duration string. - relative reminder base conversion for date-only values MUST use `reminders.date_only_anchor_time` from §9, or `00:00` local time if unset. @@ -256,19 +303,21 @@ priority: high Non-conforming behavior would silently rewrite `due` to a datetime. -## 3.15 Example: canonical datetime write +## 3.15 Example: canonical writes by role -Input: +Input in a collection with `settings.timezone` set to `Europe/Paris`: ```yaml +due: 2026-02-20T08:00:00Z timeEntries: - startTime: 2026-02-20T09:30:00+01:00 - endTime: 2026-02-20T10:00:00+01:00 + endTime: 2026-02-20T10:00:00 ``` -Canonical write: +Canonical serialization when explicitly writing these values: ```yaml +due: 2026-02-20T09:00 timeEntries: - startTime: 2026-02-20T08:30:00Z endTime: 2026-02-20T09:00:00Z diff --git a/05-operations.md b/05-operations.md index 3f1ceb9..b166472 100644 --- a/05-operations.md +++ b/05-operations.md @@ -200,7 +200,7 @@ Deterministic expansion context: - date/time variable expansion MUST use the active runtime timezone from §3.6. - locale-sensitive variables (`monthName`, `monthNameShort`, `dayName`, `dayNameShort`, `time12`) MUST use English locale outputs for portability (`January`, `Jan`, `Monday`, `Mon`, `AM`/`PM`). -- template-generated datetime-like outputs used in frontmatter MUST normalize to second precision when written as canonical datetime roles (§3.3.2). +- template-generated temporal values written to frontmatter MUST use the canonical form for the field's role (§3.3). Failure behavior: diff --git a/08-compatibility-and-migrations.md b/08-compatibility-and-migrations.md index 901b1eb..2c3dab0 100644 --- a/08-compatibility-and-migrations.md +++ b/08-compatibility-and-migrations.md @@ -52,7 +52,10 @@ With warning: ## 8.5 Temporal normalization migration -If historical writes include mixed datetime styles, migration SHOULD normalize to canonical UTC ISO `Z` for datetime roles while preserving date-only roles as dates. +If historical writes include mixed datetime styles, migration SHOULD use the +canonical form for each role (§3.3). Preserve date-only values as dates, write +timed `due` and `scheduled` values as floating datetimes, and write instant +roles in UTC with `Z`. Example: diff --git a/09-configuration.md b/09-configuration.md index 05f28a6..4ad1514 100644 --- a/09-configuration.md +++ b/09-configuration.md @@ -590,7 +590,7 @@ compatibility: Rules: - Compatibility flags MUST default to conservative behavior in new collections. -- `legacy_local_datetime_input=true` MAY relax strict parsing for offset-less datetimes only in permissive mode; strict mode parsing rules in §3.4.2 still apply. +- `legacy_local_datetime_input=true` MAY allow floating datetimes for instant-only roles in permissive mode (§3.4.4). Roles that accept floating datetimes in strict mode (§3.4.3) do so regardless of this flag. - Enabled compatibility flags SHOULD be disclosed in conformance output (§7). ## 9.19 Complete configuration example (`yaml_file` provider) diff --git a/10-dependencies-and-reminders.md b/10-dependencies-and-reminders.md index 9a79acb..899af8c 100644 --- a/10-dependencies-and-reminders.md +++ b/10-dependencies-and-reminders.md @@ -163,7 +163,8 @@ Trigger instant MUST be computed as follows: 1. If `type=absolute`, trigger = `absoluteTime` instant. 2. If `type=relative`, - resolve base field from `relatedTo`, - - if base is datetime: use that instant, + - if base is an instant: use it directly, + - if base is a floating datetime: resolve it under §3.6.3, - if base is date: convert to local datetime at configured `reminders.date_only_anchor_time`, - trigger = base + `offset`. diff --git a/12-mdbase-v0.3-binding.md b/12-mdbase-v0.3-binding.md index 6fdd32a..af03586 100644 --- a/12-mdbase-v0.3-binding.md +++ b/12-mdbase-v0.3-binding.md @@ -2,9 +2,13 @@ **Status:** Draft -**Record contract:** `tasknotes.task` `0.3.0-rc.6` +**Record contract:** `tasknotes.task` `0.3.0-rc.7` -This revision adds optional `assignees`: links to records implementing +rc.7 adds `local-date-time` to `due`, `scheduled`, `dateCreated`, and +`dateModified`. See §3 for canonical writes and resolution using the +collection's `settings.timezone`. + +The contract supports optional `assignees` links to records implementing `mdbase.person`, resolved by ordinary mdbase link resolution. Unresolved links survive person deletion or membership removal. Assignment and editable person identity associations never grant collection access. See @@ -56,7 +60,7 @@ can implement and several applications can consume. ```text personal_task ─┐ -work_task ─────┼─ implements tasknotes.task 0.3.0-rc.6 ── TaskNotes +work_task ─────┼─ implements tasknotes.task 0.3.0-rc.7 ── TaskNotes issue_task ────┘ ├─ automation └─ another task app ``` @@ -100,7 +104,7 @@ An mdbase TaskNotes type declares one implementation: ```yaml implements: - contract: tasknotes.task - version: 0.3.0-rc.6 + version: 0.3.0-rc.7 fields: title: summary status: state @@ -289,7 +293,7 @@ and is excluded from the cycle exactly when it is a skipped status. ## 12.9 Multiple implementations A collection may contain any number of types implementing -`tasknotes.task 0.3.0-rc.6`. TaskNotes-aware readers MUST: +`tasknotes.task 0.3.0-rc.7`. TaskNotes-aware readers MUST: 1. resolve the exact local contract; 2. enumerate every implementation in canonical type-name order; @@ -377,7 +381,10 @@ schema: summary: { type: string, minLength: 1 } state: { enum: [todo, doing, done, cancelled] } importance: { enum: [low, normal, high] } - created_at: { type: string, format: date-time } + created_at: + anyOf: + - { type: string, format: date-time } + - { type: string, format: local-date-time } tags: type: array items: { type: string } @@ -393,7 +400,7 @@ lifecycle: created_at: { now: true } implements: - contract: tasknotes.task - version: 0.3.0-rc.6 + version: 0.3.0-rc.7 fields: title: summary status: state diff --git a/conformance/tests/mdbase-data-contract.test.mjs b/conformance/tests/mdbase-data-contract.test.mjs index 7435a43..8fc2660 100644 --- a/conformance/tests/mdbase-data-contract.test.mjs +++ b/conformance/tests/mdbase-data-contract.test.mjs @@ -11,9 +11,20 @@ async function schema(name) { ); } -test("publishes valid JSON Schemas for the portable task view, binding, and completion event", async () => { +function mdbaseValidator() { const ajv = new Ajv2020({ allErrors: true, strict: true }); addFormats(ajv); + const validateDate = ajv.compile({ type: "string", format: "date" }); + const localDateTime = /^(\d{4}-\d{2}-\d{2})T(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?$/; + ajv.addFormat("local-date-time", (value) => { + const parts = localDateTime.exec(value); + return parts !== null && validateDate(parts[1]); + }); + return ajv; +} + +test("publishes valid JSON Schemas for the portable task view, binding, and completion event", async () => { + const ajv = mdbaseValidator(); const taskSchema = await schema("tasknotes-task.schema.json"); const bindingSchema = await schema("tasknotes-task-binding.schema.json"); const completedSchema = await schema("tasknotes-task-completed.schema.json"); @@ -140,6 +151,35 @@ test("publishes valid JSON Schemas for the portable task view, binding, and comp assert.equal(validateCompleted({ task_path: "Tasks/Ship contracts.md" }), false); }); +test("the portable task view accepts mdbase floating datetimes for the documented roles", async () => { + const validate = mdbaseValidator().compile(await schema("tasknotes-task.schema.json")); + const task = { status: "open", dateCreated: "2026-07-28T09:00:00Z" }; + const valid = [ + "2026-07-28T09:00", + "2026-07-28T09:00:00", + "2028-02-29T09:00:00.250", + ]; + const invalid = [ + "2026-02-30T09:00", + "2026-07-28T24:00", + "2026-07-28T09:60", + "2026-07-28T09:00.250", + "2026-07-28 09:00:00", + ]; + for (const field of ["due", "scheduled", "dateCreated", "dateModified"]) { + for (const value of valid) { + assert.equal(validate({ ...task, [field]: value }), true, `${field}: ${value}`); + } + for (const value of invalid) { + assert.equal(validate({ ...task, [field]: value }), false, `${field}: ${value}`); + } + } + for (const field of ["dateCreated", "dateModified"]) { + assert.equal(validate({ ...task, [field]: "2026-07-28" }), false, field); + } + assert.equal(validate({ ...task, completedDate: "2026-07-28T09:00" }), false); +}); + test("the published contract uses one exact identity and the canonical schemas", async () => { const contract = await readFile( new URL("../../mdbase/tasknotes.task.md", import.meta.url), @@ -148,7 +188,7 @@ test("the published contract uses one exact identity and the canonical schemas", assert.match(contract, /^kind: mdbase\.contract$/m); assert.match(contract, /^id: tasknotes\.task$/m); assert.match(contract, /^contract_type: record$/m); - assert.match(contract, /^version: 0\.3\.0-rc\.6$/m); + assert.match(contract, /^version: 0\.3\.0-rc\.7$/m); assert.match(contract, /^record_schema:$/m); assert.match(contract, /ref: \.\.\/schemas\/tasknotes-task\.schema\.json/); assert.match( diff --git a/mdbase/tasknotes.task.md b/mdbase/tasknotes.task.md index 9ffbca9..777900e 100644 --- a/mdbase/tasknotes.task.md +++ b/mdbase/tasknotes.task.md @@ -2,9 +2,9 @@ kind: mdbase.contract contract_type: record id: tasknotes.task -version: 0.3.0-rc.6 +version: 0.3.0-rc.7 name: TaskNotes task -description: Portable task data and behavior defined by tasknotes-spec 0.3.0-rc.6. +description: Portable task data and behavior defined by tasknotes-spec. record_schema: dialect: json-schema-2020-12 ref: ../schemas/tasknotes-task.schema.json @@ -22,6 +22,11 @@ priority vocabularies. App behaviour that does not change that meaning, such as templates, archive moves and status cycling, lives in the collection's `tasknotes.settings` record at `_settings/dev.tasknotes.md`. +`due` and `scheduled` accept dates, instants, and floating datetimes. +`dateCreated` and `dateModified` accept instants and floating datetimes. +See [chapter 03](../03-temporal-semantics.md) for canonical writes and +resolution using the collection's `settings.timezone`. + `assignees` is an optional unique list of links to records implementing `mdbase.person`, for example `"[[Alex Rivera]]"` or `"[[people/alex-rivera]]"`. Missing or empty means unassigned. An implementing type MUST declare its diff --git a/schemas/tasknotes-task-binding.schema.json b/schemas/tasknotes-task-binding.schema.json index a8a1f5a..6bbc4b1 100644 --- a/schemas/tasknotes-task-binding.schema.json +++ b/schemas/tasknotes-task-binding.schema.json @@ -2,7 +2,7 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://tasknotes.dev/schemas/tasknotes-task-binding.schema.json", "title": "TaskNotes task data-contract binding", - "description": "Semantic configuration supplied by an mdbase type that implements tasknotes.task 0.3.0-rc.6. App behaviour, such as templates, archive moves, status cycling and natural-language triggers, lives in the app's tasknotes.settings record instead.", + "description": "Semantic configuration supplied by an mdbase type that implements tasknotes.task 0.3.0-rc.7. App behaviour, such as templates, archive moves, status cycling and natural-language triggers, lives in the app's tasknotes.settings record instead.", "type": "object", "required": [ "profiles", diff --git a/schemas/tasknotes-task.schema.json b/schemas/tasknotes-task.schema.json index 0c9f2d7..2f3714b 100644 --- a/schemas/tasknotes-task.schema.json +++ b/schemas/tasknotes-task.schema.json @@ -2,7 +2,7 @@ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://tasknotes.dev/schemas/tasknotes-task.schema.json", "title": "TaskNotes portable task view", - "description": "The storage-neutral record view exposed by the tasknotes.task 0.3.0-rc.6 record contract.", + "description": "The storage-neutral record view exposed by the tasknotes.task 0.3.0-rc.7 record contract.", "type": "object", "required": ["status", "dateCreated"], "additionalProperties": false, @@ -14,13 +14,15 @@ "due": { "anyOf": [ { "type": "string", "format": "date" }, - { "type": "string", "format": "date-time" } + { "type": "string", "format": "date-time" }, + { "type": "string", "format": "local-date-time" } ] }, "scheduled": { "anyOf": [ { "type": "string", "format": "date" }, - { "type": "string", "format": "date-time" } + { "type": "string", "format": "date-time" }, + { "type": "string", "format": "local-date-time" } ] }, "contexts": { @@ -44,8 +46,18 @@ }, "timeEstimate": { "type": "integer", "minimum": 0 }, "completedDate": { "type": "string", "format": "date" }, - "dateCreated": { "type": "string", "format": "date-time" }, - "dateModified": { "type": "string", "format": "date-time" }, + "dateCreated": { + "anyOf": [ + { "type": "string", "format": "date-time" }, + { "type": "string", "format": "local-date-time" } + ] + }, + "dateModified": { + "anyOf": [ + { "type": "string", "format": "date-time" }, + { "type": "string", "format": "local-date-time" } + ] + }, "recurrence": { "type": "string" }, "recurrenceAnchor": { "enum": ["scheduled", "completion"]