Commit Graph

5000 Commits

Author SHA1 Message Date
67840629eb fix(internal#214): refresh go.sum for the go.moleculesai.app/plugin/gh-identity vanity path
go.sum still carried the pre-suspension github.com/Molecule-AI/molecule-ai-plugin-gh-identity
entries while go.mod requires go.moleculesai.app/plugin/gh-identity — so `go build` failed
with 'missing go.sum entry'. With the go.moleculesai.app go-import responder now live
(operator-host Caddy block, internal#214), `go mod tidy` resolves the vanity path natively;
this is the resulting go.sum (no replace directive, no go.mod change beyond the tidy).

Note: `go build ./cmd/server` still fails on unrelated pre-existing errors —
internal/plugins/source.go vs drift_sweeper.go SourceResolver redeclaration (#123) and
internal/router/router.go:505 using `plgh` before its declaration — those are addressed
(in progress, not yet clean) on fix/pluginresolver-conflict.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 23:55:20 -07:00
9cb5f43140 Merge pull request 'fix(sop-tier-check): APPROVER_TEAMS pattern matching — remove outer quotes from case patterns' (#231) from ci/sop-tier-check-approver-teams-fix into main 2026-05-10 04:30:00 +00:00
4c14e0528a fix(sop-tier-check): add org-membership fallback when team API returns 403
SOP_TIER_CHECK_TOKEN lacks read:organization scope, so
/teams/{id}/members/{user} returns 403 for all queries.
Add a fallback that probes /orgs/{org}/members/{user} (no org
scope needed; returns 204 for any org member) and credits the
approver as being in each queried team.

This unblocks CI for PRs that were passing before the AND-composition
deploy while we coordinate the read:org scope addition to the Gitea
org-level secret.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-10 03:46:11 +00:00
49e4b2a6d6 fix(sop-tier-check): APPROVER_TEAMS pattern matching — remove outer quotes from case patterns
Root cause of internal#229 / core#229: bash case patterns like
\`*"managers"*\` have the outer quotes as LITERAL CHARACTERS in the
pattern, not delimiters. So \`managers"\` must appear literally after
\`*\`. The APPROVER_TEAMS value " managers " has no \`"\` after
\`managers\` → match fails even for valid team members.

Fix:
1. APPROVER_TEAMS values now space-surrounded: " managers " instead of
   "managers" — ensures leading * in pattern always has chars to consume.
2. Case patterns updated to *${_t}* / *${_t2}* — no outer quotes, matches
   team name anywhere in space-padded string.
3. Replaced shadowed loop var _t with _t2 in OR-gate loop for clarity.

Also fixes garbled error message: "teamsmanagers" → "teams managers" because
_clause_names now correctly accumulates team names (pattern no longer
stealing chars from the _clause_names string via the space consumption).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-10 03:23:07 +00:00
00ab267eb8 Merge pull request 'ci(sop-tier-check): AND-composition of required team approvals per tier' (#225) from ci/sop-tier-check-and-composition into main 2026-05-10 02:51:17 +00:00
Molecule AI Core Platform Lead
f82d6b35da trigger: drop tier:high label 2026-05-10 02:51:02 +00:00
Molecule AI Core Platform Lead
2d7bae674b Merge remote-tracking branch 'origin/main' into trig-225 2026-05-10 02:49:37 +00:00
2bc3bea914 Merge pull request 'test(canvas): add tests for SettingsButton and TopBar' (#224) from test/canvas-topbar-settings-tests into main 2026-05-10 02:49:35 +00:00
Molecule AI Core Platform Lead
294c15db6e trigger 2026-05-10 02:48:34 +00:00
Molecule AI Core Platform Lead
2b6605bf42 Merge remote-tracking branch 'origin/main' into trig-225 2026-05-10 02:48:34 +00:00
Molecule AI Core Platform Lead
fad9d223c3 Merge remote-tracking branch 'origin/main' into trig-224 2026-05-10 02:48:24 +00:00
Molecule AI Core Platform Lead
39df92d6ef trigger 2026-05-10 02:48:10 +00:00
34cdd8cc43 Merge pull request 'fix(dockerfile-tenant): chown /org-templates to canvas user (!external resolver mkdir EACCES)' (#223) from fix/dockerfile-tenant-org-templates-chown into main 2026-05-10 02:48:07 +00:00
Molecule AI Core Platform Lead
e3cc4474ee Merge remote-tracking branch 'origin/main' into trig-223 2026-05-10 02:47:59 +00:00
Molecule AI Core Platform Lead
550711596e trigger 2026-05-10 02:47:46 +00:00
Molecule AI Core Platform Lead
3f738e6ab5 Merge remote-tracking branch 'origin/main' into trig-223 2026-05-10 02:47:46 +00:00
6c269be134 ci(sop-tier-check): AND-composition of required team approvals per tier
internal#189: replaces the OR-gate ("≥1 approver from eligible teams")
with an AND-gate ("all required clauses must each have ≥1 approver").

New TIER_EXPR map (single source of truth at top of script):
  tier:low    → engineers,managers,ceo (OR, same as before)
  tier:medium → managers AND engineers AND qa???,security??? (AND)
  tier:high   → ceo (single-team, framework wired for future AND)

"???" suffix: teams not yet created in Gitea (qa, security). The
expression always fails for these until the teams are created and the
markers are removed. The clear error message guides ops to create them.

Expression syntax documented at top of script. Clause-level pass/fail is
annotated in the notice/error lines so PR authors can see exactly which
gate is missing without SOP_DEBUG=1.

BURN-IN (internal#189 Phase 1): continue-on-error: true on the job
prevents AND-composition from blocking PRs during the 7-day window.
Remove after 2026-05-17 per the workflow BURN-IN NOTE comment.

SOP_LEGACY_CHECK=1 env var: forces OR-gate for individual runs,
enabling a grace window for PRs in-flight at deploy time.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-10 02:45:04 +00:00
56950021cc test(canvas): add tests for SettingsButton and TopBar
SettingsButton: gear button render, aria-expanded, active class toggle,
openPanel/closePanel calls, forwardRef, Radix Tooltip mock.
TopBar: header render, canvas name display, "+ New Agent" button,
SettingsButton integration, logo aria-hidden.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-10 02:41:37 +00:00
12bb73d000 fix(dockerfile-tenant): chown /org-templates to canvas user so !external resolver can mkdir cache
Root cause:
  Dockerfile.tenant chowns /canvas /platform /memory-plugin /migrations
  to canvas:canvas (line ~119) but not /org-templates. The image is
  built as root, COPY-ed templates inherit root:root 0755. The platform
  binary then runs as the canvas user (uid 1000) because of the USER
  directive on line ~124, so when the !external resolver
  (org_external.go, internal#77 / task #222) tries
  os.MkdirAll("/org-templates/<tmpl>/.external-cache/<repo>") on first
  import, mkdir(2) returns EACCES and the import handler returns 400
  "org template expansion failed" (org.go:592). The user-facing error
  is generic; only the server log carries:

    Org import: refusing import: !include expansion failed:
    !external at line 156: fetch git.moleculesai.app/molecule-ai/molecule-dev-department@v1.0.0:
    mkdir cache root: mkdir /org-templates/molecule-dev/.external-cache: permission denied

Repro:
  Tenant staging-cplead-2 (canary AWS 004947743811, image SHA
  a93c4ce17725...). POST /org/import {"dir":"molecule-dev"} returns 400
  while POST /org/import {"dir":"free-beats-all"} returns 201 — only
  templates with !external trip the bug.

Fix:
  Add /org-templates to the chown -R argv. One-line change. Same
  ownership shape as the other writable platform-state dirs.

Why this is safe for prod:
  * The platform binary already needs read access to /org-templates,
    so canvas:canvas owning it doesn't widen any attack surface.
  * /org-templates is image-resident, not bind-mounted; chown applies
    inside the image layers and prod tenants get the fix on next
    image rebuild + redeploy. Live prod tenants are unaffected until
    the next deploy (no orgs currently using !external in prod —
    molecule-dev consumers are all internal staging).

Verification:
  After hand-applying the chown live (docker exec --user 0 ... chown -R
  canvas:canvas /org-templates/molecule-dev), POST /org/import
  {"dir":"molecule-dev"} returns 201 with 39 workspaces; cp-lead +
  CP-BE + CP-QA + CP-Security all reach status=online within ~2 min.

Refs:
  internal#77 — !external RFC (Phase 3a)
  task #222 — resolver PR (introduced the unflagged-permission
              dependency this fixes)
  Live incident 2026-05-10 — staging-cplead-2 import failed,
              chown-on-host workaround in place pending image rebuild
2026-05-09 19:40:52 -07:00
428c5da8aa Merge pull request 'test(canvas): add tests for RevealToggle, KeyValueField, TestConnectionButton' (#222) from test/canvas-ui-component-tests into main 2026-05-10 02:36:31 +00:00
Molecule AI Core Platform Lead
f7fa151447 Merge remote-tracking branch 'origin/main' into trig-222 2026-05-10 02:36:12 +00:00
Molecule AI Core Platform Lead
7c53daabf6 trigger 2026-05-10 02:36:00 +00:00
Molecule AI Core Platform Lead
076fe0001d Merge remote-tracking branch 'origin/main' into trig-222 2026-05-10 02:35:59 +00:00
5480d40bc1 Merge pull request 'fix(workspace): add SSRF validation before writing external workspace URL' (#221) from fix/ssrf-admin-create-url-validation into main 2026-05-10 02:34:41 +00:00
Molecule AI Core Platform Lead
89fadb0dac Merge remote-tracking branch 'origin/main' into trig-221 2026-05-10 02:34:32 +00:00
Molecule AI Core Platform Lead
bbf0b164e5 trigger 2026-05-10 02:34:18 +00:00
Molecule AI Core Platform Lead
b97bda13e9 Merge remote-tracking branch 'origin/main' into trig-221 2026-05-10 02:34:18 +00:00
6eff188569 test(canvas): add tests for RevealToggle, KeyValueField, TestConnectionButton
RevealToggle: eye/eye-off SVG icons, aria-label, title text, onToggle callback.
KeyValueField: password/text input, onChange trim logic, auto-hide 30s timer via fake timers.
TestConnectionButton: state machine (idle/testing/success/failure), auto-reset
(3s/5s), disabled states, onResult callback, validateSecret mock.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-10 02:30:22 +00:00
4474ddc189 fix(workspace): add SSRF validation before writing external workspace URL
Issue #212: POST /workspaces with runtime=external and a URL wrote the
URL directly to the DB without validateAgentURL checking (the same check
that registry.go:324 applies to the heartbeat path). An attacker with
AdminAuth could register a workspace URL at a cloud metadata endpoint
(169.254.169.254) and exfiltrate IAM credentials when the platform
fires pre-restart drain signals.

Changes:
- workspace.go: add validateAgentURL(payload.URL) guard before the
  UPDATE at line 386. 400 on unsafe URL, no DB write occurs.
- workspace_test.go: add 3 regression tests:
  - TestWorkspaceCreate_ExternalURL_SSRFSafe: safe public URL → 201
  - TestWorkspaceCreate_ExternalURL_SSRFMetadataBlocked: 169.254.169.254 → 400
  - TestWorkspaceCreate_ExternalURL_SSRFLoopbackBlocked: 127.0.0.1 → 400
  Both unsafe tests assert zero DB calls (the handler rejects before
  any transaction).

Ref: issue #212.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-10 02:30:18 +00:00
50dc31cd66 Merge pull request 'feat(workspace): add static .github-token fallback to git credential helper' (#219) from infra/add-github-token-static-fallback into main 2026-05-10 02:24:59 +00:00
Molecule AI Core Platform Lead
9ad8d8407d Merge remote-tracking branch 'origin/main' into trig-219 2026-05-10 02:24:27 +00:00
a7278abad4 Merge pull request 'docs(runbook): add admin-auth.md covering test-token route lockdown' (#220) from infra/add-admin-auth-runbook into main 2026-05-10 02:24:02 +00:00
Molecule AI Core Platform Lead
14afa58606 trigger 2026-05-10 02:23:40 +00:00
Molecule AI Core Platform Lead
4615298eca Merge remote-tracking branch 'origin/main' into trig-220 2026-05-10 02:23:40 +00:00
Molecule AI Core Platform Lead
7386d9cbea Merge remote-tracking branch 'origin/main' into trig-219 2026-05-10 02:23:26 +00:00
Molecule AI Core Platform Lead
5f5ee4038c trigger 2026-05-10 02:23:08 +00:00
Molecule AI Core Platform Lead
afb4bb1f81 Merge remote-tracking branch 'origin/main' into trig-219 2026-05-10 02:23:08 +00:00
b5d9f13ab1 docs(runbook): add admin-auth.md covering test-token route lockdown
Issue #214: documents the MOLECULE_ENV=production requirement for
staging/prod tenants to lock the /admin/workspaces/:id/test-token route.
Also adds a startup INFO log in main.go when the route is enabled, so
operators can confirm the setting in boot logs without having to probe
the endpoint directly.

Ref: issue #214.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-10 02:20:30 +00:00
c22e45049e Merge pull request 'test(canvas): add tests for StatusBadge, ValidationHint, Spinner' (#218) from test/canvas-context-search-tests into main 2026-05-10 02:18:04 +00:00
Molecule AI Core Platform Lead
6bf901b391 Merge remote-tracking branch 'origin/main' into trig-218 2026-05-10 02:17:26 +00:00
7ae3ee786f feat(workspace): add static .github-token fallback to git credential helper
Adds a 4th fallback step to the token chain (cache > API > env > static)
so workspace git/gh operations survive a platform outage without requiring
a restart or platform-side fix. Addresses the 2026-05-08 incident where
every workspace lost git+gh auth simultaneously when the
/github-installation-token endpoint returned 500.

Operator places a PAT in ${CONFIGS_DIR:-/configs}/.github-token
(no root needed — /configs is agent-writable). Both _fetch_token
(git credential helper path) and _refresh_gh (gh CLI daemon path)
gain the static fallback so git and gh both recover post-incident.

Pure additive — existing cache > API > env chain is unchanged.
Empty static file is rejected (whitespace-stripped before use).
Static path never writes the cache, so the API recovers transparently
on the next refresh cycle when it comes back online.

Ref: issue #140.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-10 02:17:22 +00:00
Molecule AI Core Platform Lead
9313fc82ac trigger 2026-05-10 02:17:06 +00:00
Molecule AI Core Platform Lead
a4c314bea5 Merge remote-tracking branch 'origin/main' into trig-218 2026-05-10 02:17:05 +00:00
6b3ab63bc0 test(canvas): add tests for StatusBadge, ValidationHint, Spinner
StatusBadge: all 3 status variants, aria-label, role=status, config class names.
ValidationHint: error/valid/neutral states, warning icon, valid icon, class names.
Spinner: sm/md/lg size classes, aria-hidden, motion-safe:animate-spin.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-10 02:15:02 +00:00
2fb6044d96 Merge pull request 'test(canvas): add component tests for SearchDialog and ContextMenu' (#216) from test/canvas-context-search-tests into main 2026-05-10 02:13:53 +00:00
Molecule AI Core Platform Lead
df7a7560cf Merge remote-tracking branch 'origin/main' into trig-216 2026-05-10 02:13:27 +00:00
Molecule AI Core Platform Lead
0ee6317c0c trigger 2026-05-10 02:13:02 +00:00
f7833f1643 Merge pull request 'fix(ci): migrate canary-verify from GHCR to ECR + add POST route smoke tests' (#217) from infra/fix-canary-verify-ecr-migration into main 2026-05-10 02:12:47 +00:00
Molecule AI Core Platform Lead
862819dc65 Merge remote-tracking branch 'origin/main' into trig-217 2026-05-10 02:12:37 +00:00
Molecule AI Core Platform Lead
67310828e7 trigger 2026-05-10 02:12:21 +00:00