@genesislcap/ai-assistant 15.37.0 → 15.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/custom-elements.json +638 -0
  2. package/dist/dts/genesis/calendar.d.ts +25 -0
  3. package/dist/dts/genesis/calendar.d.ts.map +1 -0
  4. package/dist/dts/genesis/config.d.ts +16 -0
  5. package/dist/dts/genesis/config.d.ts.map +1 -1
  6. package/dist/dts/genesis/criteria.d.ts +24 -2
  7. package/dist/dts/genesis/criteria.d.ts.map +1 -1
  8. package/dist/dts/genesis/event-fields.d.ts +84 -0
  9. package/dist/dts/genesis/event-fields.d.ts.map +1 -0
  10. package/dist/dts/genesis/filter-fields.d.ts +69 -5
  11. package/dist/dts/genesis/filter-fields.d.ts.map +1 -1
  12. package/dist/dts/genesis/index.d.ts +3 -0
  13. package/dist/dts/genesis/index.d.ts.map +1 -1
  14. package/dist/dts/genesis/register-genesis-assistant.d.ts +13 -0
  15. package/dist/dts/genesis/register-genesis-assistant.d.ts.map +1 -1
  16. package/dist/dts/genesis/resource-tools.d.ts.map +1 -1
  17. package/dist/dts/genesis/review-model.d.ts +202 -0
  18. package/dist/dts/genesis/review-model.d.ts.map +1 -0
  19. package/dist/dts/genesis/row-source.d.ts +102 -0
  20. package/dist/dts/genesis/row-source.d.ts.map +1 -0
  21. package/dist/dts/genesis/serialisable.d.ts +25 -0
  22. package/dist/dts/genesis/serialisable.d.ts.map +1 -0
  23. package/dist/dts/genesis/server-text.d.ts +63 -0
  24. package/dist/dts/genesis/server-text.d.ts.map +1 -0
  25. package/dist/dts/genesis/type-name.d.ts +18 -0
  26. package/dist/dts/genesis/type-name.d.ts.map +1 -0
  27. package/dist/dts/genesis/types.d.ts +7 -0
  28. package/dist/dts/genesis/types.d.ts.map +1 -1
  29. package/dist/dts/genesis/value-compare.d.ts +19 -0
  30. package/dist/dts/genesis/value-compare.d.ts.map +1 -0
  31. package/dist/dts/genesis/write-commit.d.ts +53 -0
  32. package/dist/dts/genesis/write-commit.d.ts.map +1 -0
  33. package/dist/dts/genesis/write-outcome.d.ts +133 -0
  34. package/dist/dts/genesis/write-outcome.d.ts.map +1 -0
  35. package/dist/dts/genesis/write-payload.d.ts +129 -0
  36. package/dist/dts/genesis/write-payload.d.ts.map +1 -0
  37. package/dist/dts/genesis/write-plan.d.ts +109 -0
  38. package/dist/dts/genesis/write-plan.d.ts.map +1 -0
  39. package/dist/dts/genesis/write-review/write-review.d.ts +127 -0
  40. package/dist/dts/genesis/write-review/write-review.d.ts.map +1 -0
  41. package/dist/dts/genesis/write-review/write-review.styles.d.ts +2 -0
  42. package/dist/dts/genesis/write-review/write-review.styles.d.ts.map +1 -0
  43. package/dist/dts/genesis/write-review/write-review.template.d.ts +4 -0
  44. package/dist/dts/genesis/write-review/write-review.template.d.ts.map +1 -0
  45. package/dist/dts/genesis/write-tools.d.ts +99 -0
  46. package/dist/dts/genesis/write-tools.d.ts.map +1 -0
  47. package/dist/dts/react.d.ts +10 -0
  48. package/dist/esm/genesis/calendar.js +38 -0
  49. package/dist/esm/genesis/config.js +36 -1
  50. package/dist/esm/genesis/criteria.js +59 -55
  51. package/dist/esm/genesis/event-fields.js +158 -0
  52. package/dist/esm/genesis/filter-fields.js +111 -20
  53. package/dist/esm/genesis/index.js +2 -0
  54. package/dist/esm/genesis/register-genesis-assistant.js +76 -4
  55. package/dist/esm/genesis/resource-tools.js +21 -103
  56. package/dist/esm/genesis/review-model.js +248 -0
  57. package/dist/esm/genesis/row-source.js +127 -0
  58. package/dist/esm/genesis/serialisable.js +38 -0
  59. package/dist/esm/genesis/server-text.js +186 -0
  60. package/dist/esm/genesis/type-name.js +20 -0
  61. package/dist/esm/genesis/value-compare.js +87 -0
  62. package/dist/esm/genesis/write-commit.js +78 -0
  63. package/dist/esm/genesis/write-outcome.js +299 -0
  64. package/dist/esm/genesis/write-payload.js +632 -0
  65. package/dist/esm/genesis/write-plan.js +275 -0
  66. package/dist/esm/genesis/write-review/write-review.js +252 -0
  67. package/dist/esm/genesis/write-review/write-review.styles.js +214 -0
  68. package/dist/esm/genesis/write-review/write-review.template.js +182 -0
  69. package/dist/esm/genesis/write-tools.js +660 -0
  70. package/dist/react.cjs +7 -0
  71. package/dist/react.mjs +6 -0
  72. package/docs/genesis.md +152 -10
  73. package/package.json +18 -18
