Commit bea0465
committed
feat: ADR-0036 Wave 2 (Python) — field.timestamp instant-by-default + @localTime
Port the TS reference (fa40542) to Python. field.timestamp is now an absolute
instant / timezone-aware BY DEFAULT; the rare naive / wall-clock case opts out
with the boolean @localTime attr. The @dbColumnType: timestamp_with_tz escape
hatch is retired — the legal @dbColumnType set shrinks to { uuid, jsonb }. The
canonical golden + shared persistence fixtures are TS-owned and unchanged; this
makes the Python port byte-match them.
Metamodel:
- db_constants.py: add FIELD_ATTR_LOCAL_TIME; drop DB_COLUMN_TYPE_TIMESTAMP_TZ
from VALID_DB_COLUMN_TYPES (now [uuid, jsonb]); tombstone the retired constant.
- db_provider.py: register @localTime (boolean, NO allowed_values) on
field.timestamp only; description sourced from the embedded spec_metamodel/db.json
by apply_spec_descriptions (single-source). @dbColumnType allowed_values shrinks
via VALID_DB_COLUMN_TYPES.
- spec_metamodel/db.json: re-copied from the TS-updated repo-root spec/metamodel/db.json
(byte-identity gate) — new boolean @localTime on field.timestamp + slimmed
@dbColumnType allowedValues/description.
Loader:
- validation_passes.py: drop timestamp_with_tz from the @dbColumnType legal
pairing map (now uuid/jsonb→field.string only). A timestamp_with_tz value now
fails Rule 1 (unrecognized value) → still ERR_BAD_ATTR_VALUE, so the shared
error-dbcolumntype-illegal-pairing fixture stays green (trigger shifts from
illegal-pairing to unknown-value).
Runtime (the core native-type flip):
- object_manager.py write codec: default field.timestamp → tz-aware datetime
(UTC tzinfo → driver binds timestamptz); @localTime:true → naive datetime
(no tzinfo → driver binds plain timestamp). Inverts the prior default. The
normalization boundary (tests/integration/normalization.py) already keys
tz-aware↔Z / naive↔no-Z off tzinfo, so it is unchanged.
Codegen/schema: Python is pure data-access (ADR-0015) — no DDL/schema emitter
and the Pydantic type map is datetime.datetime for both modes, so no codegen
column-type branch existed to flip.
Tests: registry-conformance byte-match green; spec_metamodel embed byte-match
green; full conformance (301) green incl. the shared illegal-pairing fixture;
test_field_uuid_dbcolumntype updated for the retirement + a new @localTime-ok
case. Native-type rule unit-verified (default aware / @localTime naive). The
persistence op:roundtrip (tsVal naive / tsTzVal tz-aware) needs pg8000 +
Testcontainers Postgres — CI-gated, not run locally. The 2 failing
test_cli_staleness_nudge tests are pre-existing (unrelated agent-docs message
wording), failing identically on the base branch.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GF9xLEQZaPus5Y6opk398n1 parent a50f1d4 commit bea0465
6 files changed
Lines changed: 81 additions & 29 deletions
File tree
- server/python
- src/metaobjects
- loader
- meta/persistence/db
- runtime
- spec_metamodel
- tests/unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
46 | 45 | | |
47 | 46 | | |
48 | 47 | | |
| |||
662 | 661 | | |
663 | 662 | | |
664 | 663 | | |
665 | | - | |
| 664 | + | |
666 | 665 | | |
667 | 666 | | |
668 | 667 | | |
669 | 668 | | |
670 | | - | |
671 | | - | |
672 | | - | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
673 | 675 | | |
674 | 676 | | |
675 | 677 | | |
676 | 678 | | |
677 | 679 | | |
678 | | - | |
| 680 | + | |
679 | 681 | | |
680 | 682 | | |
681 | 683 | | |
682 | 684 | | |
683 | | - | |
684 | 685 | | |
685 | 686 | | |
686 | 687 | | |
| |||
Lines changed: 17 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
24 | 32 | | |
25 | 33 | | |
26 | 34 | | |
| |||
30 | 38 | | |
31 | 39 | | |
32 | 40 | | |
33 | | - | |
34 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
35 | 47 | | |
36 | 48 | | |
37 | 49 | | |
| |||
40 | 52 | | |
41 | 53 | | |
42 | 54 | | |
43 | | - | |
| 55 | + | |
| 56 | + | |
44 | 57 | | |
45 | 58 | | |
46 | 59 | | |
47 | | - | |
48 | 60 | | |
49 | 61 | | |
50 | 62 | | |
| |||
Lines changed: 26 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
64 | 74 | | |
65 | 75 | | |
66 | 76 | | |
| |||
129 | 139 | | |
130 | 140 | | |
131 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
132 | 149 | | |
133 | 150 | | |
134 | 151 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
674 | 674 | | |
675 | 675 | | |
676 | 676 | | |
677 | | - | |
678 | | - | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
679 | 680 | | |
680 | 681 | | |
681 | 682 | | |
682 | 683 | | |
683 | 684 | | |
684 | 685 | | |
685 | 686 | | |
686 | | - | |
| 687 | + | |
687 | 688 | | |
688 | 689 | | |
689 | 690 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
11 | 18 | | |
12 | 19 | | |
13 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
94 | 97 | | |
95 | 98 | | |
96 | 99 | | |
97 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
98 | 110 | | |
99 | 111 | | |
100 | 112 | | |
| |||
104 | 116 | | |
105 | 117 | | |
106 | 118 | | |
| 119 | + | |
107 | 120 | | |
108 | 121 | | |
109 | 122 | | |
| |||
185 | 198 | | |
186 | 199 | | |
187 | 200 | | |
188 | | - | |
| 201 | + | |
| 202 | + | |
189 | 203 | | |
190 | 204 | | |
191 | 205 | | |
192 | 206 | | |
193 | | - | |
194 | | - | |
| 207 | + | |
| 208 | + | |
195 | 209 | | |
196 | 210 | | |
197 | 211 | | |
| |||
0 commit comments