inamprotocol 0.4.1 → 0.4.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.
@@ -0,0 +1,31 @@
1
+ /**
2
+ * SPEC.md §4.3 — dispute lifecycle. Pure and storage-free, same pattern as
3
+ * receiptVisibility.ts: both runtimes' receiptService/reputationService
4
+ * import this instead of duplicating the logic.
5
+ *
6
+ * Two rules live here:
7
+ *
8
+ * 1. Dispute right is per-party, not per-receipt. A receipt used to record
9
+ * a single "resolved" flag shared by both parties, so whichever party
10
+ * disputed-and-resolved first (self or otherwise) permanently blocked
11
+ * the *other* party from ever disputing — a worker could immunize its
12
+ * own receipt against a real requester complaint by disputing itself and
13
+ * immediately withdrawing. `usedBy` tracks which parties have already
14
+ * spent their one-shot dispute right; each party gets their own.
15
+ * 2. An open dispute that its opener never resolves would otherwise zero
16
+ * out the receipt's reputation contribution forever, at no cost to the
17
+ * opener — a free hostage mechanism. `resolutionDeadline` (set to the
18
+ * same window length as the dispute-opening window itself) lets it lapse:
19
+ * past the deadline, an unresolved dispute stops counting as active for
20
+ * reputation purposes, though it can still be formally resolved later.
21
+ */
22
+ export interface DisputeCheckable {
23
+ status: "draft" | "finalized" | "disputed";
24
+ dispute: {
25
+ status: "none" | "open" | "resolved";
26
+ resolutionDeadline?: string;
27
+ usedBy?: string[];
28
+ };
29
+ }
30
+ export declare function hasUsedDisputeRight(receipt: DisputeCheckable, callerDid: string): boolean;
31
+ export declare function isDisputeActive(receipt: DisputeCheckable, now?: number): boolean;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * SPEC.md §4.3 — dispute lifecycle. Pure and storage-free, same pattern as
3
+ * receiptVisibility.ts: both runtimes' receiptService/reputationService
4
+ * import this instead of duplicating the logic.
5
+ *
6
+ * Two rules live here:
7
+ *
8
+ * 1. Dispute right is per-party, not per-receipt. A receipt used to record
9
+ * a single "resolved" flag shared by both parties, so whichever party
10
+ * disputed-and-resolved first (self or otherwise) permanently blocked
11
+ * the *other* party from ever disputing — a worker could immunize its
12
+ * own receipt against a real requester complaint by disputing itself and
13
+ * immediately withdrawing. `usedBy` tracks which parties have already
14
+ * spent their one-shot dispute right; each party gets their own.
15
+ * 2. An open dispute that its opener never resolves would otherwise zero
16
+ * out the receipt's reputation contribution forever, at no cost to the
17
+ * opener — a free hostage mechanism. `resolutionDeadline` (set to the
18
+ * same window length as the dispute-opening window itself) lets it lapse:
19
+ * past the deadline, an unresolved dispute stops counting as active for
20
+ * reputation purposes, though it can still be formally resolved later.
21
+ */
22
+ export function hasUsedDisputeRight(receipt, callerDid) {
23
+ return (receipt.dispute.usedBy ?? []).includes(callerDid);
24
+ }
25
+ export function isDisputeActive(receipt, now = Date.now()) {
26
+ if (receipt.status !== "disputed" || receipt.dispute.status !== "open")
27
+ return false;
28
+ if (!receipt.dispute.resolutionDeadline)
29
+ return true;
30
+ return now < new Date(receipt.dispute.resolutionDeadline).getTime();
31
+ }
32
+ //# sourceMappingURL=disputeLifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"disputeLifecycle.js","sourceRoot":"","sources":["../../src/core/disputeLifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAWH,MAAM,UAAU,mBAAmB,CAAC,OAAyB,EAAE,SAAiB;IAC9E,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,OAAyB,EAAE,MAAc,IAAI,CAAC,GAAG,EAAE;IACjF,IAAI,OAAO,CAAC,MAAM,KAAK,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,KAAK,MAAM;QAAE,OAAO,KAAK,CAAC;IACrF,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,kBAAkB;QAAE,OAAO,IAAI,CAAC;IACrD,OAAO,GAAG,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,OAAO,EAAE,CAAC;AACtE,CAAC"}
package/dist/types.d.ts CHANGED
@@ -68,6 +68,12 @@ export interface AgentRecord {
68
68
  revokedAt?: string;
69
69
  revocationReason?: string;
70
70
  }
71
+ /** SPEC.md §4.1 — the receipt's own self-declared claim of how its parties
72
+ * say the work was checked, set by agent_b at draft time. **Not** the same
73
+ * as `IndependentVerificationMethod` (§12) below: this is unenforced today
74
+ * (only `payer_confirmation` carries real weight), while a Verification is
75
+ * a separate, signed third-party attestation resource with its own
76
+ * distinct `method` enum. */
71
77
  export type VerificationMethod = "payer_confirmation" | "independent_validator" | "test_suite_pass";
72
78
  export type ReceiptOutcome = "success" | "partial" | "failed";
73
79
  export type ReceiptStatus = "draft" | "finalized" | "disputed";
@@ -111,6 +117,13 @@ export interface ExecutionReceipt {
111
117
  openedBy?: string;
112
118
  resolvedAt?: string;
113
119
  resolution?: string;
120
+ /** SPEC.md §4.3 (v0.22). Set when a dispute is opened; past this point
121
+ * an unresolved dispute stops counting as active for reputation. */
122
+ resolutionDeadline?: string;
123
+ /** SPEC.md §4.3 (v0.22). DIDs that have already disputed-and-resolved
124
+ * this receipt — each party gets one dispute right, tracked separately
125
+ * so one party's resolved dispute can't block the other party's real one. */
126
+ usedBy?: string[];
114
127
  };
115
128
  signatures: {
116
129
  agentB?: string;
@@ -200,11 +213,15 @@ export interface JobRecord {
200
213
  createdAt: string;
201
214
  expiresAt?: string;
202
215
  }
216
+ /** SPEC.md §12 — how an independent Verification's signer actually checked
217
+ * the work. **Not** the same as `VerificationMethod` (§4.1) above: that's
218
+ * the receipt's own unenforced self-declared claim; this is a separate,
219
+ * first-class attestation resource's method, with its own distinct enum. */
220
+ export type IndependentVerificationMethod = "deterministic" | "agent_attestation";
221
+ export type VerificationResult = "verified" | "rejected";
203
222
  /** SPEC.md §12: independent attestation that a finalized receipt's output
204
223
  * actually satisfies its job's requirements. Single verifier, no
205
224
  * draft/countersign step — complete and signed on submission. */
206
- export type IndependentVerificationMethod = "deterministic" | "agent_attestation";
207
- export type VerificationResult = "verified" | "rejected";
208
225
  export interface VerificationRecord {
209
226
  verificationVersion: "1.0";
210
227
  verificationId: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inamprotocol",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Reference TypeScript/JavaScript SDK for the INAM Protocol — agent identity, execution receipts, jobs, and reputation",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",