@@ -0,0 +1,186 @@
1
+ import { logger } from '../utils/logger';
2
+ /**
3
+ * What of the server's own words may be shown to a model or a user.
4
+ *
5
+ * @remarks
6
+ * Shared by the read path and the write path deliberately. They hit the same problem for the
7
+ * same reason — a reply's TEXT is whatever the platform put there, and it reaches both a model
8
+ * vendor and a person's screen — and two copies of the rule would drift into two answers to one
9
+ * question.
10
+ */
11
+ /**
12
+ * One short plain sentence — the shape an app's own refusal takes, and the shape a stack trace,
13
+ * a SQL error or a Java class name does not.
14
+ *
15
+ * @remarks
16
+ * Deliberately an ALLOW-list on shape. The first version matched the server's text for things it
17
+ * recognised (`Groovy`, `Script\d+`), which made it a deny-list: anything unfamiliar went
18
+ * straight through to the model and onto the user's screen, and there is no reason to think the
19
+ * four patterns seen so far are the only ones a platform can produce. Reviewer catch on #2543 —
20
+ * his diagnosis exactly, with a different fix, because suppressing every refusal on a filtered
21
+ * read throws away the half worth keeping (see the read tools' `readableRefusal`).
22
+ *
23
+ * The character set does much of the work: no colon, so `ORA-00904:` and
24
+ * `global.genesis.Foo$Bar:` are out; no braces, semicolons, angle brackets or backticks; nothing
25
+ * below a space, so a multi-line trace cannot pass. Underscores are allowed, because
26
+ * "TRADE_ID is required" is an app message worth keeping — which is what leaves real work for
27
+ * the three shape tests below rather than making them decoration.
28
+ *
29
+ * It is fail-closed by construction, and it will occasionally sanitise a legitimate message that
30
+ * happens to read like code. That costs the model a phrase; the other direction costs a
31
+ * disclosure.
32
+ */
33
+ const PLAIN_SENTENCE_LIMIT = 160;
34
+ const PLAIN_SENTENCE = /^[A-Za-z0-9_ ,.'"!?%/()-]+$/;
35
+ /** `Expr.foo(`, `doThing(` — a call, whatever it is called. */
36
+ const CALL_SHAPE = /[A-Za-z0-9_]\(/;
37
+ /** A dotted identifier: `Script166.groovy`, `global.genesis`. Not `1.5`, which starts a digit. */
38
+ const DOTTED_NAME = /[A-Za-z_][A-Za-z0-9_]*\.[A-Za-z_]/;
39
+ /** `ORA-00904`, `SQL-1234`: an error code carries no punctuation to catch it by. */
40
+ const ERROR_CODE = /\b[A-Za-z]{2,}-\d+\b/;
41
+ /**
42
+ * `NullPointerException`, `TradeDao` — a class name with no package to give it away. A sentence
43
+ * does not run two capitals together across a lowercase run, so ordinary prose survives.
44
+ */
45
+ const CAMEL_CASE = /[A-Z][a-z]+[A-Z]/;
46
+ /** A dotted quad: an internal address, which `DOTTED_NAME` misses because it has no letters. */
47
+ const IPV4 = /\b\d{1,3}(?:\.\d{1,3}){3}\b/;
48
+ /**
49
+ * `/opt/genesis/...`: the server's filesystem layout, which needs no dot and no brackets.
50
+ *
51
+ * @remarks
52
+ * A slash counts as a path's root after anything but a word character, not only after whitespace:
53
+ * `(/opt/genesis/run)`, `"/opt/genesis/cfg"` and `./runtime/cfg` all passed when it had to follow a
54
+ * space. A slash between two words (`BUY/SELL`, `and/or`, `50/50`) is still not a root.
55
+ */
56
+ const ROOTED_PATH = /(?:^|[^A-Za-z0-9_])\/[A-Za-z0-9_.-]/;
57
+ /** @internal */
58
+ export const readsLikeProse = (text) => text.length <= PLAIN_SENTENCE_LIMIT &&
59
+ PLAIN_SENTENCE.test(text) &&
60
+ !CALL_SHAPE.test(text) &&
61
+ !DOTTED_NAME.test(text) &&
62
+ !ERROR_CODE.test(text) &&
63
+ !CAMEL_CASE.test(text) &&
64
+ !IPV4.test(text) &&
65
+ !ROOTED_PATH.test(text);
66
+ /**
67
+ * What a server error's `FIELD` may look like.
68
+ *
69
+ * @remarks
70
+ * A tighter rule than prose, because `FIELD` has two known shapes and neither is a sentence: a
71
+ * column name, or an index and the value that clashed with it — live captures show
72
+ * `TRADE_BY_ID -> 000000000000001TRLO1` on a duplicate key. Running it through the prose test
73
+ * threw the second one away, and which index and which value is the most useful thing in that
74
+ * reply. So the shape is matched instead, with the value held to the same restricted
75
+ * characters: `TRADE_BY_CPTY_DATE -> global.genesis.db.DbRecord$Key@1a2b (Foo.java:88)` fails
76
+ * on `$`, `@`, `(` and `:` while the live one passes.
77
+ */
78
+ /**
79
+ * UPPER_SNAKE, because that is what a Genesis identifier is — `config.ts` pins the same shape for
80
+ * resource names. It is also what separates a column from a Java class without having to know
81
+ * the classes: `NullPointerException` and `TradeDao` passed the mixed-case version outright, and
82
+ * every fixture had exercised the indexed form, so the bare half was never probed at all.
83
+ */
84
+ const FIELD_NAME = /^[A-Z][A-Z0-9_]{0,63}$/;
85
+ const INDEX_AND_VALUE = /^[A-Z][A-Z0-9_]{0,63} -> (.+)$/;
86
+ /** The characters a key value may use: enough for an id, a code or a decimal, and no more. */
87
+ const KEY_VALUE = /^[A-Za-z0-9_ .,'-]{1,80}$/;
88
+ /** Whether text is a Genesis identifier, the {@link FIELD_NAME} shape. @internal */
89
+ export const readsLikeFieldName = (text) => FIELD_NAME.test(text);
90
+ /**
91
+ * Whether a value the server produced may be shown as a KEY value — an id like
92
+ * `000000000000001TRLO1`, a code, a decimal.
93
+ *
94
+ * @remarks
95
+ * Restricted characters, then the same shape tests the prose rule uses, for the same reason: a
96
+ * class name, an address and a path all arrive looking like an ordinary value. The characters
97
+ * alone were not enough — `global.genesis.db.DbRecord` and `TradeDao.java` are letters and dots
98
+ * — while a decimal like `1.25` has a digit before its dot and is a perfectly ordinary key.
99
+ *
100
+ * One rule for the index value in a duplicate-key `FIELD` and for a key a write GENERATED, so the
101
+ * two cannot drift.
102
+ *
103
+ * @internal
104
+ */
105
+ export const readsLikeKeyValue = (text) => KEY_VALUE.test(text) && !DOTTED_NAME.test(text) && !CAMEL_CASE.test(text) && !IPV4.test(text);
106
+ /** @internal */
107
+ export function plainFieldName(field, context) {
108
+ var _a;
109
+ const trimmed = String(field !== null && field !== void 0 ? field : '').trim();
110
+ if (!trimmed)
111
+ return undefined;
112
+ // The VALUE side is held to readsLikeKeyValue: restricted characters, and no dotted name, class
113
+ // name or address among them. The example that first justified the rule failed only on its
114
+ // `$`, `@` and `(`, while `global.genesis.db.DbRecord` passed a character rule written to stop
115
+ // exactly it. No path test: the value's character set has no `/`, so a path never gets that far
116
+ // and a guard for it would be a line that cannot fail.
117
+ const value = (_a = INDEX_AND_VALUE.exec(trimmed)) === null || _a === void 0 ? void 0 : _a[1];
118
+ if (FIELD_NAME.test(trimmed) || (!!value && readsLikeKeyValue(value)))
119
+ return trimmed;
120
+ logger.error(`Genesis assistant: ${context}: ${trimmed}`);
121
+ return 'a field it did not name plainly';
122
+ }
123
+ /**
124
+ * The server's text if it can be shown, and a plain fallback if it cannot.
125
+ *
126
+ * @remarks
127
+ * Anything replaced is logged with its context: an unfamiliar refusal is exactly the one whoever
128
+ * is debugging the bridge needs to see, and it is the one the model was told nothing about.
129
+ *
130
+ * @internal
131
+ */
132
+ export function plainServerText(text, context, fallback) {
133
+ const trimmed = String(text !== null && text !== void 0 ? text : '').trim();
134
+ if (trimmed && readsLikeProse(trimmed))
135
+ return trimmed;
136
+ logger.error(`Genesis assistant: ${context}: ${trimmed || '(no reason given)'}`);
137
+ return fallback;
138
+ }
139
+ /** {@link withTimeout}'s own rejection: this bridge's message, not the app's. */
140
+ const TIMED_OUT = /^withTimeout:/;
141
+ /**
142
+ * Whatever a rejection turns out to be, as a sentence.
143
+ *
144
+ * @remarks
145
+ * Comms rejects with a plain object rather than an `Error` on the socket path, so `String(error)`
146
+ * handed the model `The read failed: [object Object]` — which tells it nothing and, worse, reads
147
+ * like the bridge having no idea what happened. An `Error` still answers with its message.
148
+ */
149
+ export function describeFailure(error) {
150
+ var _a;
151
+ if (error instanceof Error)
152
+ return error.message;
153
+ const named = (_a = error) !== null && _a !== void 0 ? _a : {};
154
+ for (const candidate of [named.message, named.TEXT, named.ERROR]) {
155
+ if (typeof candidate === 'string' && candidate.length)
156
+ return candidate;
157
+ }
158
+ // Nothing worth saying. `undefined` rather than a filler phrase, so the caller ends its own
159
+ // sentence instead of appending "the app gave no reason" to "whether this was written is
160
+ // unknown", which reads as though the two were different facts.
161
+ return undefined;
162
+ }
163
+ /**
164
+ * A rejection as one sentence a model and a user may both see.
165
+ *
166
+ * @remarks
167
+ * Three shapes reach here and all three used to be printed raw with `String(error)`:
168
+ *
169
+ * - an `Error` from the server, whose message can carry a SQL code, a class name or a host;
170
+ * - a plain object, which comms rejects with on the socket path — `[object Object]`, which
171
+ * tells the model nothing and reads like the bridge not knowing what happened;
172
+ * - {@link withTimeout}'s own rejection, which is OUR message and names an internal helper.
173
+ *
174
+ * The timeout is said in words, because it is not the server's text and "it took too long" is
175
+ * something the model can act on. Everything else goes through the same allow-list a refusal
176
+ * does. The full detail is always logged.
177
+ *
178
+ * @internal
179
+ */
180
+ export function plainFailure(error, context, wording) {
181
+ const detail = describeFailure(error);
182
+ logger.error(`Genesis assistant: ${context}: ${detail !== null && detail !== void 0 ? detail : '(the rejection named no reason)'}`);
183
+ if (detail && TIMED_OUT.test(detail))
184
+ return wording.timeout;
185
+ return detail && readsLikeProse(detail) ? `${wording.failed}: ${detail}` : `${wording.failed}.`;
186
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * A Genesis field type, as the platform writes it, reduced to the name a lookup can match.
3
+ *
4
+ * @remarks
5
+ * Metadata and schemas carry parameters — `STRING(256)`, `BIGDECIMAL(20,4)` — and every place
6
+ * that reasons about a type has to strip them first. Shared because forgetting it fails
7
+ * SILENTLY, differently each time: a parameterised decimal falls outside the numeric set and is
8
+ * compared as text (a change marked that is not one), or misses the JSON-type map and goes to
9
+ * the wire in the wrong shape. Four call sites each learned that separately; the fifth would
10
+ * have learned it too.
11
+ *
12
+ * Only the PARSING is shared. Each caller keeps its own set of types, because what counts as a
13
+ * date to a formatter is not what counts as a number to a comparator.
14
+ *
15
+ * @internal
16
+ */
17
+ export const genesisTypeName = (type) => String(type !== null && type !== void 0 ? type : '')
18
+ .toUpperCase()
19
+ .split('(')[0]
20
+ .trim();
@@ -0,0 +1,87 @@
1
+ import { genesisTypeName } from './type-name';
2
+ /**
3
+ * Comparing two values that came from different places.
4
+ *
5
+ * @remarks
6
+ * Two callers need this and both would be wrong without it:
7
+ *
8
+ * - the review's **changed** mark, where the left side is the row as read and the right side is
9
+ * the payload the builder produced;
10
+ * - the approve-time **staleness check**, where the left side is the pre-image the review showed
11
+ * and the right side is a fresh re-read.
12
+ *
13
+ * Both sides are normalised HERE rather than by the caller. A property that depends on every
14
+ * future caller remembering which side is raw is not a property — and the two mistakes it
15
+ * prevents are opposite:
16
+ *
17
+ * - comparing raw values marks EVERYTHING as changed (a read stamps a big integer as text while
18
+ * the payload holds a number), which in the staleness check drops every row;
19
+ * - comparing DISPLAY text misses real changes, because display is deliberately lossy: a
20
+ * timestamp rendered to the minute hides a change of seconds, and Genesis does not truncate
21
+ * those — a capture shows `13:27:05` stored as sent.
22
+ */
23
+ /** Digits with at most one point and an optional sign: the forms a number can arrive in. */
24
+ const NUMERIC = /^[-+]?\d+(?:\.\d+)?$/;
25
+ /**
26
+ * Types whose values are numbers, so `007` and `7` are the same value.
27
+ *
28
+ * @remarks
29
+ * Gated on the DECLARED type, never on what the text looks like. A zero-padded account or book
30
+ * code is ordinary in this domain, and canonicalising `'007'` to `'7'` on a STRING field would
31
+ * mark a changed field as unchanged — the same failure this comparator was written to fix,
32
+ * reached from the other end. Nor can the strip simply go: a model can write `'007.50'` on a
33
+ * BIGDECIMAL whose stored value is `7.5`, and comparing those as text marks an unchanged field
34
+ * as changed.
35
+ */
36
+ const NUMERIC_TYPES = new Set([
37
+ 'INT',
38
+ 'INTEGER',
39
+ 'LONG',
40
+ 'SHORT',
41
+ 'DOUBLE',
42
+ 'FLOAT',
43
+ 'BIGDECIMAL',
44
+ 'DECIMAL',
45
+ ]);
46
+ const isNumericType = (type) => NUMERIC_TYPES.has(genesisTypeName(type));
47
+ /**
48
+ * One canonical text for a value, whatever shape it arrived in.
49
+ *
50
+ * @remarks
51
+ * Numbers are canonicalised as TEXT rather than through `Number`: a Genesis LONG beyond 2^53
52
+ * arrives from a read as a decimal string, and parsing it to compare would round exactly the
53
+ * values — ids, sequence numbers — where a wrong answer is worst. So `100.50` and `100.5` are
54
+ * the same value, and `9007199254740993` is not `9007199254740992`.
55
+ *
56
+ * @internal
57
+ */
58
+ export function normaliseValue(value, type) {
59
+ if (value === undefined || value === null)
60
+ return '';
61
+ // `String` already gives 'true'/'false' for a boolean and the digits for a bigint, so both
62
+ // fall through here rather than getting a branch that cannot be tested apart from this one.
63
+ const raw = String(value);
64
+ // Text for everything the metadata does not call a number: a field's type decides this, not
65
+ // the shape of one of its values. And text is compared as it is, surrounding whitespace
66
+ // included — Genesis stores what it is sent, so `'VOD '` is not `'VOD'`, and a trim here made a
67
+ // whitespace-only edit look like no change at all. Only a NUMBER is trimmed, because only its
68
+ // canonical form is what the comparison is about.
69
+ if (!isNumericType(type))
70
+ return raw;
71
+ const text = raw.trim();
72
+ if (!NUMERIC.test(text))
73
+ return raw;
74
+ const negative = text.startsWith('-');
75
+ const [whole, fraction = ''] = text.replace(/^[-+]/, '').split('.');
76
+ const trimmedWhole = whole.replace(/^0+(?=\d)/, '');
77
+ const trimmedFraction = fraction.replace(/0+$/, '');
78
+ const digits = trimmedFraction ? `${trimmedWhole}.${trimmedFraction}` : trimmedWhole;
79
+ // `-0` and `0` are the same value; every other sign is kept.
80
+ return negative && digits !== '0' ? `-${digits}` : digits;
81
+ }
82
+ /**
83
+ * Whether two values are the same value, whichever side each came from.
84
+ *
85
+ * @internal
86
+ */
87
+ export const sameValue = (left, right, type) => normaliseValue(left, type) === normaliseValue(right, type);
@@ -0,0 +1,78 @@
1
+ import { __awaiter } from "tslib";
2
+ import { withTimeout } from '../utils/with-timeout';
3
+ import { plainFailure } from './server-text';
4
+ import { mapWriteReply, writeNotAttempted, writeOutcomeUnknown, } from './write-outcome';
5
+ /** A commit that never settles would leave the turn hanging with rows in an unknown state. */
6
+ const COMMIT_TIMEOUT_MS = 30000;
7
+ /**
8
+ * The server's own NACK, when comms rejected with it instead of resolving.
9
+ *
10
+ * @remarks
11
+ * Only a NACK. A rejection is otherwise the transport giving up, and anything else carried on
12
+ * one is not a reply this bridge can vouch for — least of all an ACK, which would turn a write
13
+ * of unknown fate into a confident "written".
14
+ */
15
+ function rejectedNack(error) {
16
+ var _a;
17
+ const received = error === null || error === void 0 ? void 0 : error.receivedMessage;
18
+ if (!received || typeof received !== 'object')
19
+ return undefined;
20
+ const type = String((_a = received.MESSAGE_TYPE) !== null && _a !== void 0 ? _a : '');
21
+ return type === 'MSG_NACK' || type === 'EVENT_NACK'
22
+ ? received
23
+ : undefined;
24
+ }
25
+ /**
26
+ * Commits rows one at a time, in order, and never throws.
27
+ *
28
+ * @remarks
29
+ * Sequential on purpose: a batch sent in parallel gives the user no way to reason about what
30
+ * happened when the connection drops halfway, and the per-row outcome is what both the user and
31
+ * the model are told. A row that fails does not stop the ones after it — each row is its own
32
+ * decision and its own answer — but every result says whether it reached the database.
33
+ *
34
+ * @internal
35
+ */
36
+ export function commitRows(rows_1, _a) {
37
+ return __awaiter(this, arguments, void 0, function* (rows, { connect, eventName, op, reason, timeoutMs = COMMIT_TIMEOUT_MS }) {
38
+ const results = [];
39
+ for (const row of rows) {
40
+ if (!(connect === null || connect === void 0 ? void 0 : connect.isConnected)) {
41
+ // Not attempted rather than failed: nothing was sent, so nothing can have been written.
42
+ results.push(Object.assign({ index: row.index }, writeNotAttempted('failed', 'The app is not connected to its server, so nothing was written.')));
43
+ continue;
44
+ }
45
+ try {
46
+ // Sequential deliberately, which is why the rule is suppressed rather than obeyed: these
47
+ // are WRITES. Sent in parallel, a connection that drops halfway leaves the user unable to
48
+ // reason about which rows landed, and the per-row outcome is the whole contract here.
49
+ // oxlint-disable-next-line no-await-in-loop -- writes must not race each other
50
+ const reply = yield withTimeout(connect.commitEvent(eventName, Object.assign({ DETAILS: row.details }, (reason ? { REASON: reason } : {}))), timeoutMs);
51
+ results.push(Object.assign({ index: row.index }, mapWriteReply(reply, { mode: 'commit', op })));
52
+ }
53
+ catch (error) {
54
+ // Not every rejection is silence. On the socket path comms REJECTS on a MSG_NACK, with
55
+ // `{ receivedMessage, sentMessage }` (socket.ts, the `nacked` branch), so the router's
56
+ // answer arrived here and was reported as "the app did not answer". Read as the reply it
57
+ // is: a 404 (an unmapped event) is a definite "not written", and any other code stays
58
+ // `unknown` — mapWriteReply decides which, not this catch.
59
+ const nack = rejectedNack(error);
60
+ if (nack) {
61
+ results.push(Object.assign({ index: row.index }, mapWriteReply(nack, { mode: 'commit', op })));
62
+ continue;
63
+ }
64
+ // commitEvent RESOLVES on an EVENT_NACK — a throw here is the transport giving up, and
65
+ // the row's fate is genuinely unknown: the server may have committed it before the
66
+ // connection went. Say that rather than implying it did not happen.
67
+ // The rejection goes through the same allow-list the rest of the bridge uses: comms
68
+ // rejects with a plain object on the socket path, and an Error's message here has carried
69
+ // an internal hostname and port straight to the model vendor.
70
+ results.push(Object.assign({ index: row.index }, writeOutcomeUnknown(plainFailure(error, `${eventName} commit failed`, {
71
+ timeout: 'The app did not answer in time, so whether this was written is unknown.',
72
+ failed: 'The app did not answer, so whether this was written is unknown',
73
+ }))));
74
+ }
75
+ }
76
+ return results;
77
+ });
78
+ }