Skip to content

ddoJs for v5#131

Merged
alexcos20 merged 55 commits into
mainfrom
feat/ddojs-commands
Jul 22, 2026
Merged

ddoJs for v5#131
alexcos20 merged 55 commits into
mainfrom
feat/ddojs-commands

Conversation

@AdriGeorge

@AdriGeorge AdriGeorge commented Sep 15, 2025

Copy link
Copy Markdown
Collaborator

Fixes # .

Changes proposed in this PR:

  • integrated policy server
  • allow publish v5 with ddo.js
  • download v5 with ddo.js throw command: npm run cli download did path serviceId
  • start free compute for v5 with ddo.js
  • start paid compute for v5 with ddo.js
  • publish algo v5 with ddo.js
  • allow/disallow algo v5 with ddo.js
  • added metadata example for dataset and algo v5
  • edit download to accept optionally serviceId
  • edit startFreeCompute/startCompute to accept optionally serviceIds and algoServiceId
  • README
  • update tests

need to set also env for v5 like:

  • export SSI_WALLET_API=""
  • export SSI_WALLET_ID=""
  • export SSI_WALLET_DID="" (this is optional, if not settet, will use the first one)

Summary by CodeRabbit

  • New Features

    • Added service targeting for download and compute start commands, including optional algorithm service selection and multi-service --services support.
    • Added optional SSI wallet environment variables for v5 credential flows; job status now accepts an optional agreementId.
  • Documentation

    • Updated publish/setup guidance and expanded CLI examples/options for v5, including named options per command.
    • Added v5 metadata examples for datasets and algorithms.
  • Bug Fixes

    • Improved validation and compute ordering/compatibility checks for service-aware workflows.
  • Tests

    • Added/updated integration tests for v5 publishing and paid/free compute using explicit service IDs; improved CLI/test stability.

@AdriGeorge
AdriGeorge marked this pull request as ready for review September 19, 2025 07:40
@alexcos20
alexcos20 self-requested a review February 6, 2026 12:02

@alexcos20 alexcos20 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@alexcos20 alexcos20 added the doNotMerge not merge yet label Feb 6, 2026
@AdriGeorge
AdriGeorge force-pushed the feat/ddojs-commands branch from 6f3c32d to c9fa4d2 Compare March 10, 2026 07:50
@AdriGeorge
AdriGeorge force-pushed the feat/ddojs-commands branch from 79dff9c to c9fa4d2 Compare April 7, 2026 11:12
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@alexcos20, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 43 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3c6ad495-bcbe-4ed9-ba18-c826cf9ac8e8

📥 Commits

Reviewing files that changed from the base of the PR and between 701374b and 498ed25.

📒 Files selected for processing (1)
  • src/commands.ts
📝 Walkthrough

Walkthrough

The CLI adds explicit dataset and algorithm service selection, DDO-derived metadata handling, and SSI wallet policy-server flows for downloads and compute. Versioned metadata fixtures, command documentation, ESLint settings, and integration tests are also updated.

Changes

Service-aware compute and policy-server integration

