@ultimat3/action 31.31.0 → 31.32.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/action",
3
- "version": "31.31.0",
3
+ "version": "31.32.0",
4
4
  "description": "The action primitive: one declaration projected to route, OpenAPI, client, MCP tool, job handle, tests",
5
5
  "keywords": [
6
6
  "ultimate",
@@ -48,13 +48,13 @@
48
48
  "test": "bun test"
49
49
  },
50
50
  "dependencies": {
51
- "@ultimat3/cache": "31.31.0",
52
- "@ultimat3/core": "31.31.0",
53
- "@ultimat3/db": "31.31.0",
54
- "@ultimat3/entity": "31.31.0",
55
- "@ultimat3/http": "31.31.0",
56
- "@ultimat3/policy": "31.31.0",
57
- "@ultimat3/schema": "31.31.0",
58
- "@ultimat3/storage": "31.31.0"
51
+ "@ultimat3/cache": "31.32.0",
52
+ "@ultimat3/core": "31.32.0",
53
+ "@ultimat3/db": "31.32.0",
54
+ "@ultimat3/entity": "31.32.0",
55
+ "@ultimat3/http": "31.32.0",
56
+ "@ultimat3/policy": "31.32.0",
57
+ "@ultimat3/schema": "31.32.0",
58
+ "@ultimat3/storage": "31.32.0"
59
59
  }
60
60
  }
package/src/client.ts CHANGED
@@ -33,6 +33,7 @@ import {
33
33
  problemOf,
34
34
  remoteTitleOf,
35
35
  renderedActionPin,
36
+ renderFixShellArg,
36
37
  } from '@ultimat3/core/page';
37
38
  import type { InferInput, InferOutput, StandardSchemaV1 } from '@ultimat3/schema';
38
39
  import type { Action, StreamAction } from './action';
@@ -315,7 +316,7 @@ function toUltimateError(
315
316
  meta: metaFromWire(body['meta']),
316
317
  requestId: body['requestId'],
317
318
  cause: stringOr(body['cause'] ?? body['detail'], `${name} failed with ${status}`),
318
- fix: stringOr(body['fix'], `x actions show ${name} --json`),
319
+ fix: stringOr(body['fix'], `x actions show ${renderFixShellArg(name, '<action-name>')} --json`),
319
320
  // RFC-9457's `type` IS a documentation URI, so a server that sends no `docs` extension has
320
321
  // still offered one. Both travel, in preference order: `??` picked `docs` on presence alone,
321
322
  // so a `javascript:` one hid a perfectly good `type` behind it. `remoteDocs` takes the first
package/src/errors.ts CHANGED
@@ -81,7 +81,7 @@ export class ActionDeniedError extends UltimateError {
81
81
  super({
82
82
  code: refused.code,
83
83
  cause: `${refused.name} denied: ${refused.reason}`,
84
- fix: `x policy explain ${refused.name} --json # shows which clause decided and why`,
84
+ fix: `x policy explain ${renderFixShellArg(refused.name, '<permission>')} --json # shows which clause decided and why`,
85
85
  callerFix: deniedCallerFix(),
86
86
  });
87
87
  this.denial = refused.denial;
@@ -221,7 +221,7 @@ export function postgresIdempotencyStore(
221
221
  };
222
222
  const now = options.now ?? ((): number => liveClock.now().getTime());
223
223
 
224
- const fetch = async (key: string): Promise<IdempotencyRecord | undefined> => {
224
+ const readRecord = async (key: string): Promise<IdempotencyRecord | undefined> => {
225
225
  const rows = await exec.query<IdempotencyRow>(SQL_IDEMPOTENCY_GET, [key, windowSecs]);
226
226
  const row = rows[0];
227
227
  return row === undefined ? undefined : toRecord(row);
@@ -250,7 +250,7 @@ export function postgresIdempotencyStore(
250
250
  ]);
251
251
  const row = claimed[0];
252
252
  if (row !== undefined) return { record: toRecord(row), created: true };
253
- const existing = await fetch(key);
253
+ const existing = await readRecord(key);
254
254
  if (existing !== undefined) return { record: existing, created: false };
255
255
  }
256
256
  // Reported as a fresh reservation rather than a throw would be wrong in the one direction
@@ -302,7 +302,7 @@ export function postgresIdempotencyStore(
302
302
  await exec.query(SQL_IDEMPOTENCY_RELEASE, [key, reservationId]);
303
303
  },
304
304
 
305
- get: fetch,
305
+ get: readRecord,
306
306
 
307
307
  async purgeExpired(): Promise<number> {
308
308
  const rows = await exec.query<{ readonly key: string }>(
@@ -14,6 +14,7 @@ import {
14
14
  logger,
15
15
  MAX_TIMER_MS,
16
16
  runToCompletion,
17
+ timingSafeEqual,
17
18
  tryUseContext,
18
19
  } from '@ultimat3/core';
19
20
  import { adapterSlot } from '@ultimat3/core/adapter';
@@ -296,7 +297,9 @@ export async function withIdempotency<T>(
296
297
  );
297
298
  const requestHash = keyedFingerprint(input, IDEMPOTENCY_FINGERPRINT_PURPOSE);
298
299
  const { record, created } = await store.reserve(key, requestHash);
299
- if (record.requestHash !== requestHash) assertSamePayload(key, record.requestHash, input);
300
+ // Keyed fingerprints, and the request side is the caller's to vary: compared in constant time.
301
+ if (!timingSafeEqual(record.requestHash, requestHash))
302
+ assertSamePayload(key, record.requestHash, input);
300
303
  if (!created) {
301
304
  if (record.status === 'in-flight') throw new IdempotencyConflictError(key, 'in-flight');
302
305
  if (record.status === 'failed') throw new IdempotencyReplayedFailureError(key, record.failure);