Repository navigation
Commit 400c53f
fix(codegen-ts): detect source.rdb structurally, not by instanceof MetaSource
`hasAnyRdbSource` / `hasWritableRdbSource` identified a source by
`child instanceof MetaSource`. That is the same class-identity assumption
that split ts-poet's Code objects in 0.21.6: two physical copies of
@metaobjectsdev/metadata in one process give the loader's nodes a different
MetaSource class object than these helpers close over, so `instanceof` is
false for a node that is a source.rdb in every observable respect.
Here the consequence is silent rather than loud. The entity reads as "not
backed by any store", so the table, queries and routes tiers all emit
nothing for it and nothing errors — the adopter gets a successful `meta gen`
with an entity missing from the output.
`meta gen` aliases @metaobjectsdev/metadata to the CLI's own copy
(load-metaobjects-config.ts CLI_PKG_PATHS), which is why this has never
fired in practice. But that alias map runs only for the CLI path: a consumer
embedding runGen() programmatically never executes it, so the helpers should
not depend on it. Both now gate on type/subType, and writability is read
through the node's own surface rather than through the class.
Behaviour is unchanged on a single-copy tree — the registry maps TYPE_SOURCE
to MetaSource, so every source.rdb child already satisfied the old guard.
A node that cannot answer isWritable() is still not counted as writable.
Gated by test/source-detect.test.ts, which models a foreign-realm source as a
MetaData subclass with the same type/subType and writability surface
(instanceof false, everything else identical). Verified red without the fix:
hasAnyRdbSource and hasWritableRdbSource both returned false. The suite also
pins the two directions the relaxation could overshoot — a read-only kind
stays non-writable, and a non-source child is not mistaken for a source.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KTGT5ksntpcJDZVJ5VyXHS1 parent ac61bc1 commit 400c53f
2 files changed
Lines changed: 105 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | 9 | | |
11 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
12 | 44 | | |
13 | 45 | | |
14 | 46 | | |
| |||
22 | 54 | | |
23 | 55 | | |
24 | 56 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 57 | + | |
| 58 | + | |
29 | 59 | | |
30 | 60 | | |
31 | 61 | | |
| |||
42 | 72 | | |
43 | 73 | | |
44 | 74 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
| 75 | + | |
49 | 76 | | |
50 | 77 | | |
51 | 78 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| 14 | + | |
13 | 15 | | |
14 | | - | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
58 | 60 | | |
59 | 61 | | |
60 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
0 commit comments