Layer / File(s) Summary
Policy-server contracts and SSI wallet orchestration
src/policyServerInterfaces.ts, src/policyServerHelper.ts, package.json
Adds policy-server types and SSI wallet helpers for credential presentation, wallet sessions, presentation definitions, and policy-object retrieval; adds axios.
DDO metadata and service ordering
src/helpers.ts, src/commands.ts, metadata/*.json, test/consumeFlow.test.ts
Uses DDO-derived metadata and services for publishing, downloading, metadata updates, trusted algorithms, and orderability validation; adds v5 metadata fixtures and publish coverage.
CLI service selection and compute integration
src/cli.ts, src/commands.ts, test/paidComputeFlow.test.ts, test/setup.test.ts
Adds service options and validation to download and compute commands, passes policy-server data into provider calls, and updates compute and help-output tests.
Documentation and tooling support
README.md, eslint.config.mjs, test/interactivePublishFlow.ts, test/accessList.test.ts
Documents SSI wallet and service options, updates ESLint globals and ignores, and guards interactive stdin writes.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant PolicyServer
  participant SSIWallet
  participant Provider
  participant Signer
  CLI->>PolicyServer: Request credential presentation
  PolicyServer-->>CLI: Return OpenID4VC session data
  CLI->>PolicyServer: Retrieve presentation definition
  CLI->>Signer: Sign wallet nonce
  Signer-->>CLI: Return signed nonce
  CLI->>SSIWallet: Match and submit credentials
  SSIWallet-->>CLI: Return presentation result
  CLI->>Provider: Start download or compute with policy objects
  Provider-->>CLI: Return operation result
Loading

Suggested reviewers: giurgiur99, ndrpp, bogdanfazakas, andreip136

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is related to the change, but it is too vague to convey the main scope of the PR. Rename it to something more specific, such as "Add v5 ddo.js policy server support".
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/ddojs-commands

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/cli.ts (1)

382-384: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Stale confirmation message references a non-existent --yes flag. The auto-confirm option is --accept; the log should say so to avoid confusing users.

Proposed fix
-          console.log(chalk.cyan("Auto-confirm enabled with --yes flag."));
+          console.log(chalk.cyan("Auto-confirm enabled with --accept flag."));
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/cli.ts` around lines 382 - 384, Update the auto-confirm log message in
the CLI branch around the --accept handling to reference the existing --accept
option instead of the non-existent --yes flag, preserving the current
informational behavior.
🧹 Nitpick comments (1)
eslint.config.mjs (1)

8-8: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Scope browser globals instead of enabling them globally.

Merging globals.browser into the repository-wide config makes names such as window and document valid in Node CLI code, weakening no-undef checks. Keep Node globals globally and add browser globals only through a browser-specific override if needed.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@eslint.config.mjs` at line 8, Update the repository-wide ESLint configuration
object to remove globals.browser from the global languageOptions.globals merge,
retaining globals.node globally. If browser files require those names, add
globals.browser only in a targeted browser-specific override rather than
enabling them for Node CLI code.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@README.md`:
- Around line 96-99: Correct the README examples: remove the duplicated export
keyword from SSI_WALLET_DID, change both compute example flags from
----algo-service to --algo-service, fix serviceEnpoint to serviceEndpoint, and
add an appropriate language hint to the fenced block containing the SSI
environment variables.

In `@src/commands.ts`:
- Line 343: Update the initArgs construction in the command initialization flow
to pass the resolved outputLocation instead of the raw positional output value.
Keep computeArgs and the existing output resolution logic unchanged so --output
values reach initializeCompute consistently.
- Around line 1293-1298: Update the guard in the disallowAlgo flow in
commands.ts to return the error only when
services[0].compute.publisherTrustedAlgorithms is absent or empty, allowing
findIndex and splice to run when trusted algorithms exist. Replace the copied
compute-service error text with a message accurately describing the missing
trusted-algorithm list.

In `@src/policyServerHelper.ts`:
- Line 376: Replace the lexicographic version gates at src/policyServerHelper.ts
lines 376 and 393 and src/commands.ts line 224 with semver-aware parsing or
comparison, preserving each gate’s existing threshold and behavior for missing
or older versions. Use the project’s established semver utility if available.
- Around line 392-395: Update the algorithm validation in the surrounding
policy-building function so the version check runs only when algo is present;
when algo is null or undefined, preserve and return the dataset actions already
collected in results. Keep returning null for present algorithms missing a
version or below version 5.0.0.
- Around line 29-31: Update the catch blocks in connectToSSIWallet,
sendPresentationRequest, resolvePresentationRequest, getWalletDids, and
matchCredentialForPresentationDefinition to throw error.response when available,
otherwise throw the original error. Preserve the existing HTTP-response
propagation behavior while retaining the underlying axios error for network and
timeout failures.

In `@src/policyServerInterfaces.ts`:
- Around line 49-60: Remove the second duplicate declaration of
PolicyServerInitiateComputeActionData in policyServerInterfaces.ts, preserving
the first interface and its documentId and serviceId members unchanged.

---

Outside diff comments:
In `@src/cli.ts`:
- Around line 382-384: Update the auto-confirm log message in the CLI branch
around the --accept handling to reference the existing --accept option instead
of the non-existent --yes flag, preserving the current informational behavior.

---

Nitpick comments:
In `@eslint.config.mjs`:
- Line 8: Update the repository-wide ESLint configuration object to remove
globals.browser from the global languageOptions.globals merge, retaining
globals.node globally. If browser files require those names, add globals.browser
only in a targeted browser-specific override rather than enabling them for Node
CLI code.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a3714655-1e2b-4b56-9b69-57e304024ce6

📥 Commits

Reviewing files that changed from the base of the PR and between d55c5fa and 85bb53b.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (15)
  • README.md
  • eslint.config.mjs
  • metadata/jsAlgoV5.json
  • metadata/simpleDownloadDatasetV5.json
  • package.json
  • src/cli.ts
  • src/commands.ts
  • src/helpers.ts
  • src/policyServerHelper.ts
  • src/policyServerInterfaces.ts
  • test/accessList.test.ts
  • test/consumeFlow.test.ts
  • test/interactivePublishFlow.ts
  • test/paidComputeFlow.test.ts
  • test/setup.test.ts
💤 Files with no reviewable changes (1)
  • test/accessList.test.ts

Comment thread README.md
Comment thread src/commands.ts
const algoServiceIdInput = args[9] as string | undefined;
if (typeof algoServiceIdInput === "string" && algoServiceIdInput.trim().length > 0) {
const expectedAlgoServiceId = algoServiceIdInput.trim();
const matchAlgoSvc = servicesAlgo.find((s: any) => s.id === expectedAlgoServiceId);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

initArgs uses raw positional output instead of resolved outputLocation. outputLocation = options.output || output is computed at Line 312, and computeArgs (Line 386) correctly uses it, but initArgs here passes the bare positional output. When the user supplies --output, initializeCompute receives undefined at that slot. Use outputLocation for consistency.

🧰 Tools
🪛 GitHub Check: lint

[warning] 343-343:
Unexpected any. Specify a different type

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/commands.ts` at line 343, Update the initArgs construction in the command
initialization flow to pass the resolved outputLocation instead of the raw
positional output value. Keep computeArgs and the existing output resolution
logic unchanged so --output values reach initializeCompute consistently.

Comment thread src/commands.ts Outdated
Comment thread src/policyServerHelper.ts
Comment thread src/policyServerHelper.ts Outdated
Comment thread src/policyServerHelper.ts Outdated
Comment thread src/policyServerInterfaces.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/commands.ts (1)

244-251: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Fix string semver comparison and adhere to CLI error guidelines.

Comparing semantic versions as strings (e.g., '10.0.0' >= '5.0.0') leads to logic errors because '10' is lexicographically smaller than '5'. Parse the major version as an integer instead.

Additionally, as per coding guidelines:

  • Always include semicolons.
  • Use the chalk library for colored console output in error messages.
  • Use process.exit(1) for CLI exit codes instead of throwing unhandled errors that dump a stack trace.
🐛 Proposed fix
-		let policyServer = null
+		let policyServer = null;
		try {
-			if (version >= '5.0.0') {
+			if (version && parseInt(version.split('.')[0], 10) >= 5) {
				policyServer = await getPolicyServerOBJ(dataDdo, serviceId, this.signer, this.oceanNodeUrl);
			}
		} catch (error) {
-			throw new Error('Error getting Policy Server Object: ' + error.message)
+			console.error(chalk.red('Error getting Policy Server Object: ' + (error as Error).message));
+			process.exit(1);
		}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/commands.ts` around lines 244 - 251, The policy-server version gate in
the command flow must parse the major component of version as an integer before
comparing it with 5, avoiding lexicographic semver errors. Update the catch
handling around getPolicyServerOBJ to follow CLI guidelines: use semicolons,
report the failure with chalk-colored console output, and terminate via
process.exit(1) instead of throwing an unhandled Error.

Source: Coding guidelines

♻️ Duplicate comments (1)
src/commands.ts (1)

1315-1320: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Inverted guard makes disallowAlgo always fail.

This returns an error whenever publisherTrustedAlgorithms exists—but the list must exist for there to be anything to remove. The condition should be negated. Additionally, update the error handling to follow the CLI guidelines for formatting and exit codes.

🐛 Proposed fix
-		if (services[0].compute.publisherTrustedAlgorithms) {
+		if (!services[0].compute.publisherTrustedAlgorithms) {
-      console.error(
-        " " + args[1] + ".  Does this asset has an computeService?"
-      );
+      console.error(
+        chalk.red(`${args[1]} has no publisherTrustedAlgorithms to update.`)
+      );
-      return;
+      process.exit(1);
    }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/commands.ts` around lines 1315 - 1320, Update the guard in the
disallowAlgo command around services[0].compute.publisherTrustedAlgorithms so it
errors only when the list is absent, allowing removal when it exists. Revise the
error output and termination behavior to follow the CLI’s established formatting
and exit-code conventions.

Source: Coding guidelines

🧹 Nitpick comments (3)
src/commands.ts (3)

367-371: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use chalk.red and process.exit(1) for CLI errors.

As per coding guidelines, CLI tools should use the chalk library to colorize error messages and process.exit(1) to appropriately signal an error exit code to the shell, rather than simply exiting the function via a return;.

  • src/commands.ts#L367-L371: Wrap the error message in chalk.red() and replace return; with process.exit(1);.
  • src/commands.ts#L235-L238: Wrap the error message in chalk.red() and replace return; with process.exit(1);.
  • src/commands.ts#L266-L269: Wrap the error message in chalk.red() and replace return; with process.exit(1);.
  • src/commands.ts#L403-L407: Wrap the error message in chalk.red() and replace return; with process.exit(1);.
  • src/commands.ts#L425-L428: Wrap the error message in chalk.red() and replace return; with process.exit(1);.
  • src/commands.ts#L624-L628: Wrap the error message in chalk.red() and replace return; with process.exit(1);.
  • src/commands.ts#L634-L637: Wrap the error message in chalk.red() and replace return; with process.exit(1);.
  • src/commands.ts#L672-L676: Wrap the error message in chalk.red() and replace return; with process.exit(1);.
  • src/commands.ts#L688-L691: Wrap the error message in chalk.red() and replace return; with process.exit(1);.
  • src/commands.ts#L702-L705: Wrap the error message in chalk.red() and replace return; with process.exit(1);.
  • src/commands.ts#L1023-L1027: Wrap the error message in chalk.red() and replace return; with process.exit(1);.
  • src/commands.ts#L1059-L1063: Wrap the error message in chalk.red() and replace return; with process.exit(1);.
  • src/commands.ts#L1081-L1084: Wrap the error message in chalk.red() and replace return; with process.exit(1);.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/commands.ts` around lines 367 - 371, Update each listed error-handling
site in src/commands.ts—lines 235-238, 266-269, 367-371, 403-407, 425-428,
624-628, 634-637, 672-676, 688-691, 702-705, 1023-1027, 1059-1063, and
1081-1084—to pass the existing CLI error message through chalk.red and call
process.exit(1) instead of returning. Preserve the current error messages and
surrounding command behavior.

Source: Coding guidelines


352-357: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Extract inline object types to an interface.

As per coding guidelines, use interfaces for defining object types in TypeScript rather than repeating the same inline structures across the file.

  • src/commands.ts#L352-L357: Extract this inline type to a shared interface (e.g., PolicyAsset) and use it here.
  • src/commands.ts#L385-L390: Use the new interface here for the array type.
  • src/commands.ts#L608-L613: Use the new interface here.
  • src/commands.ts#L651-L656: Use the new interface here for the array type.
  • src/commands.ts#L1008-L1013: Use the new interface here.
  • src/commands.ts#L1041-L1046: Use the new interface here for the array type.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/commands.ts` around lines 352 - 357, Extract the repeated inline object
shape into a shared PolicyAsset interface, then replace each occurrence in
src/commands.ts at lines 352-357, 385-390, 608-613, 651-656, 1008-1013, and
1041-1046 with that interface, preserving the existing optional version property
and array usage.

Source: Coding guidelines


365-365: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Avoid any type overrides and loosely typed array callbacks.

As per coding guidelines, avoid using the any type. Replace instances of any with a strictly typed definition or an appropriate interface.

  • src/commands.ts#L365-L365: Replace (s: any) with a strict type (e.g., (s: { id: string; serviceEndpoint?: string })).
  • src/commands.ts#L116-L116: Replace (services[0].files as any) with a strictly typed cast or unknown.
  • src/commands.ts#L151-L151: Replace (services[0].files as any) with a strictly typed cast or unknown.
  • src/commands.ts#L401-L401: Replace (s: any) with a strict type.
  • src/commands.ts#L622-L622: Replace (s: any) with a strict type.
  • src/commands.ts#L632-L632: Replace (s: any) with a strict type.
  • src/commands.ts#L670-L670: Replace (s: any) with a strict type.
  • src/commands.ts#L686-L686: Replace (s: any) with a strict type.
  • src/commands.ts#L1021-L1021: Replace (s: any) with a strict type.
  • src/commands.ts#L1057-L1057: Replace (s: any) with a strict type.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/commands.ts` at line 365, Replace all loose any usage in
src/commands.ts:365-365, 401-401, 622-622, 632-632, 670-670, 686-686, 1021-1021,
and 1057-1057 with explicit service callback types matching the accessed fields,
including the matchAlgoSvc lookup; replace the files casts at
src/commands.ts:116-116 and 151-151 with an appropriate strict files type or
unknown followed by validation. Preserve the existing callback behavior while
ensuring all service arrays and file values are type-safe.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/commands.ts`:
- Around line 244-251: The policy-server version gate in the command flow must
parse the major component of version as an integer before comparing it with 5,
avoiding lexicographic semver errors. Update the catch handling around
getPolicyServerOBJ to follow CLI guidelines: use semicolons, report the failure
with chalk-colored console output, and terminate via process.exit(1) instead of
throwing an unhandled Error.

---

Duplicate comments:
In `@src/commands.ts`:
- Around line 1315-1320: Update the guard in the disallowAlgo command around
services[0].compute.publisherTrustedAlgorithms so it errors only when the list
is absent, allowing removal when it exists. Revise the error output and
termination behavior to follow the CLI’s established formatting and exit-code
conventions.

---

Nitpick comments:
In `@src/commands.ts`:
- Around line 367-371: Update each listed error-handling site in
src/commands.ts—lines 235-238, 266-269, 367-371, 403-407, 425-428, 624-628,
634-637, 672-676, 688-691, 702-705, 1023-1027, 1059-1063, and 1081-1084—to pass
the existing CLI error message through chalk.red and call process.exit(1)
instead of returning. Preserve the current error messages and surrounding
command behavior.
- Around line 352-357: Extract the repeated inline object shape into a shared
PolicyAsset interface, then replace each occurrence in src/commands.ts at lines
352-357, 385-390, 608-613, 651-656, 1008-1013, and 1041-1046 with that
interface, preserving the existing optional version property and array usage.
- Line 365: Replace all loose any usage in src/commands.ts:365-365, 401-401,
622-622, 632-632, 670-670, 686-686, 1021-1021, and 1057-1057 with explicit
service callback types matching the accessed fields, including the matchAlgoSvc
lookup; replace the files casts at src/commands.ts:116-116 and 151-151 with an
appropriate strict files type or unknown followed by validation. Preserve the
existing callback behavior while ensuring all service arrays and file values are
type-safe.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f8c63837-eff9-4f09-8e4f-ba249ad48487

📥 Commits

Reviewing files that changed from the base of the PR and between 01b6f3a and a22adda.

📒 Files selected for processing (1)
  • src/commands.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
src/commands.ts (3)

1312-1318: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Initialize the trusted-algorithm list before pushing.

disallowAlgo now handles an absent list, but allowAlgo still crashes when publisherTrustedAlgorithms is omitted. Initialize it first.

Proposed fix
-    services[0].compute.publisherTrustedAlgorithms.push(trustedAlgorithm);
+    const trustedAlgorithms =
+      services[0].compute.publisherTrustedAlgorithms ?? [];
+    services[0].compute.publisherTrustedAlgorithms = trustedAlgorithms;
+    trustedAlgorithms.push(trustedAlgorithm);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/commands.ts` around lines 1312 - 1318, Update the allowAlgo flow around
the trustedAlgorithm construction to initialize
services[0].compute.publisherTrustedAlgorithms to an empty list when it is
absent before calling push. Preserve the existing trustedAlgorithm contents and
append behavior when the list already exists.

291-331: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Order the selected download service.

serviceId is used for policy retrieval and getDownloadUrl, but orderAsset(...) receives neither that ID nor a service index. Selecting a non-default service therefore obtains its URL using an order for the default service, which can fail authorization. Make ordering service-aware too.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/commands.ts` around lines 291 - 331, The orderAsset call in the command
flow must target the selected serviceId, matching the policy retrieval and
ProviderInstance.getDownloadUrl calls. Update orderAsset’s invocation and, if
necessary, its implementation to accept and use the selected service identifier
or corresponding service index, while preserving the existing default-service
behavior when no service is specified.

970-975: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Fetch policies before submitting paid orders.

Algorithm and dataset orders are sent in Lines 775-825 before this policy-server call. If policy resolution fails, the command aborts after the user has paid/locked funds but before starting a job. Resolve and validate policies before any handleComputeOrder call.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/commands.ts` around lines 970 - 975, Move the getPolicyServerOBJs call
and its policy validation earlier in the command flow, before any
handleComputeOrder invocation for algorithm or dataset orders. Ensure policy
resolution completes successfully before paid orders are submitted, while
preserving the existing order-submission behavior after validation.
🧹 Nitpick comments (2)
src/commands.ts (2)

35-35: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Format the touched imports with Prettier.

The new imports omit semicolons, and Line 40 uses double quotes. As per coding guidelines: “Use Prettier for code formatting with 2-space indentation, single quotes preferred, and always include semicolons.”

Also applies to: 40-40

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/commands.ts` at line 35, Format the touched imports and the string
literal in src/commands.ts with Prettier: use single quotes, include semicolons,
and preserve the project’s 2-space indentation. Update the import declaration
containing Asset, DDOManager, and validateDDO, plus the double-quoted expression
at line 40.

Source: Coding guidelines


82-125: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Replace the new any types with narrow types.

The validation helpers introduce all five lint warnings. Define a minimal DDO validation interface and use unknown plus narrowing for caught errors and validation output. As per coding guidelines: “Avoid any type; use unknown if necessary” and “Use interfaces for defining object types in TypeScript.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/commands.ts` around lines 82 - 125, Replace the any types in
fillNodeManagedAddresses and validateBeforePublish with a minimal DDO validation
interface and unknown-based types. Define interfaces for the accessed DDO,
subject, service, file, indexedMetadata, and stats fields, and type the
validation result without any. Change the caught error to unknown and narrow it
before logging or extracting details, while preserving the existing validation
behavior and untouched original asset.

Sources: Coding guidelines, Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/commands.ts`:
- Around line 1312-1318: Update the allowAlgo flow around the trustedAlgorithm
construction to initialize services[0].compute.publisherTrustedAlgorithms to an
empty list when it is absent before calling push. Preserve the existing
trustedAlgorithm contents and append behavior when the list already exists.
- Around line 291-331: The orderAsset call in the command flow must target the
selected serviceId, matching the policy retrieval and
ProviderInstance.getDownloadUrl calls. Update orderAsset’s invocation and, if
necessary, its implementation to accept and use the selected service identifier
or corresponding service index, while preserving the existing default-service
behavior when no service is specified.
- Around line 970-975: Move the getPolicyServerOBJs call and its policy
validation earlier in the command flow, before any handleComputeOrder invocation
for algorithm or dataset orders. Ensure policy resolution completes successfully
before paid orders are submitted, while preserving the existing order-submission
behavior after validation.

---

Nitpick comments:
In `@src/commands.ts`:
- Line 35: Format the touched imports and the string literal in src/commands.ts
with Prettier: use single quotes, include semicolons, and preserve the project’s
2-space indentation. Update the import declaration containing Asset, DDOManager,
and validateDDO, plus the double-quoted expression at line 40.
- Around line 82-125: Replace the any types in fillNodeManagedAddresses and
validateBeforePublish with a minimal DDO validation interface and unknown-based
types. Define interfaces for the accessed DDO, subject, service, file,
indexedMetadata, and stats fields, and type the validation result without any.
Change the caught error to unknown and narrow it before logging or extracting
details, while preserving the existing validation behavior and untouched
original asset.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 326bf9f9-7da2-4d62-8cc0-64600900009c

📥 Commits

Reviewing files that changed from the base of the PR and between a22adda and 701374b.

📒 Files selected for processing (7)
  • README.md
  • metadata/jsAlgoV5.json
  • metadata/simpleDownloadDatasetV5.json
  • src/cli.ts
  • src/commands.ts
  • src/policyServerHelper.ts
  • src/policyServerInterfaces.ts
💤 Files with no reviewable changes (1)
  • src/policyServerInterfaces.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • metadata/simpleDownloadDatasetV5.json
  • README.md
  • metadata/jsAlgoV5.json
  • src/policyServerHelper.ts
  • src/cli.ts

@alexcos20
alexcos20 merged commit ee97bfd into main Jul 22, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doNotMerge not merge yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants