-
Notifications
You must be signed in to change notification settings - Fork 6
[kafka pr-1 · 02/6] Slice 02 — Explicit local-vs-shared CG choice + lazy kafka-local #391
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
Open
zsculac
wants to merge
9
commits into
feat/kafka-walking-skeleton
Choose a base branch
from
feat/kafka-explicit-cg
base: feat/kafka-walking-skeleton
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b97eb18
feat(kafka): explicit local-vs-shared CG selection in package
ee3b1cc
feat(kafka): explicit local-vs-shared CG choice on the endpoint API
56d9137
test(kafka): cover defensive branches and ratchet kafka coverage floors
0fe2580
refactor(kafka): polish slice 02 per code review
a4e7790
refactor(kafka): polish slice 02 for clarity and decoupling
d4e444e
docs(kafka): restore non-obvious rationale lost in polish 2
23a12f5
fix(kafka): reject reserved id and treat useLocalCg:false as omission
381fd35
fix(kafka): scope kafka-local id to peer-id and force private: true
6d5add6
fix(kafka): verify CG privacy on reuse and after race-create
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| // Adapters that bind the daemon's `DKGAgent` to the small interfaces the | ||
| // `@origintrail-official/dkg-kafka` package depends on. Kept on the CLI side | ||
| // because the agent type lives here; the kafka package stays agent-agnostic. | ||
| // | ||
| // Slice 02 only consumes these from `routes/kafka.ts`; later kafka routes | ||
| // (discover, revoke) will reuse them — one home, one responsibility each. | ||
|
|
||
| import type { DKGAgent } from '@origintrail-official/dkg-agent'; | ||
| import type { | ||
| KafkaEndpointPublisher, | ||
| LocalCgPrimitive, | ||
| } from '@origintrail-official/dkg-kafka'; | ||
|
|
||
| /** | ||
| * Wraps `agent.publish` with the daemon's `{ public: content }` envelope so | ||
| * the kafka package can stay envelope-agnostic. | ||
| */ | ||
| export function kafkaPublisherFromAgent(agent: DKGAgent): KafkaEndpointPublisher { | ||
| return { | ||
| async publish(contextGraphId, knowledgeAsset) { | ||
| await agent.publish( | ||
| contextGraphId, | ||
| { public: knowledgeAsset } as Record<string, unknown>, | ||
| ); | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * Adapts the agent's free-CG surface to the `LocalCgPrimitive` shape the | ||
| * kafka-local ensurer consumes. `callerAgentAddress` is threaded into | ||
| * `createContextGraph` so the create runs under the requesting agent. | ||
| * | ||
| * The `private: true` flag is hardcoded HERE — the kafka package never sees | ||
| * the boolean, so a future refactor cannot accidentally drop it. Without | ||
| * `private: true`, the agent auto-subscribes to the CG's gossip topic and | ||
| * broadcasts the CG definition (`dkg-agent.ts:3837`); the slice-02 spec | ||
| * requires kafka-local to be truly node-local, which means no gossip. | ||
| */ | ||
| export function kafkaLocalCgFromAgent( | ||
| agent: DKGAgent, | ||
| callerAgentAddress: string, | ||
| ): LocalCgPrimitive { | ||
| return { | ||
| contextGraphExists: (id) => agent.contextGraphExists(id), | ||
| isPrivateContextGraph: (id) => agent.isPrivateContextGraph(id), | ||
| createPrivateContextGraph: (opts) => | ||
| agent.createContextGraph({ | ||
| ...opts, | ||
| private: true, | ||
| callerAgentAddress, | ||
| }), | ||
| }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.