Skip to content

Ralph/prd 141 widget vertical refactor#388

Merged
AutomatosAI merged 11 commits into
mainfrom
ralph/prd-141-widget-vertical-refactor
May 28, 2026
Merged

Ralph/prd 141 widget vertical refactor#388
AutomatosAI merged 11 commits into
mainfrom
ralph/prd-141-widget-vertical-refactor

Conversation

@AutomatosAI
Copy link
Copy Markdown
Owner

No description provided.

- US-011 (byte-equality snapshot tests) moved ahead of US-005 so the
  equivalence net guards every lift (US-005-010) in real time instead of
  landing after the US-010 hard-cut delete.
- US-012 grep gate: drop PCRE (?!...) lookahead (incompatible with grep -E;
  macOS has no grep -P) for a portable two-pass POSIX ERE check.
- US-009: Ralph validates the migration offline only (alembic --sql +
  py_compile + reviewer agent); staging apply + rowcount deferred to human.
Adds byte-equality tests against the US-004 fixtures that run through the
US-003 shim end-to-end. Conftest AST-extracts the four proactive helpers
from real chat.py and injects them as a fake api.widgets.chat module
plus a fixture-bound GraphifyService stub, so the tests exercise
production source without paying the full FastAPI/RAG import cost. The
synthetic INBUILD-flavoured graph exercises every branch (FBT walk,
collection/vendor fallback, multi-seed cart aggregation, by_vendor-
overrides-FBT NetworkX undirected quirk). Now-green snapshot net gates
the US-005/006/007/008/010 lifts — must stay green through every move.

Validation: pytest orchestrator/integrations/ → 32 passed; py_compile
clean on the two changed Python files. `from main import app` is
environment-blocked on a missing camelot native dep (unrelated to this
PR; same blocker on baseline) so was not re-run as part of US-011.

Story: scripts/ralph/prd.json US-011
PRD: docs/PRDS/141-WIDGET-VERTICAL-AGNOSTIC-REFACTOR.md
…context_value into integrations/shopify/

First ACTUAL move out of orchestrator/api/widgets/chat.py. Creates
integrations/shopify/context_fields.py hosting the field-mapping tuple
and single-value formatter — verbatim copies, no value or behaviour
changes. chat.py now imports both from the new module so
_build_proactive_opener_message keeps rendering identical output
through US-008. conftest.py and regenerate.py drop the two names from
their AST-extract sets and seed them into the exec namespace via a
direct import (context_fields has no heavy deps). US-011 byte-equality
snapshot tests stay green (14/14).

Story: scripts/ralph/prd.json US-005
PRD: docs/PRDS/141-WIDGET-VERTICAL-AGNOSTIC-REFACTOR.md
…egrations/shopify/

Move the single-seed FBT/collection/vendor walk verbatim from
orchestrator/api/widgets/chat.py to
orchestrator/integrations/shopify/widget_proactive.py. The shim's
product-page path now calls the local function and only lazy-imports
_build_proactive_opener_message from chat.py (until US-008). chat.py
keeps the existing call site at the proactive_opener branch and
imports the resolver from the new home; the function definition is
gone from chat.py. Conftest drops the AST extraction for this name and
test_widget_proactive's fake_chat fixture monkeypatches the local
resolver so delegation tests still record calls. All 32
integrations/ tests stay green including the US-011 byte-equality
snapshots.

Story: scripts/ralph/prd.json US-006
PRD: docs/PRDS/141-WIDGET-VERTICAL-AGNOSTIC-REFACTOR.md
…rations/shopify/

Move the multi-seed cart-idle FBT walk verbatim from
orchestrator/api/widgets/chat.py to
orchestrator/integrations/shopify/widget_proactive.py. The shim's
cart_idle path now calls the local resolver and only lazy-imports
_build_cart_idle_opener_message from chat.py (until US-008). chat.py
keeps the existing call site at the cart_idle branch and imports the
resolver from the new home; the function definition is gone from
chat.py. Conftest drops the AST extraction for this name and
test_widget_proactive's fake_chat fixture monkeypatches the local
resolver so delegation tests still record calls. All 32 integrations/
tests stay green including the US-011 byte-equality snapshots.

