Skip to content

feat(persona-kit): typed ProactiveCapabilities on PersonaSpec (#1555 PR-B)#169

Merged
khaliqgant merged 1 commit into
mainfrom
codex/persona-kit-capabilities
May 31, 2026
Merged

feat(persona-kit): typed ProactiveCapabilities on PersonaSpec (#1555 PR-B)#169
khaliqgant merged 1 commit into
mainfrom
codex/persona-kit-capabilities

Conversation

@khaliqgant
Copy link
Copy Markdown
Member

Adds the canonical typed capabilities schema (review/issueClaim/conflictAutofix + legacy pullRequest alias; CapabilityValue = boolean | {enabled?}) to PersonaSpec. Source-of-truth home for cloud PR-A's locally-typed registry. Additive + optional, zero behavior change. Cloud will re-import these types after this publishes.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 31, 2026

Warning

Review limit reached

@khaliqgant, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 14 minutes and 59 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

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.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b5ffc212-dd2d-4c66-a233-4b79b736c472

📥 Commits

Reviewing files that changed from the base of the PR and between a380c74 and 6bdf8e5.

📒 Files selected for processing (12)
  • .trajectories/completed/2026-05/traj_rdhqus1o0ci8.json
  • .trajectories/completed/2026-05/traj_rdhqus1o0ci8.md
  • .trajectories/index.json
  • packages/persona-kit/CHANGELOG.md
  • packages/persona-kit/package.json
  • packages/persona-kit/schemas/persona.schema.json
  • packages/persona-kit/src/__fixtures__/personas/full.json
  • packages/persona-kit/src/define.test.ts
  • packages/persona-kit/src/define.ts
  • packages/persona-kit/src/index.ts
  • packages/persona-kit/src/parse.ts
  • packages/persona-kit/src/types.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/persona-kit-capabilities

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 and usage tips.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces typed proactive capabilities (ProactiveCapabilities) to the persona-kit PersonaSpec, updating the JSON schema, types, parser, tests, and fixtures. The review feedback correctly identifies a potential validation gap where arrays could bypass the isObject check and be treated as objects, and provides a code suggestion to explicitly reject arrays using Array.isArray.

Comment on lines +856 to +874
function parseCapabilityValue(value: unknown, context: string): CapabilityValue {
if (typeof value === 'boolean') return value;
if (!isObject(value)) {
throw new Error(`${context} must be a boolean or object if provided`);
}
if (value.enabled !== undefined && typeof value.enabled !== 'boolean') {
throw new Error(`${context}.enabled must be a boolean if provided`);
}
return { ...value } as CapabilityValue;
}

export function parseCapabilities(
value: unknown,
context: string
): ProactiveCapabilities | undefined {
if (value === undefined) return undefined;
if (!isObject(value)) {
throw new Error(`${context} must be an object if provided`);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

In JavaScript/TypeScript, typeof [] is 'object' and null is already checked by isObject, but arrays will still pass the isObject check. This means that if an array is passed as a capability value (e.g., review: [true]) or for the capabilities field itself (e.g., capabilities: []), it will not throw a validation error. Instead, parseCapabilityValue will return an object representation of the array (e.g., { '0': true }), and parseCapabilities will silently ignore the array and return undefined.

To prevent this, we should explicitly check and reject arrays using Array.isArray(value).

Suggested change
function parseCapabilityValue(value: unknown, context: string): CapabilityValue {
if (typeof value === 'boolean') return value;
if (!isObject(value)) {
throw new Error(`${context} must be a boolean or object if provided`);
}
if (value.enabled !== undefined && typeof value.enabled !== 'boolean') {
throw new Error(`${context}.enabled must be a boolean if provided`);
}
return { ...value } as CapabilityValue;
}
export function parseCapabilities(
value: unknown,
context: string
): ProactiveCapabilities | undefined {
if (value === undefined) return undefined;
if (!isObject(value)) {
throw new Error(`${context} must be an object if provided`);
}
function parseCapabilityValue(value: unknown, context: string): CapabilityValue {
if (typeof value === 'boolean') return value;
if (!isObject(value) || Array.isArray(value)) {
throw new Error(`${context} must be a boolean or object if provided`);
}
if (value.enabled !== undefined && typeof value.enabled !== 'boolean') {
throw new Error(`${context}.enabled must be a boolean if provided`);
}
return { ...value } as CapabilityValue;
}
export function parseCapabilities(
value: unknown,
context: string
): ProactiveCapabilities | undefined {
if (value === undefined) return undefined;
if (!isObject(value) || Array.isArray(value)) {
throw new Error(`${context} must be an object if provided`);
}

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: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 12 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/persona-kit/src/parse.ts">

<violation number="1" location="packages/persona-kit/src/parse.ts:858">
P2: Top-level capabilities accepts array. Invalid config gets silently ignored. Reject array input.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic


function parseCapabilityValue(value: unknown, context: string): CapabilityValue {
if (typeof value === 'boolean') return value;
if (!isObject(value)) {
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.

P2: Top-level capabilities accepts array. Invalid config gets silently ignored. Reject array input.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/persona-kit/src/parse.ts, line 858:

<comment>Top-level capabilities accepts array. Invalid config gets silently ignored. Reject array input.</comment>

<file context>
@@ -851,6 +853,44 @@ export function parseMemory(value: unknown, context: string): PersonaMemory | un
 
+function parseCapabilityValue(value: unknown, context: string): CapabilityValue {
+  if (typeof value === 'boolean') return value;
+  if (!isObject(value)) {
+    throw new Error(`${context} must be a boolean or object if provided`);
+  }
</file context>
Suggested change
if (!isObject(value)) {
if (!isObject(value) || Array.isArray(value)) {

@khaliqgant khaliqgant merged commit 4846b63 into main May 31, 2026
4 checks passed
@khaliqgant khaliqgant deleted the codex/persona-kit-capabilities branch May 31, 2026 10:42
@agent-relay-bot
Copy link
Copy Markdown

Reviewed PR #169 locally and made two fixes:

  • Tightened parseCapabilities so arrays are rejected for both the top-level capabilities object and individual capability values, matching the generated schema and TypeScript shape.
  • Added focused parser tests for valid capability declarations and malformed capability inputs.
  • Fixed an unrelated runtime test isolation failure exposed by the full check by clearing all ambient relay/workforce token env vars in the no-auth memory test.

Local verification completed:

  • corepack pnpm --filter @agentworkforce/persona-kit test
  • corepack pnpm --filter @agentworkforce/runtime test
  • corepack pnpm run check

@agent-relay-bot
Copy link
Copy Markdown

pr-reviewer applied fixes — committed and pushed b209965 to this PR. The notes below describe what changed.

Reviewed PR #169 locally and made two fixes:

  • Tightened parseCapabilities so arrays are rejected for both the top-level capabilities object and individual capability values, matching the generated schema and TypeScript shape.
  • Added focused parser tests for valid capability declarations and malformed capability inputs.
  • Fixed an unrelated runtime test isolation failure exposed by the full check by clearing all ambient relay/workforce token env vars in the no-auth memory test.

Local verification completed:

  • corepack pnpm --filter @agentworkforce/persona-kit test
  • corepack pnpm --filter @agentworkforce/runtime test
  • corepack pnpm run check

Copy link
Copy Markdown

@agent-relay-bot agent-relay-bot Bot left a comment

Choose a reason for hiding this comment

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

pr-reviewer applied fixes — committed and pushed b209965 to this PR. The notes below describe what changed.

Reviewed PR #169 locally and made two fixes:

  • Tightened parseCapabilities so arrays are rejected for both the top-level capabilities object and individual capability values, matching the generated schema and TypeScript shape.
  • Added focused parser tests for valid capability declarations and malformed capability inputs.
  • Fixed an unrelated runtime test isolation failure exposed by the full check by clearing all ambient relay/workforce token env vars in the no-auth memory test.

Local verification completed:

  • corepack pnpm --filter @agentworkforce/persona-kit test
  • corepack pnpm --filter @agentworkforce/runtime test
  • corepack pnpm run check

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