14 Commits
Author SHA1 Message Date
sam e78cb1e63e fix(webhookguard): token counts in task logs keep their value; secrets under token keys stay redacted (#1720) 2026-11-14 23:42:46 +11:00
sam 6f10ecc04f feat(agentexec): record each agent run's transcript and show it per step (#1718)
The loop runner hooks every model call and tool call and reports ordered,
redacted, clipped entries. Each is persisted as an agent_transcript task
event through InsertEvent, left out of the timeline read, and served per
attempt at /api/tasks/{id}/transcript. The step run view shows it with Trace.
2026-11-01 22:09:53 +11:00
sam 02a4ac0629 fix(state): harden the audit feed against audit findings 2026-10-25 21:23:52 +11:00
sam ab78f5c909 feat(state): org-scoped audit feed contract and read model 2026-10-25 21:23:52 +11:00
sam 39430d78ae Revert "fix(messaging): mask secrets embedded in chat tool arguments"
This reverts commit 9c9aefd296.
2026-10-24 20:56:31 +11:00
sam 9c9aefd296 fix(messaging): mask secrets embedded in chat tool arguments 2026-10-24 20:53:27 +11:00
sam 8a3ba32c5a Feat/operator alerts (#1635)
* feat(state): durable operator alerts owned by the State Store

Alerts dedup on org+kind+subject, resolve themselves when a condition
clears, and are raised, resolved, dismissed and listed through the state
contract. Task transitions raise needs-human and failed alerts in the same
transaction; the store checks service health and prunes closed alerts.
Each raise and resolve queues a webhook delivery whose attempts are kept.

* feat(notify): deliver operator alerts to the webhook; raise config and release alerts

notify.webhook now receives raised and resolved alerts above a severity
threshold with HMAC-signed payloads, bounded retry and every attempt recorded
on the alert. archied raises model alias, provider and credential-binding
alerts from the effective configuration, an update alert from the release
channel, and a credential-rejected alert from the egress resolver. The
dashboard API lists and dismisses the caller's org's alerts.

* feat(ui): alert bell in the top bar and webhook alert settings

The bell lists the org's open alerts by severity with dismiss and a link per
alert, and refreshes from the event stream. The task settings page gains the
webhook severity threshold and signing secret. ui/dist rebuilt.
2026-10-12 03:30:46 +11:00
sam cb6b8618c2 refactor: cut remaining long comments down to what the code does 2026-10-03 22:06:57 +10:00
sam 030b4ed176 refactor: strip doc and issue narration from code comments
Remove PRD/doc paths, bead IDs, phase notes and deleted-test references
from comments; drop test-only hooks left by the test deletion. Includes
in-progress archied bootstrap, gateway and query changes.
2026-10-03 21:47:46 +10:00
sam 780bc44d82 refactor: testing from the beginning. a journey in 150k lines of tests to none 2026-10-03 21:16:25 +10:00
sam 61ecc14327 fix(webhookguard): verify uppercase-hex HMAC signatures
VerifyHMAC compared the supplied signature against the computed digest as
case-sensitive hex text, so a sender that emits an uppercase digest failed
verification -- and the failure is indistinguishable from a wrong secret. The
helper is shared by all three inbound surfaces (forge intake, the chat webhook
gateway, capture intake), so one such sender breaks whichever surface it
targets.

Decode both sides to raw bytes and compare those. hex.DecodeString accepts
either case, and comparing digests rather than their text keeps the comparison
constant-time -- strings.EqualFold over the encoded text would not be. A
signature that is not valid hex is rejected outright, and a digest of the
wrong length simply does not match.

archie-core-rl04
2026-10-03 01:44:17 +10:00
sam 0e0611a6b3 refactor(gateway): share sensitive-key markers with webhookguard
Resolves infra-misc-3.

WIRE: webhookguard.SensitiveKeyMarkers is now the single exported marker
list, and gateway.sensitiveParameterKey consumes it instead of inlining an
identical copy. webhookguard/redact.go documented that the two lists must
match "exactly so the two redaction paths agree"; that agreement is now
structural (one slice, two consumers) rather than a comment nothing
enforces. A new test asserts both consumers observe the same set, so a
future edit cannot silently desynchronise chat-transcript redaction from
webhook-capture redaction.
2026-09-15 12:55:52 +10:00
sam f9f9888702 feat(webhook): harden captured payload redaction
RedactPayload only redacted values under a fixed set of sensitive key
names, so a sender that names a secret field something else leaked it into
captured_events.body. Harden the heuristic:

- broaden the key-name markers (compound names like access_token,
  client_secret, signing_key, x_api_key, webhook_secret, refresh_token)
  and keep gateway.sensitiveParameterKey identical to preserve the
  documented agreement between the two redaction paths.
- add value-shape detection: a compact JWT or a PEM private-key block is
  redacted under any key, catching the 'sender named the field something
  the heuristic misses' gap.
- keep it conservative so schema-by-example field mapping still works:
  only unambiguous shapes (eyJ-prefixed JWTs, PEM key blocks) are
  redacted by value, never ordinary content.

Best-effort per docs/prds/webhook-intake-security.md point 5.

Refs archie-core-t2db (captured_events.body redaction)
2026-09-02 23:59:43 +10:00
sam 543b657472 feat(webhookguard): shared HMAC, rate-limit, and redaction mechanics
archie-core-7d5u.3 -- storage-agnostic building blocks for vetting inbound
webhook-shaped requests, extracted rather than duplicated:

- VerifyHMAC: behavior-preserving extraction of internal/channels/webhook's
  private validateHMAC. internal/channels/webhook now calls it instead of
  keeping its own copy; all 10 of that package's existing tests still pass
  unmodified, and the one now-redundant unit test was removed with a
  comment pointing to where its coverage relocated.
- RateLimiter: per-source token bucket. Source IDs come from a registered,
  operator-controlled set, not unbounded attacker input, so the bucket map
  is not itself bounded -- documented explicitly rather than left implicit.
- RedactPayload: key-name-based redaction, matching gateway/stream.go's
  sensitiveParameterKey marker list. Deliberately does NOT reuse that
  function's actual behavior: it replaces every string value regardless of
  key, correct for a bounded chat summary and wrong here -- a captured
  payload exists to be inspected for field mapping (t2db.3), so only values
  under a sensitive-looking key are touched.

Narrowed from 7d5u.3's original scope, which bundled capture storage and an
approval state machine into this package. Both moved to the beads that own
that state (t2db.1's capture store depends on 7d5u.2's still-open NATS
storage decision; t2db.4's binding is the only consumer of approval state
today) rather than building shared abstractions ahead of a second real
consumer.

Adversarially reviewed by a fresh subagent with zero surviving findings:
token-bucket math hand-traced on two scenarios and race-clean under -race,
the redaction/gateway-stream.go behavioral divergence verified by reading
both functions side by side, both the redaction and rate-limit guards
mutation-tested by disabling each and confirming the suite catches it.

task check exit 0, golangci-lint 0 issues, gofumpt clean.
2026-08-22 01:28:58 +10:00