Skip to content

refactor(examples): pivot L5 triage to raw Temporal + add activities (#74) - #230

Merged
lex00 merged 1 commit into
mainfrom
feat/74-triage-activities
Jun 7, 2026
Merged

lex00 merged 1 commit into
mainfrom
feat/74-triage-activities

Conversation

@lex00

@lex00 lex00 commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Course-correction for L5. The triage workflow needs custom activities (they run the agent), which chant Ops don't support — Op codegen only re-exports pre-built lexicon activities, so the alert-triage.op.ts skeleton from #229 could never generate a working worker. Pivot to chant's documented "Raw Temporal + chant" model (same split as temporal-crdb-deploy): chant synthesizes the manifests; the triage workflow is hand-written Temporal.

Changes

  • Remove alert-triage.op.ts (wrong abstraction).
  • Add activities/triage.ts — raw Temporal activities (classifyAlert, gatherContext, proposeRemediation, notifyOutcome). Deterministic stubs by default; proposeRemediation calls Claude when ANTHROPIC_API_KEY is set (@anthropic-ai/sdk dynamic-imported, opt-in; model via ANTHROPIC_MODEL, default claude-sonnet-4-6).
  • Add activities/triage.test.ts — unit tests for the stub path (CI-safe, no key).
  • vitest.config.ts — include examples/alert-triage/**/*.test.ts so the app's colocated tests run in CI (still not globbing examples/** — fargate docker e2e).
  • App code lives outside src/ so chant lint src stays clean (src/ is chant resources only).
  • README + getting-started L5 row updated to the raw-Temporal model.

Validation

examples.test.ts                          → 164 passed (alert-triage manifests lint clean)
examples/alert-triage/activities/triage   → 5 passed (stub-path unit tests)

eslint packages/ clean.

Part of #74. Follow-ups: the Temporal workflow + worker, webhook source, WatchOp second source.

🤖 Generated with Claude Code

…74)

The triage workflow needs custom activities (the agent), which chant Ops don't
support — Op codegen only re-exports pre-built lexicon activities, so the
alert-triage.op.ts skeleton from #229 could never generate a working worker.
Pivot to chant's documented "Raw Temporal + chant" model (as temporal-crdb-deploy
uses): chant synthesizes the manifests, the triage workflow is hand-written
Temporal.

- Remove alert-triage.op.ts (wrong abstraction).
- Add activities/triage.ts — raw Temporal activities (classifyAlert,
  gatherContext, proposeRemediation, notifyOutcome). Deterministic stubs by
  default; proposeRemediation calls Claude when ANTHROPIC_API_KEY is set
  (@anthropic-ai/sdk dynamic-imported, opt-in; model via ANTHROPIC_MODEL).
- activities/triage.test.ts — unit tests for the stub path (CI-safe, no key).
- vitest.config.ts — include examples/alert-triage/**/*.test.ts so the app's
  colocated tests run in CI (still not globbing examples/** — fargate docker).
- App code lives outside src/ so `chant lint src` stays clean (src/ is chant
  resources only).
- README + getting-started L5 row updated to the raw-Temporal model.

examples.test.ts: 164 passed; activity unit tests: 5 passed; lint clean.

Part of #74. Follow-ups: the Temporal workflow + worker, webhook source, WatchOp.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@lex00
lex00 merged commit 7e83c7f into main Jun 7, 2026
5 checks passed
@lex00
lex00 deleted the feat/74-triage-activities branch June 7, 2026 16:17
lex00 added a commit that referenced this pull request Jun 7, 2026
…233)

Wire the triage activities (#230) into a runnable raw Temporal workflow + worker,
with a time-skipping test — the last L5 piece that carries a real CI check.

- activities/workflow.ts — triage workflow: classify → gather context → propose
  → approval gate → notify. Safe remediations apply directly; risky ones wait on
  the `approve-remediation` signal (condition, 12h) then are held. `import type`
  keeps the activity module out of the deterministic workflow bundle.
- activities/worker.ts — registers activities + workflow; connects via the
  `local` profile in chant.config.ts. `npm run worker`.
- activities/workflow.test.ts — TestWorkflowEnvironment (time-skipping), modeled
  on the temporal lexicon's #161 harness: asserts phase order, gate-clears-on-
  signal, safe-path-skips-gate, and unapproved-risky-waits-out-the-12h-gate.
- package.json — @temporalio/{workflow,worker,testing} + a `worker` script.
- README — workflow/worker section and how to run it locally.

Workflow test runs in CI (under the examples/alert-triage/**/*.test.ts include):
3 passed. Full examples suite 200 passed; lint + eslint clean.

Closes #231. Part of #74 / #216.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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