-
Notifications
You must be signed in to change notification settings - Fork 6
fix: consolidated V10 API hardening + finality principle (supersedes #105, #106, #107) #108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
113b7ae
cb1adbc
3bd6d9c
5df9bd7
0f97e77
970f27b
2f09d31
ef5c1a5
b4f1e7f
1447790
1fc10ff
77941df
286e504
aebbb42
b9cd210
83bc515
c805265
96418c8
d37f3ca
80935d0
53c07c8
6a765e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -372,9 +372,9 @@ export class DkgNodePlugin { | |
| name: 'dkg_publish', | ||
| description: | ||
| 'Publish knowledge to a DKG context graph as an array of quads (subject/predicate/object). ' + | ||
| 'Data is first written to Shared Working Memory, then published to Verified Memory on-chain. ' + | ||
| 'Object values that look like URIs (http://, https://, urn:, did:) are treated as URIs; ' + | ||
| 'all other values become string literals automatically. ' + | ||
| 'By default, published data is private (ownerOnly). Set access_policy to "public" to make it readable by anyone.', | ||
| 'all other values become string literals automatically.', | ||
| parameters: { | ||
| type: 'object', | ||
| properties: { | ||
|
|
@@ -395,19 +395,6 @@ export class DkgNodePlugin { | |
| 'Array of quads to publish. Each quad has subject (URI), predicate (URI), and object (URI or literal string). ' + | ||
| 'URIs are auto-detected by prefix (http://, https://, urn:, did:); everything else becomes a literal.', | ||
| }, | ||
| access_policy: { | ||
| type: 'string', | ||
| enum: ['public', 'ownerOnly', 'allowList'], | ||
| description: | ||
| 'Access control: "ownerOnly" (only you can read — the default), ' + | ||
| '"public" (anyone can read), or "allowList" (only listed peers).', | ||
| }, | ||
| allowed_peers: { | ||
| type: 'string', | ||
| description: | ||
| 'Comma-separated peer IDs allowed to read the data. ' + | ||
| 'Required when access_policy is "allowList". Must not be set for other policies.', | ||
| }, | ||
| }, | ||
| required: ['context_graph_id', 'quads'], | ||
| }, | ||
|
|
@@ -566,43 +553,8 @@ export class DkgNodePlugin { | |
| }; | ||
| }); | ||
|
|
||
| // Access policy: default to ownerOnly (private) when not specified | ||
| const VALID_POLICIES = new Set(['public', 'ownerOnly', 'allowList']); | ||
| const accessPolicy = args.access_policy | ||
| ? String(args.access_policy).trim() | ||
| : 'ownerOnly'; | ||
|
|
||
| if (!VALID_POLICIES.has(accessPolicy)) { | ||
| return this.error( | ||
| `Invalid access_policy "${accessPolicy}". Must be one of: ${[...VALID_POLICIES].join(', ')}.`, | ||
| ); | ||
| } | ||
|
|
||
| // Parse allowed_peers from comma-separated string | ||
| let allowedPeers: string[] | undefined; | ||
| if (args.allowed_peers) { | ||
| allowedPeers = String(args.allowed_peers) | ||
| .split(',') | ||
| .map(p => p.trim()) | ||
| .filter(p => p.length > 0); | ||
| } | ||
|
|
||
| if (accessPolicy === 'allowList' && (!allowedPeers || allowedPeers.length === 0)) { | ||
| return this.error( | ||
| '"allowList" access_policy requires non-empty "allowed_peers" (comma-separated peer IDs).', | ||
| ); | ||
| } | ||
| if (accessPolicy !== 'allowList' && allowedPeers && allowedPeers.length > 0) { | ||
| return this.error( | ||
| '"allowed_peers" is only valid when access_policy is "allowList".', | ||
| ); | ||
| } | ||
|
|
||
| const result = await this.client.publish(contextGraphId, quads, undefined, { | ||
| accessPolicy: accessPolicy as 'public' | 'ownerOnly' | 'allowList', | ||
| allowedPeers, | ||
| }); | ||
| return this.json({ kcId: result.kcId, kaCount: result.kas?.length ?? 0, quadsPublished: quads.length, accessPolicy }); | ||
| const result = await this.client.publish(contextGraphId, quads); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Bug: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Bug: |
||
| return this.json({ kcId: result.kcId, kaCount: result.kas?.length ?? 0, quadsPublished: quads.length }); | ||
| } catch (err: any) { | ||
| return this.daemonError(err); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -188,12 +188,16 @@ export class DkgDaemonClient { | |
| privateQuads?: Array<{ subject: string; predicate: string; object: string; graph?: string }>, | ||
| opts?: { accessPolicy?: 'public' | 'ownerOnly' | 'allowList'; allowedPeers?: string[] }, | ||
| ): Promise<any> { | ||
| return this.post('/api/publish', { | ||
| contextGraphId, | ||
| quads, | ||
| privateQuads, | ||
| accessPolicy: opts?.accessPolicy, | ||
| allowedPeers: opts?.allowedPeers, | ||
| if (privateQuads?.length || opts?.accessPolicy || opts?.allowedPeers?.length) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Bug: |
||
| throw new Error( | ||
| 'privateQuads, accessPolicy, and allowedPeers are not supported in V10 SWM-first publish', | ||
| ); | ||
| } | ||
| await this.post('/api/shared-memory/write', { paranetId: contextGraphId, quads }); | ||
| return this.post('/api/shared-memory/publish', { | ||
| paranetId: contextGraphId, | ||
| selection: 'all', | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Bug: |
||
| clearAfter: true, | ||
| }); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 Bug:
dkg_publishused to default toownerOnlyand allowedallowList, but this now always goes through the SWM-first public publish path with no privacy controls. Existing agents that still sendaccess_policy/allowed_peerswill have those fields ignored and can unintentionally publish data more broadly than before. Either preserve access-policy support here or fail explicitly when legacy privacy args are passed.