Story: scripts/ralph/prd.json US-007
PRD: docs/PRDS/141-WIDGET-VERTICAL-AGNOSTIC-REFACTOR.md
…to integrations/shopify/

Move _build_proactive_opener_message and _build_cart_idle_opener_message verbatim
from orchestrator/api/widgets/chat.py to orchestrator/integrations/shopify/widget_proactive.py.
chat.py now imports both from the integrations module; widget_proactive's handle_widget_message
calls the local builders directly (lazy api.widgets.chat imports dropped).

Tests rewired: orchestrator/tests/test_widget_proactive_prd007.py imports the two builders from
their new home; integrations/shopify/tests/test_widget_proactive.py's fake_chat fixture now
monkey-patches the builders on widget_proactive (consistent with the resolver patches from
US-006/007); conftest.py's AST extraction of chat.py is removed — only the GraphifyService
stub remains. All 32 integrations tests pass including the byte-equality snapshot tests.

Story: scripts/ralph/prd.json US-008
PRD: docs/PRDS/141-WIDGET-VERTICAL-AGNOSTIC-REFACTOR.md
…ify workspaces

New Alembic migration sets settings.vertical='shopify' on every workspace
whose JSONB settings already contain shopify_domain. Idempotent (WHERE
NOT settings ? 'vertical'). Downgrade only strips vertical from rows we
set it on. Lands in same PR as US-010 to keep INBUILD's PRD-007 +
PRD-008-B dispatch routing intact.

