@emilia-protocol/gate 0.17.0 → 0.18.2
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/CHANGELOG.md +67 -0
- package/README.md +51 -0
- package/admission-store-postgres.js +4 -0
- package/admission-store.js +4 -0
- package/dist/admission-store-postgres.d.ts +66 -0
- package/dist/admission-store-postgres.d.ts.map +1 -0
- package/dist/admission-store-postgres.js +537 -0
- package/dist/admission-store-postgres.js.map +1 -0
- package/dist/admission-store.d.ts +292 -0
- package/dist/admission-store.d.ts.map +1 -0
- package/dist/admission-store.js +777 -0
- package/dist/admission-store.js.map +1 -0
- package/dist/gate-qualification-v2.d.ts +225 -0
- package/dist/gate-qualification-v2.d.ts.map +1 -0
- package/dist/gate-qualification-v2.js +1011 -0
- package/dist/gate-qualification-v2.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/referee-runner.d.ts +35 -0
- package/dist/referee-runner.d.ts.map +1 -0
- package/dist/referee-runner.js +294 -0
- package/dist/referee-runner.js.map +1 -0
- package/dist/referee.d.ts +124 -0
- package/dist/referee.d.ts.map +1 -0
- package/dist/referee.js +434 -0
- package/dist/referee.js.map +1 -0
- package/gate-qualification-v2.js +4 -0
- package/package.json +29 -3
- package/referee-runner.js +3 -0
- package/referee.js +3 -0
- package/src/admission-store-postgres.ts +695 -0
- package/src/admission-store.ts +1065 -0
- package/src/gate-qualification-v2.ts +1534 -0
- package/src/index.ts +5 -0
- package/src/referee-runner.ts +365 -0
- package/src/referee.ts +625 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,73 @@
|
|
|
4
4
|
All notable changes to `@emilia-protocol/gate` are documented here.
|
|
5
5
|
This package follows [Semantic Versioning](https://semver.org/).
|
|
6
6
|
|
|
7
|
+
## 0.18.2 (2026-07-27)
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- `./referee`, a closed, non-authorizing `EP-REFEREE-RESULT-v1` self-test
|
|
12
|
+
evaluator that preserves native verification, relying-party acceptance,
|
|
13
|
+
exact-action matching, evidence satisfaction, provider outcome, and observed
|
|
14
|
+
effect as separate dimensions.
|
|
15
|
+
- `./referee-runner`, a no-shell local subprocess transport with strict JSON,
|
|
16
|
+
executable SHA-256 verification, bounded input/output and time, and
|
|
17
|
+
fail-closed handling for malformed or ambiguous runner behavior.
|
|
18
|
+
|
|
19
|
+
### Security
|
|
20
|
+
|
|
21
|
+
- Referee results are fixed to `claim_scope: SELF_TEST` and
|
|
22
|
+
`execution_authorizing: false`; they cannot authorize, reserve, invoke, or
|
|
23
|
+
certify an action.
|
|
24
|
+
- The transport is not an operating-system sandbox and makes no claim to block
|
|
25
|
+
runner network, filesystem, syscall, or descendant-process access.
|
|
26
|
+
- Retained the independently published
|
|
27
|
+
`@emilia-protocol/verify@3.16.0` registry dependency. Referee does not depend
|
|
28
|
+
on the new Verify AEB-1 reference runner, so Gate keeps its release graph
|
|
29
|
+
honest instead of declaring an unnecessary coupled upgrade.
|
|
30
|
+
|
|
31
|
+
## 0.18.1 (2026-07-27)
|
|
32
|
+
|
|
33
|
+
### Fixed
|
|
34
|
+
|
|
35
|
+
- Repinned the release dependency to the exact published
|
|
36
|
+
`@emilia-protocol/verify@3.16.0` registry tarball. No runtime or API behavior
|
|
37
|
+
changed from 0.18.0; the protected 0.18.0 tag was never published.
|
|
38
|
+
|
|
39
|
+
## 0.18.0 (2026-07-26)
|
|
40
|
+
|
|
41
|
+
### Added
|
|
42
|
+
|
|
43
|
+
- `./gate-qualification-v2`, with pure qualification/AEB/AEC/local-policy
|
|
44
|
+
composition plus shadow, enforcement, and evidence-only reconciliation
|
|
45
|
+
orchestration around a protected adapter.
|
|
46
|
+
- `./admission-store`, a unified immutable admission snapshot, CAS-owned
|
|
47
|
+
lifecycle, one-time execution right, operation/resource fencing,
|
|
48
|
+
predecessor-digest journal, supersession, and remedy reference contract.
|
|
49
|
+
- `./admission-store-postgres`, a deployment-bound PostgreSQL RPC adapter for
|
|
50
|
+
the unified store with single-tenant construction, exact output validation,
|
|
51
|
+
bounded transaction retries, and ambiguous-begin readback handling.
|
|
52
|
+
- Root-package re-exports, generated declarations, compatibility entry points,
|
|
53
|
+
and focused package tests for the qualification and admission modules.
|
|
54
|
+
|
|
55
|
+
### Security
|
|
56
|
+
|
|
57
|
+
- Qualification remains non-authorizing and cannot replace AEB, AEC, or the
|
|
58
|
+
relying party's local authorization policy.
|
|
59
|
+
- Authority is consumed before provider entry; uncertain outcomes remain
|
|
60
|
+
reconciliation-required and cannot be blindly retried.
|
|
61
|
+
- The checked-in memory store is an explicit test-only, non-durable reference.
|
|
62
|
+
The orchestrator and PostgreSQL adapter consume the canonical unified
|
|
63
|
+
`AdmissionStore` contract.
|
|
64
|
+
- Enforcement requires authoritative immediate remeasurement of the candidate,
|
|
65
|
+
qualification status, AEB, AEC, local policy, and protected request before
|
|
66
|
+
transactional consumption. It also requires protected restart-safe custody
|
|
67
|
+
for owner and reconciliation capabilities; memory custody is test-only.
|
|
68
|
+
- Qualification decisions bind the exact protected-request digest and cannot
|
|
69
|
+
be replayed across another otherwise-valid admission.
|
|
70
|
+
- The PostgreSQL adapter is a single-tenant public reference. Managed
|
|
71
|
+
tenant-principal mapping, deployment migrations, federated atomicity, and
|
|
72
|
+
managed service operation are not claimed.
|
|
73
|
+
|
|
7
74
|
## 0.17.0 (2026-07-26)
|
|
8
75
|
|
|
9
76
|
### Added
|
package/README.md
CHANGED
|
@@ -59,6 +59,57 @@ if (!out.ok) throw out.body; // 428 Receipt Required
|
|
|
59
59
|
console.log(out.packet.verdict); // "rely"
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
+
## Gate Qualification v2
|
|
63
|
+
|
|
64
|
+
Gate Qualification v2 treats model or agent qualification as one input to a
|
|
65
|
+
consequence-owning Gate. Qualification never substitutes for AEB, AEC, or the
|
|
66
|
+
relying party's local authorization policy.
|
|
67
|
+
|
|
68
|
+
```js
|
|
69
|
+
import {
|
|
70
|
+
GateQualificationV2,
|
|
71
|
+
composeQualificationDecisionV2,
|
|
72
|
+
createMemoryInvocationAuthorityCustodyV2,
|
|
73
|
+
} from '@emilia-protocol/gate/gate-qualification-v2';
|
|
74
|
+
import {
|
|
75
|
+
createAdmissionSnapshot,
|
|
76
|
+
createMemoryAdmissionStore,
|
|
77
|
+
} from '@emilia-protocol/gate/admission-store';
|
|
78
|
+
import {
|
|
79
|
+
createAdmissionPostgresStore,
|
|
80
|
+
} from '@emilia-protocol/gate/admission-store-postgres';
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`composeQualificationDecisionV2()` is pure and non-mutating. In enforcement
|
|
84
|
+
mode, `GateQualificationV2` requires matching qualification, AEB, AEC, and
|
|
85
|
+
local-policy legs. It requires an authoritative invocation remeasurement and
|
|
86
|
+
protected restart-safe capability custody, then atomically consumes authority
|
|
87
|
+
before entering a caller-supplied protected adapter. Provider commitment and observed effect remain separately
|
|
88
|
+
authenticated facts; an uncertain outcome stays reconciliation-required and
|
|
89
|
+
cannot be retried as fresh work.
|
|
90
|
+
|
|
91
|
+
`createMemoryAdmissionStore()` is a test-only, non-durable, single-process
|
|
92
|
+
reference for the unified immutable snapshot, CAS-owned lifecycle, operation
|
|
93
|
+
and resource fencing, journal, supersession, and remedy contracts.
|
|
94
|
+
It refuses `beginInvocation()` without an explicit currentness oracle;
|
|
95
|
+
`createMemoryInvocationAuthorityCustodyV2()` is likewise test-only and
|
|
96
|
+
non-durable.
|
|
97
|
+
`GateQualificationV2` consumes that canonical `AdmissionStore` contract and
|
|
98
|
+
requires both a durable production store and durable protected authority
|
|
99
|
+
custody unless explicitly constructed for tests.
|
|
100
|
+
|
|
101
|
+
`createAdmissionPostgresStore()` is a deployment-bound, locally atomic and
|
|
102
|
+
durable adapter to an externally installed PostgreSQL RPC contract. Each store
|
|
103
|
+
instance is bound to exactly one deployment and one tenant. This public
|
|
104
|
+
reference does not provide or claim managed tenant-principal mapping, a
|
|
105
|
+
deployment migration, cross-tenant operation, federated atomicity, or managed
|
|
106
|
+
service operation; callers remain responsible for database roles, RPC
|
|
107
|
+
installation, backups, monitoring, and recovery procedures.
|
|
108
|
+
|
|
109
|
+
A `QUALIFIED` verifier result by itself is non-authorizing. It does not grant
|
|
110
|
+
permission, reserve or consume authority, invoke a provider, or establish
|
|
111
|
+
legality or business suitability.
|
|
112
|
+
|
|
62
113
|
## Proposal to effect
|
|
63
114
|
|
|
64
115
|
`@emilia-protocol/gate/proposal-to-effect` closes the loop from an agent's
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deployment-bound PostgreSQL Admission Store.
|
|
3
|
+
*
|
|
4
|
+
* Every mutation is one PostgreSQL function call. The SQL functions use
|
|
5
|
+
* explicit row locks and permanent unique fences; this adapter retries only
|
|
6
|
+
* SQLSTATE 40001 (serialization failure) and 40P01 (deadlock), with the same
|
|
7
|
+
* caller-generated capabilities. It never retries an ambiguous provider
|
|
8
|
+
* effect. A lost beginInvocation acknowledgement is recovered only when an
|
|
9
|
+
* authoritative read proves that this exact invocation-token digest committed.
|
|
10
|
+
*/
|
|
11
|
+
import { type AdmissionStore } from './admission-store.js';
|
|
12
|
+
export interface AdmissionPostgresQueryResult {
|
|
13
|
+
rowCount: number;
|
|
14
|
+
rows?: Array<Record<string, unknown>>;
|
|
15
|
+
}
|
|
16
|
+
export type AdmissionPostgresQuery = (text: string, params: readonly unknown[]) => Promise<AdmissionPostgresQueryResult>;
|
|
17
|
+
export interface CreateAdmissionPostgresStoreOptions {
|
|
18
|
+
query: AdmissionPostgresQuery;
|
|
19
|
+
deploymentId: string;
|
|
20
|
+
tenantId: string;
|
|
21
|
+
/** Test seam only. Production callers should use the cryptographic default. */
|
|
22
|
+
ownerTokenFactory?: () => string;
|
|
23
|
+
/** Test seam only. Production callers should use the cryptographic default. */
|
|
24
|
+
invocationTokenFactory?: () => string;
|
|
25
|
+
/** Number of retries after the first attempt for SQLSTATE 40001/40P01. */
|
|
26
|
+
maxTransactionRetries?: number;
|
|
27
|
+
}
|
|
28
|
+
export interface AdmissionPostgresStore extends AdmissionStore {
|
|
29
|
+
readonly guaranteeClass: 'local_atomic';
|
|
30
|
+
readonly singleTenant: true;
|
|
31
|
+
readonly deploymentBound: true;
|
|
32
|
+
readonly managedTenantPrincipalMapping: false;
|
|
33
|
+
readonly maxTransactionRetries: number;
|
|
34
|
+
}
|
|
35
|
+
export declare const ADMISSION_POSTGRES_SQL: Readonly<{
|
|
36
|
+
reserve: "SELECT public.ep_gate_admission_reserve($1::text, $2::text, $3::jsonb, $4::text) AS result";
|
|
37
|
+
release: "SELECT public.ep_gate_admission_release($1::text, $2::text, $3::text, $4::bigint, $5::text, $6::text) AS result";
|
|
38
|
+
expire: "SELECT public.ep_gate_admission_expire($1::text, $2::text, $3::text, $4::bigint, $5::text) AS result";
|
|
39
|
+
supersede: "SELECT public.ep_gate_admission_supersede($1::text, $2::text, $3::text, $4::bigint, $5::text, $6::jsonb, $7::text) AS result";
|
|
40
|
+
beginInvocation: "SELECT public.ep_gate_admission_begin_invocation($1::text, $2::text, $3::text, $4::bigint, $5::text, $6::text) AS result";
|
|
41
|
+
recoverIndeterminate: "SELECT public.ep_gate_admission_recover_indeterminate($1::text, $2::text, $3::text, $4::text, $5::text) AS result";
|
|
42
|
+
recordProviderOutcome: "SELECT public.ep_gate_admission_record_provider_outcome($1::text, $2::text, $3::text, $4::bigint, $5::text, $6::text, $7::text, $8::text, $9::text) AS result";
|
|
43
|
+
recordEffectRelation: "SELECT public.ep_gate_admission_record_effect_relation($1::text, $2::text, $3::text, $4::bigint, $5::text, $6::text, $7::text, $8::text, $9::text) AS result";
|
|
44
|
+
read: "SELECT public.ep_gate_admission_read($1::text, $2::text, $3::text) AS result";
|
|
45
|
+
readByOperation: "SELECT public.ep_gate_admission_read_by_operation($1::text, $2::text, $3::text) AS result";
|
|
46
|
+
readSnapshot: "SELECT public.ep_gate_admission_read_snapshot($1::text, $2::text, $3::text) AS result";
|
|
47
|
+
journal: "SELECT public.ep_gate_admission_journal($1::text, $2::text, $3::text) AS result";
|
|
48
|
+
checkInvariants: "SELECT public.ep_gate_admission_check_invariants($1::text, $2::text) AS result";
|
|
49
|
+
}>;
|
|
50
|
+
export declare class AdmissionPostgresProtocolError extends Error {
|
|
51
|
+
constructor(message: string, options?: ErrorOptions);
|
|
52
|
+
}
|
|
53
|
+
export declare class AdmissionPostgresAmbiguousBeginError extends Error {
|
|
54
|
+
readonly admissionId: string;
|
|
55
|
+
constructor(admissionId: string, message: string, options?: ErrorOptions);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Creates a durable single-tenant store bound to one installed deployment row.
|
|
59
|
+
* The SQL deliberately has no session-user-to-tenant mapping: database access
|
|
60
|
+
* is the deployment boundary and every RPC rechecks the singleton binding.
|
|
61
|
+
*/
|
|
62
|
+
export declare function createAdmissionPostgresStore(options: CreateAdmissionPostgresStoreOptions): AdmissionPostgresStore;
|
|
63
|
+
/** Compatibility alias following the noun-first naming used by some stores. */
|
|
64
|
+
export declare const createPostgresAdmissionStore: typeof createAdmissionPostgresStore;
|
|
65
|
+
export default createAdmissionPostgresStore;
|
|
66
|
+
//# sourceMappingURL=admission-store-postgres.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admission-store-postgres.d.ts","sourceRoot":"","sources":["../src/admission-store-postgres.ts"],"names":[],"mappings":"AACA;;;;;;;;;GASG;AAIH,OAAO,EAoBL,KAAK,cAAc,EAIpB,MAAM,sBAAsB,CAAC;AAI9B,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACvC;AAED,MAAM,MAAM,sBAAsB,GAAG,CACnC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,SAAS,O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