|
16 | 16 | """ |
17 | 17 | from __future__ import annotations |
18 | 18 |
|
19 | | -from ...core.attr.attr_constants import ATTR_SUBTYPE_STRING |
| 19 | +from ...core.attr.attr_constants import ATTR_SUBTYPE_BOOLEAN, ATTR_SUBTYPE_STRING |
20 | 20 | from ...core.field import field_constants as fc |
21 | 21 | from ...core.identity.identity_constants import ( |
22 | 22 | IDENTITY_SUBTYPE_REFERENCE, |
|
27 | 27 | from ....shared.base_types import TYPE_FIELD, TYPE_IDENTITY |
28 | 28 | from .db_constants import ( |
29 | 29 | FIELD_ATTR_DB_COLUMN_TYPE, |
| 30 | + FIELD_ATTR_LOCAL_TIME, |
30 | 31 | IDENTITY_REFERENCE_ATTR_CONSTRAINT_NAME, |
31 | 32 | IDENTITY_SECONDARY_ATTR_ORDERS, |
32 | 33 | IDENTITY_SECONDARY_ATTR_WHERE, |
|
46 | 47 | _COLUMN_SCHEMA = AttrSchema(name=fc.FIELD_ATTR_COLUMN, value_type=ATTR_SUBTYPE_STRING, required=False) |
47 | 48 |
|
48 | 49 | # @dbColumnType — physical column-type override on a field. Carries the closed |
49 | | -# value-set (uuid | jsonb | timestamp_with_tz) PURELY so it surfaces in the |
50 | | -# registry manifest (ADR-0036 Wave 1, decision 5 — closed-value-set conformance |
51 | | -# gate). Its REAL constraint is the (subtype × value) pairing enforced by the |
52 | | -# loader's _validate_db_column_type pass, which emits the single ERR_BAD_ATTR_VALUE |
53 | | -# for both an unrecognized value and an illegal pairing; that pass is the sole |
54 | | -# enforcer, so @dbColumnType is EXEMPT from the generic flat allowed_values |
55 | | -# membership check (Check 3 in validation_passes) to avoid double-reporting — |
56 | | -# matching the TS reference. |
| 50 | +# value-set (uuid | jsonb) PURELY so it surfaces in the registry manifest (ADR-0036 |
| 51 | +# Wave 1, decision 5 — closed-value-set conformance gate). Its REAL constraint is |
| 52 | +# the (subtype × value) pairing enforced by the loader's _validate_db_column_type |
| 53 | +# pass, which emits the single ERR_BAD_ATTR_VALUE for both an unrecognized value and |
| 54 | +# an illegal pairing; that pass is the sole enforcer, so @dbColumnType is EXEMPT from |
| 55 | +# the generic flat allowed_values membership check (Check 3 in validation_passes) to |
| 56 | +# avoid double-reporting — matching the TS reference. |
57 | 57 | _DB_COLUMN_TYPE_SCHEMA = AttrSchema( |
58 | 58 | name=FIELD_ATTR_DB_COLUMN_TYPE, |
59 | 59 | value_type=ATTR_SUBTYPE_STRING, |
60 | 60 | required=False, |
61 | 61 | allowed_values=VALID_DB_COLUMN_TYPES, |
62 | 62 | ) |
63 | 63 |
|
| 64 | +# @localTime — boolean opt-out into a naive / wall-clock timestamp (ADR-0036 Wave |
| 65 | +# 2). Registered on field.timestamp only; the description is sourced from the |
| 66 | +# embedded spec/metamodel/db.json by apply_spec_descriptions (single-source). NO |
| 67 | +# allowed_values — it's an open boolean, not a closed-enum attr. |
| 68 | +_LOCAL_TIME_SCHEMA = AttrSchema( |
| 69 | + name=FIELD_ATTR_LOCAL_TIME, |
| 70 | + value_type=ATTR_SUBTYPE_BOOLEAN, |
| 71 | + required=False, |
| 72 | +) |
| 73 | + |
64 | 74 | # DB-domain physical attrs EXTENDING identity subtypes — RDB index / FK-constraint |
65 | 75 | # concerns, NOT core identity. Mirrors spec/metamodel/db.json's identity extends and |
66 | 76 | # the TS/Java/C# db providers. Descriptions are byte-identical to the canonical. |
@@ -129,6 +139,13 @@ def _register(registry: TypeRegistry) -> None: |
129 | 139 | sub_type, |
130 | 140 | attributes=[_COLUMN_SCHEMA, _DB_COLUMN_TYPE_SCHEMA], |
131 | 141 | ) |
| 142 | + # ADR-0036 Wave 2: @localTime is a field.timestamp-only opt-out (instant by |
| 143 | + # default → naive). Registered on the timestamp subtype only. |
| 144 | + registry.extend( |
| 145 | + TYPE_FIELD, |
| 146 | + fc.FIELD_SUBTYPE_TIMESTAMP, |
| 147 | + attributes=[_LOCAL_TIME_SCHEMA], |
| 148 | + ) |
132 | 149 | registry.extend( |
133 | 150 | TYPE_IDENTITY, |
134 | 151 | IDENTITY_SUBTYPE_SECONDARY, |
|
0 commit comments