Validated OFFLINE only: py_compile OK, `alembic upgrade … --sql` renders
upgrade + downgrade cleanly, `pytest integrations/` 32/32 green,
migration-reviewer agent PASS. Staging apply + rowcount verification
deferred to human before merge (per US-009 AC #7).

Story: scripts/ralph/prd.json US-009
PRD: docs/PRDS/141-WIDGET-VERTICAL-AGNOSTIC-REFACTOR.md
Generic widget endpoint now resolves vertical from
workspace.settings.vertical (default 'generic') and dispatches the
message through PLUGIN_REGISTRY[vertical].handle_widget_message. The
Shopify-specific helpers are no longer imported into chat.py — they
stay private to integrations/shopify/. The product_context fallback
in the open-callback-form SSE bridge dropped its productTitle/
productHandle reads; the LLM tool call is now the only source.
Observability preserved: PROACTIVE_REWRITE and UNKNOWN_TRIGGER_REASON
log lines rebuilt from plugin telemetry, now carrying vertical=.

Plugin docstrings, context_note values, and test fixtures dropped
"shim" wording — post-rewire the Shopify plugin owns the path
end-to-end. US-009 backfill migration (cbc3b1a) ships in the same
PR for the atomic deploy required by US-010 notes.

Validation: pytest integrations/ → 32/32 green (snapshot byte-equality
for PRD-007 + PRD-008-B openers held). grep -rE
'productHandle|productTitle|cartItems|shopify_'
orchestrator/api/widgets/chat.py orchestrator/modules/context/sections/
returns zero matches. Manual smoke test on INBUILD is deferred to the
US-020 canary (human-only).

Story: scripts/ralph/prd.json US-010
PRD: docs/PRDS/141-WIDGET-VERTICAL-AGNOSTIC-REFACTOR.md
… surfaces

Adds scripts/ci/check-no-shopify-in-generic.sh (POSIX ERE, two-pass:
forbidden field keys + shopify_ prefix with plugin/integration/sync
allowlist) and wires it into a minimal .github/workflows/
check-shopify-isolation.yml that runs on push to main/ralph and on PRs
to main. Behaviourally verified offline: clean tree passes, injected
productHandle fails Pass A, injected shopify_widget_id fails Pass B,
and shopify_plugin/integration/sync pass through the allowlist. The 32
US-011 integration tests stay green.

Story: scripts/ralph/prd.json US-012
PRD: docs/PRDS/141-WIDGET-VERTICAL-AGNOSTIC-REFACTOR.md
Adds the step-by-step guide a future engineer follows to ship vertical #2
without touching generic surfaces. Covers what a vertical is, when to add
one, the copy-paste-modify recipe (with a ~30-line minimal plugin), the
§12 MAY-NOT rules, snapshot + grep-gate test requirements, where admin UI
goes, and skill registration. Points at integrations/shopify/widget_proactive.py
as the working reference.

Story: scripts/ralph/prd.json US-018
PRD: docs/PRDS/141-WIDGET-VERTICAL-AGNOSTIC-REFACTOR.md
…n; PRD-141 build complete (cross-repo + canary stories remain BLOCKED for human)

Adds docs/architecture/integration-walkthrough-barbershop.md — a worked
end-to-end walkthrough of adding a hypothetical "barbershop" vertical
(ClipShop UK booking site) against the Phase 1 plugin protocol. Mirrors
Shopify's package layout, handle_widget_message dispatch, and graph-
backed message builders to prove the abstraction is not Shopify-shaped
in disguise. Produces the PRD §13 target opener byte-for-byte ("Looking
at booking with Sarah for a fade — her next opening is Tuesday at 2pm.
Want me to hold it?"), routed via PLUGIN_REGISTRY exactly as Shopify is.

Catalogues seven Known Abstraction Gaps surfaced by the walkthrough:
no convention for partner-API calls inside the rewrite (Gap 1);
centralised PROACTIVE_TRIGGER_REASONS in chat.py (Gap 2); no missing-
skill detection at dispatch (Gap 3); duplicated _format_opener_context_
value (Gap 4); no page_context schema versioning (Gap 5); multi-location
overrides (Gap 6); sync Session in async protocol (Gap 7). Verdict:
Phase 1 protocol is vertical-neutral enough to ship; all gaps are
additive and defer to the PRD that adds vertical #2.

Story: scripts/ralph/prd.json US-019
PRD: docs/PRDS/141-WIDGET-VERTICAL-AGNOSTIC-REFACTOR.md

Ralph executable scope complete:
  - US-001..US-012 done (Phase 0/1 scaffolding + lifts + CI gate)
  - US-018, US-019 done (docs)
  - US-013/014/015 — BLOCKED-CROSS-REPO (automatos-widget-sdk)
  - US-016/017     — BLOCKED-CROSS-REPO (automatos-skills)
  - US-020         — SKIPPED-HUMAN (operational canary)

RALPH_COMPLETE
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 28, 2026

Warning

Review limit reached

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

More reviews will be available in 56 minutes and 56 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 08211ed1-316d-4a85-9e84-767998f4c696

📥 Commits

Reviewing files that changed from the base of the PR and between 6879748 and 5f9254b.

📒 Files selected for processing (17)
  • .github/workflows/check-shopify-isolation.yml
  • docs/architecture/integration-walkthrough-barbershop.md
  • docs/integrations/README.md
  • orchestrator/alembic/versions/20260528_backfill_workspace_vertical.py
  • orchestrator/api/widgets/chat.py
  • orchestrator/integrations/shopify/__init__.py
  • orchestrator/integrations/shopify/context_fields.py
  • orchestrator/integrations/shopify/tests/conftest.py
  • orchestrator/integrations/shopify/tests/fixtures/README.md
  • orchestrator/integrations/shopify/tests/fixtures/regenerate.py
  • orchestrator/integrations/shopify/tests/test_widget_proactive.py
  • orchestrator/integrations/shopify/widget_proactive.py
  • orchestrator/tests/test_widget_proactive_prd007.py
  • scripts/ci/check-no-shopify-in-generic.sh
  • scripts/ralph/IMPLEMENTATION_PLAN_prd141.md
  • scripts/ralph/prd-141-widget-vertical.json
  • scripts/ralph/prd.json
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ralph/prd-141-widget-vertical-refactor

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.

@AutomatosAI AutomatosAI merged commit f74d905 into main May 28, 2026
2 of 3 checks passed
@AutomatosAI AutomatosAI deleted the ralph/prd-141-widget-vertical-refactor branch May 28, 2026 22:12
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.

2 participants