Skip to content

Add custom digest SDK and CLI#158

Merged
khaliqgant merged 4 commits into
spec/workspace-primitivesfrom
codex/custom-digest-functions-ricky
May 14, 2026
Merged

Add custom digest SDK and CLI#158
khaliqgant merged 4 commits into
spec/workspace-primitivesfrom
codex/custom-digest-functions-ricky

Conversation

@khaliqgant
Copy link
Copy Markdown
Member

Summary

  • add SDK digest function deployment/list/detail/disable/log APIs on WorkspaceHandle
  • add relayfile digest function CLI commands backed by Cloud digest-functions endpoints
  • add local digest test rendering/runtime support with deterministic wasm runner tests

Verification

  • go test ./internal/... ./cmd/relayfile-cli
  • npm --prefix packages/sdk/typescript test
  • npm --prefix packages/sdk/typescript run typecheck
  • git diff --check

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 14, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2da0f62d-2e76-4590-9f75-a4e08a3f8132

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/custom-digest-functions-ricky

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

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 3 potential issues.

View 6 additional findings in Devin Review.

Open in Devin Review

Comment thread cmd/relayfile-cli/digest_functions.go Outdated
} else if (ch === "?") {
out += "[^/]";
} else if ("\\.+^$|()[]{}".includes(ch)) {
out += "\\\\" + ch;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔴 Double-escaped regex in JS globToRegExp breaks path matching for patterns with dots

The globToRegExp function in the digest function test runner script (digestFunctionRunnerScript) double-escapes regex special characters. Since the script is embedded in a Go raw string (backtick-delimited), the text "\\\\" on line 657 is delivered literally to JavaScript as "\\\\". JavaScript interprets "\\\\" as the 2-character string \\, so "\\\\" + ch produces \\<ch>. In a regex, \\. means "match literal backslash, then any character" — not "match literal dot".

This causes globToRegExp to produce incorrect regexes for any glob pattern containing ., +, ^, $, |, (, ), [, ], {, or }. For example, the glob *.md generates regex ^[^/]*\\.md$ which requires a literal backslash before d, so it never matches readme.md. The existing test passes only because the pattern /notion/databases/eng-roadmap/* is matched by the endsWith("/*") shortcut in matchesPath, never hitting globToRegExp.

Suggested change
out += "\\\\" + ch;
out += "\\" + ch;
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in fbb71fe by changing the embedded JS escape to a single regex escape and adding TestDigestFunctionTestMatchesDotGlobPatterns for *.md fixtures.

Comment on lines +325 to +328
func isOOM(err error) bool {
msg := strings.ToLower(err.Error())
return strings.Contains(msg, "out of memory") || strings.Contains(msg, "oom") || strings.Contains(msg, "memory")
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 isOOM heuristic matches any error mentioning "memory", misclassifying non-OOM errors

The isOOM function at internal/wasmrun/wasmrun.go:327 uses strings.Contains(msg, "memory") as a catch-all, which matches any error whose message contains the substring "memory". This incorrectly classifies non-OOM errors as out-of-memory. For example, engine.go:62 can return "wasmrun: guest module exposes no memory" when a WASM module doesn't export a memory section — this is a module configuration error, not an out-of-memory condition. The isOOM check would classify it as OOM, causing a misleading WarningOOM to appear in digest warnings instead of a generic error warning.

Suggested change
func isOOM(err error) bool {
msg := strings.ToLower(err.Error())
return strings.Contains(msg, "out of memory") || strings.Contains(msg, "oom") || strings.Contains(msg, "memory")
}
func isOOM(err error) bool {
msg := strings.ToLower(err.Error())
return strings.Contains(msg, "out of memory") || strings.Contains(msg, "oom") || strings.Contains(msg, "memory limit")
}
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in fbb71fe by narrowing OOM detection to out-of-memory/oom/memory-limit wording and adding TestEngineInvokeDoesNotClassifyMissingMemoryAsOOM.

Comment thread internal/wasmrun/cache/cache.go Outdated
Comment on lines +90 to +95
verify: true,
now: time.Now,
}
if opts.Verify {
c.verify = true
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Cache Options.Verify field is non-functional — verification cannot be disabled

In cache.go:90, c.verify is unconditionally set to true. The subsequent if opts.Verify { c.verify = true } on lines 93–95 only ever sets it to true again. As a result, the Verify field in the public Options struct is dead — setting Options{Verify: false} has no effect, and verification is always enabled. The intent appears to be that verify defaults to true but could be disabled, or alternatively that the opts.Verify assignment should replace the hardcoded default. Either way, the current code makes the Verify option misleading.

Suggested change
verify: true,
now: time.Now,
}
if opts.Verify {
c.verify = true
}
verify: true,
now: time.Now,
}
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in fbb71fe by removing the misleading Options.Verify field and dead assignment; the cache now always verifies sidecar integrity as the implementation already required.

@khaliqgant khaliqgant merged commit dcf5f1d into spec/workspace-primitives May 14, 2026
7 checks passed
@khaliqgant khaliqgant deleted the codex/custom-digest-functions-ricky branch May 14, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant