Repository navigation
feat: multi-store intelligence with adapters, decomposition and read-only pricing - #20
Merged
Merged
Conversation
Add Amazon/Shopify style CSV presets for orders, ads and inventory, exposed through a read-only adapter catalog and accepted by preview/commit. Import batches record the adapter id; validation, atomic ingest and idempotency stay unchanged. Scope product SKU uniqueness to tenant so the same SKU can exist in different tenants; migration 0006 rebuilds SQLite products, preserves order references and refuses unsafe rollback.
…aved weekly tool Extend the existing profit bridge with a deterministic volume/price/mix decomposition that closes to the sales delta in integer cents, and add bounded price suggestions marked as read-only recommendations. Expose get_saved_weekly_report through the read-only MCP allowlist with tenant filtering, cache weekly snapshots by id, and keep chat answers gated by numeric and evidence checks.
Add adapter selection to the import center, show volume/price/mix evidence and read-only price suggestions on the intelligence page, and sync API types with the backend contract. Add a Playwright screenshot spec that drives the real import, weekly and chat flows without response interception.
Document the adapter catalog, tenant-scoped SKU migration, decomposition evidence and saved weekly MCP tool. Add Amazon/Shopify CSV samples, six browser screenshots and the final verification record.
Weekly chat now treats asp, suggested price, current price, attributed sales, and sales change as cents, while counts and percentages stay unconverted. Alembic uses -x, then an explicit sqlalchemy.url, before the process environment. Sample orders include a prior synthetic week so the 2020-01-12 report has a closed volume, price, and mix split, including new and discontinued SKUs. Price suggestions abstain when cost is unproven, and --demo-db starts data/demo-copy.db without migrating the runtime database. Co-authored-by: Akaliup <Akaliup@users.noreply.github.com>
The five-minute path uses python scripts/dev.py --demo-db. The docs describe the sales decomposition, read-only pricing rules, the three offline adapters, and the new citable ids. They no longer say the sample has no prior-week sales or that MCP tests are a fixed count of 9. Co-authored-by: Akaliup <Akaliup@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
adapter参数,批次记录适配器 ID;原有校验、原子导入与幂等逻辑不变0006_tenant_scoped_sku,SQLite 重建保留订单关联,跨租户重名时拒绝回退rule_version与INSUFFICIENT_DATA分支,不执行改价get_saved_weekly_report,按当前服务租户过滤,其他租户报告拒绝返回docs/CONTRACT.md、frontend/src/types.ts与测试;补充平台 CSV 样例、六张截图与交付记录迁移
backend/migrations/versions/0006_tenant_scoped_sku.py,接在0005_weekly_chat后。products,移除旧全局唯一约束,保留数据与子表外键实际验证
在最终代码上实际执行:
.venv/Scripts/python.exe -m pytest backend/tests -q→ 348 passed, 6 skipped(跳过项为未配置PROFITOPS_TEST_POSTGRES_URL的 PostgreSQL 集成测试)npm --prefix frontend test→ 24 passednpm --prefix frontend run build→ 通过(仅 chunk 超过 500 kB 警告).venv/Scripts/python.exe scripts/mcp_check.py→ 通过,七个只读工具可用,写入与问答工具未暴露,未配置模型.venv/Scripts/python.exe scripts/smoke.py --base-url http://127.0.0.1:8023→ 21/21;临时 SQLite、LLM_PROVIDER=disabled、hashing embedding,启动目录不含本地.envpython -m pytest backend/tests/test_migrations.py ...相关迁移用例包含在完整后端结果内说明:本地未跟踪的
.env设置了KNOWLEDGE_MIN_SCORE=0.42,会让离线 hashing embedding 的冒烟检索低于阈值;冒烟改用不含.env的工作目录启动,代码与依赖不变。未验证
边界
frontend/src/types.ts与docs/CONTRACT.md.env、API Key、数据库、缓存或构建产物;plans/未纳入版本概要
amazon-orders、shopify-orders、amazon-ads。没有库存适配器。preview/commit 接受adapter,服务端再次校验;非法 JSON、未知 adapter、kind 不匹配返回 422,整批不入账。不连接卖家后台0006_tenant_scoped_skusales_change。新建或下架 SKU 不估算缺失 ASP,其销售额变化进入销量项后再拆结构效应pricing-rules-v1。可变成本为 0 且不能证明成本已导入时不给建议价get_saved_weekly_report,按当前服务租户过滤。没有新增周报快照缓存;提交d104329说明里的 “cache weekly snapshots by id” 与代码不符end_date=2020-01-12的量价拆解为确定整数美分,不是已验证的经营因果python scripts/dev.py --demo-db只使用data/demo-copy.db并打印 URL,不迁移data/profitops.db。不带该参数时仍使用 Settings /.env迁移
backend/migrations/versions/0006_tenant_scoped_sku.py,接在0005_weekly_chat后。Alembic URL 优先级:
-x url=/-x database_url=,然后本次 Config 里非占位的sqlalchemy.url,然后PROFITOPS_DATABASE_URL/ALEMBIC_DATABASE_URL,最后才是Settings().database_url。实际验证
在本轮代码上实际执行(Linux,仓库内
.venv,临时 SQLite):PYTHONPATH=backend .venv/bin/python -m pytest backend/tests -q→ 360 passed, 6 skipped(跳过项为未配置PROFITOPS_TEST_POSTGRES_URL的 PostgreSQL 集成测试)npm --prefix frontend test -- --run→ 27 passednpm --prefix frontend run build→ 通过(仅 chunk 超过 500 kB 警告)PYTHONPATH=backend .venv/bin/python scripts/mcp_check.py→ 通过,七个只读工具可用,写入与问答工具为unknown_tool,llm_configured=false未验证
data/profitops.db)docs/screenshots/weekly-decomposition.png仍是上期销量为零时的画面,利润环比会与补上上一周订单后的页面不一致;当期销售额 US$160.01 仍与样例当期订单一致边界
.env、API Key、数据库、缓存、构建产物或plans/