Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz Source: /opt/alga-psa on psa.joliet.tech
8.7 KiB
8.7 KiB
Scratchpad — Workflow JSON Transform + AI-Assisted Authoring
- Plan slug:
2026-05-09-workflow-json-transform-ai-authoring - Created:
2026-05-09
What This Is
Working notes for adding deterministic JSON Transform actions and AI-assisted authoring through existing Quick Ask.
Decisions
- (2026-05-09) Start with JSON from workflow values or static literals only. No URL/file/blob loading in Transform actions.
- (2026-05-09) Do not build a visual mapper for this phase. Use deterministic JSONata-based actions and teach existing Alga AI/Quick Ask how to help users write expressions.
- (2026-05-09) JSON Transform runtime must be independent of AI. AI only helps author expressions/configuration.
- (2026-05-09) Keep JSON transforms in the existing
action.call+ Transform action model rather than adding a new node type. - (2026-05-09) Use existing AI entitlement and feature gating for Quick Ask / optional Ask AI trigger. Do not gate the JSON Transform actions themselves behind AI.
Discoveries / Constraints
- (2026-05-09) Transform actions live in
shared/workflow/runtime/actions/registerTransformActions.tsand are pure, non-side-effectful actions registered in the ActionRegistry. - (2026-05-09)
action.callresolves input mappings, calls the action registry, and saves outputs throughsaveAsusingapplyAssignmentsinshared/workflow/runtime/nodes/registerDefaultNodes.ts. - (2026-05-09) Existing expression engine uses JSONata in
shared/workflow/runtime/expressionEngine.ts, with allow-listed functions, timeout checks, JSON-serializable result checks, and max output size checks. - (2026-05-09) Dynamic action output schemas already have precedents in
ai.inferandtransform.compose_textviashared/workflow/runtime/actions/actionOutputSchemaResolver.ts, but JSON mapper MVP can use static wrapper outputs. - (2026-05-09) Quick Ask is already gated by
aiAssistantfeature andADD_ONS.AI_ASSISTANTin layout/chat routes. Optional Ask AI trigger should reuse this instead of introducing a new AI surface. - (2026-05-09) Potential gotcha: input mapping can resolve
$secretinto action args, andsaveAscould store parsed secret content into workflow state. Need to document or guard this before encouraging secret-backed JSON parsing. - (2026-05-09) Git metadata for this worktree appears unhealthy:
git status --shortfailed withfatal: not a git repository: /Users/roberisaacs/alga-psa/.git/worktrees/support-regex-workflows.
Commands / Runbooks
- (2026-05-09) Relevant files inspected:
shared/workflow/runtime/actions/registerTransformActions.tsshared/workflow/runtime/expressionEngine.tsshared/workflow/runtime/utils/mappingResolver.tsshared/workflow/runtime/actions/actionOutputSchemaResolver.tsshared/workflow/runtime/designer/actionCatalog.tsshared/workflow/runtime/nodes/registerDefaultNodes.tsee/server/src/services/chatCompletionsService.tsee/server/src/components/chat/QuickAskOverlay.tsxserver/src/components/layout/DefaultLayout.tsxpackages/types/src/constants/addOns.ts
Links / References
- Plan PRD:
ee/docs/plans/2026-05-09-workflow-json-transform-ai-authoring/PRD.md - Feature checklist:
ee/docs/plans/2026-05-09-workflow-json-transform-ai-authoring/features.json - Test checklist:
ee/docs/plans/2026-05-09-workflow-json-transform-ai-authoring/tests.json
Open Questions
- Include
transform.stringify_jsonin the first implementation or defer? - Add optional defaults to
transform.query_json, or rely on JSONata/coalesce patterns? - Include optional Ask AI trigger in first implementation, or ship runtime actions + prompt update first?
- What existing UI context can Quick Ask see from the workflow designer without new plumbing?
Implementation Updates (2026-05-09)
- Added
transform.parse_json,transform.query_json, andtransform.stringify_jsontoshared/workflow/runtime/actions/registerTransformActions.ts. transform.parse_jsonbehavior:- Parses JSON strings to typed values.
- Passes through plain literal objects/arrays unchanged.
- Returns
{ value, type }wheretypeis one ofobject|array|string|number|boolean|null. - Throws actionable
JSON parse failed: ...errors for invalid JSON and unsupported inputs.
transform.query_jsonbehavior:- Evaluates JSONata expression from
expressionagainstsourceand returns{ value }. - Uses existing safe expression engine path via
compileExpression. - Exposes
sourceand preserves workflow expression context (payload,vars,meta,error) through handler context merge. - Distinguishes error class in messages:
JSON query expression validation failed: ...JSON query expression evaluation failed: ...
- Evaluates JSONata expression from
transform.stringify_jsonbehavior:- Serializes JSON-compatible values to
{ text }. - Supports optional pretty spacing (
0..8). - Throws
JSON stringify failed: ...on non-serializable inputs.
- Serializes JSON-compatible values to
- Added reusable expression helper
evaluateExpressionSource(source, ctx, timeoutMs?)inshared/workflow/runtime/expressionEngine.ts.
AI Guidance Updates (2026-05-09)
- Added
ee/server/src/services/chatWorkflowJsonTransformGuidance.tsand injected guidance into Quick Ask system prompt inee/server/src/services/chatCompletionsService.ts. - Guidance explicitly includes:
- Action names (
transform.parse_json,transform.query_json,transform.stringify_json). - JSONata examples (extract, object construction, coalesce, array filter/map).
- Where to paste expression (
transform.query_json.inputMapping.expression). saveAspatterns forpayload/vars.- Deterministic runtime statement that AI does not execute inside workflow runtime.
- Security warning about persisting secret-derived parsed JSON into workflow state.
- Action names (
Tests Added/Updated (2026-05-09)
- Updated:
shared/workflow/runtime/actions/__tests__/registerTransformActions.test.ts- Added parse/query/stringify happy-path and failure-path coverage.
- Added schema metadata checks for new actions.
- Added:
shared/workflow/runtime/nodes/__tests__/actionCallTransformJsonSaveAsRuntime.test.ts- Validates
action.call+saveAs+ downstream expression mapping integration.
- Validates
- Updated:
shared/workflow/runtime/__tests__/expressionEngine.test.ts- Added custom-context helper test for
evaluateExpressionSource.
- Added custom-context helper test for
- Added:
ee/server/src/services/__tests__/chatWorkflowJsonTransformGuidance.test.ts- Validates guidance content coverage and deterministic-runtime messaging.
Runbook / Commands (2026-05-09)
- Test command used:
npx vitest run --config vitest.json-transform.config.mts
- Note: root/server Vitest config include globs do not include
shared/workflow/runtime/**by default, so a local targeted config was used to execute these tests in one run.
Optional Ask AI Trigger Decision (2026-05-09)
- Deferred for this PRD slice; no new trigger UI introduced.
- Existing Quick Ask entitlement gating remains unchanged (AI add-on + feature access checks remain existing behavior).
Review Fixes (2026-05-09)
- Replaced bare
z.unknown()JSON action source/value schemas with a recursive JSON value schema so required fields are enforced by Zod and emitted in JSON Schema. - Added JSON transform schema regression assertions for missing
source/valuefields. - Moved the Quick Ask JSON guidance unit test from
ee/server/src/services/__tests__toee/server/src/__tests__/servicesso it is included byee/server/vitest.config.ts. - Corrected plan checklist state: optional Ask AI trigger features/tests are deferred, not implemented.
- Reverted unrelated
package-lock.jsonchanges.
Validation (2026-05-09 Review Fixes)
npx vitest run --config shared/vitest.config.ts workflow/runtime/actions/__tests__/registerTransformActions.test.ts workflow/runtime/__tests__/expressionEngine.test.ts workflow/runtime/nodes/__tests__/actionCallTransformJsonSaveAsRuntime.test.ts- Passed: 3 files, 15 tests.
cd ee/server && npx vitest run --config vitest.config.ts src/__tests__/services/chatWorkflowJsonTransformGuidance.test.ts- Passed: 1 file, 2 tests.
Review Fix Follow-up (2026-05-09)
- Fixed
transform.parse_jsonnumeric overflow handling: JSON strings such as1e999now fail withJSON parse failed: parsed value is not a finite JSON valueinstead of returningInfinityand failing later during output validation. - Added regression coverage for JSON numeric overflow.
Validation (2026-05-09 Numeric Overflow Fix)
npx vitest run --config shared/vitest.config.ts workflow/runtime/actions/__tests__/registerTransformActions.test.ts workflow/runtime/__tests__/expressionEngine.test.ts workflow/runtime/nodes/__tests__/actionCallTransformJsonSaveAsRuntime.test.ts- Passed: 3 files, 15 tests.