Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ published without one. The same script, with no arguments, holds
errors; if it still does not fit it is not stored, and the report you had
stays. The Change column is worked out by the app from the two periods'
clicks, not written by the model. Reports written before this still open.
- **Every growth report is drawn the same way** (#646). Growth overview,
Social posts and Product now work like Search growth: a fixed layout the
agent fills with numbers and sentences, sent back once if it does not fit
and never stored half-wrong. Where a report shows a change or a share (a
platform's share of views, each funnel step against the first) the app
works it out from the figures, not the model. Reports written before this
still open, in the same layout; an old one whose numbers cannot be read
shows its verdict and asks to be refreshed.

### Added

Expand Down
10 changes: 9 additions & 1 deletion app/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,20 @@ The rules as code are `lib/artifactFormat.js`, and each artifact's own
never an instruction (`clipLog`).
- **A built-in artifact's words are translated here**: its layout is English,
and a table beside `lib/artifactCopy.js` (`siteHealthCopy.js`,
`searchGrowthCopy.js`) maps each string to its `msg`. A test fails on a
`searchGrowthCopy.js`, `growthReportCopy.js`) maps each string to its `msg`. A test fails on a
layout string with no entry, and on an entry the layout no longer uses.
- **A stored run is drawn by the artifact it names**
(`components/artifacts/StoredArtifactRun.jsx`): the row's content type is
`application/vnd.duct.artifact-run+json` and `meta.artifact_id` says which.
The layout comes from this build, never from the row.
- **Every growth report is an artifact** (Search growth, Growth overview,
Social posts, Product), drawn by `ArtifactView` and nothing else. A report
stored in the old block shape is read into its template's artifact by
`lib/legacyGrowthReport.js` (`StoredArtifactRun`'s `legacy`); there is no
second renderer to add a block to. Their shared parts (`headline`,
`signals`, `actions`, `sources`, a series) stay the same shape in all four:
Home's tile reads any of them (`coverFrom`), and the backend's
`test_artifact_runs.py` fails when they drift.
- **Its tests travel with it**: `tests/checks.json` says what must hold for
each fixture run, and `artifactFormat.test.js` runs every folder's, so a
change to a block that breaks an artifact fails `npm test`.
Expand Down
1 change: 0 additions & 1 deletion app/scripts/check-design-system.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ const RULES = [
re: /\bfrom\s*["'](?:recharts|@nivo\/[\w-]+|mermaid|react-syntax-highlighter(?!\/dist\/esm\/styles\/prism\/)[^"']*)["']/g,
allow: new Map([
["components/artifacts/ChartSpecView.jsx", "reached only through lazy() in ArtifactRenderer"],
["components/content/report/GrowthReportView.jsx", "lazy() in ArtifactRenderer; statically only from AnalyticsReport, a chart surface"],
["components/content/AnalyticsView.jsx", "lazy() in app/(app)/content/page.jsx"],
["components/workspace/HighlightedCode.jsx", "lazy() in workspace/CodeBlock"],
["components/insight-blocks", "InsightBlock → InsightDashboard → the stored insight page, a chart surface"],
Expand Down
97 changes: 44 additions & 53 deletions app/src/app/preview/scenes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ import SiteHealthReport from "@/components/audit/SiteHealthReport";
import StoredArtifactRun from "@/components/artifacts/StoredArtifactRun";
import SEARCH_GROWTH_SAMPLE from "@/artifacts/search-growth/sample.json";
import SEARCH_GROWTH_QUIET from "@/artifacts/search-growth/tests/runs/nothing-moved.json";
import GROWTH_OVERVIEW_SAMPLE from "@/artifacts/growth-overview/sample.json";
import SOCIAL_POSTS_SAMPLE from "@/artifacts/social-posts/sample.json";
import PRODUCT_GROWTH_SAMPLE from "@/artifacts/product-growth/sample.json";
import PRODUCT_GROWTH_QUIET from "@/artifacts/product-growth/tests/runs/nothing-moved.json";
import ArtifactView from "@/components/artifacts/host/ArtifactView";
import StageView from "@/components/artifacts/host/StageView";
import { sizeRatio } from "@/lib/artifactFormat";
Expand All @@ -117,9 +121,7 @@ import PlanStrategy from "@/components/content/PlanStrategy";
import PlanDayOne from "@/components/content/PlanDayOne";
import AccountsTab from "@/components/content/AccountsTab";
import AnalyticsView, { AnalyticsGate } from "@/components/content/AnalyticsView";
import AnalyticsReport from "@/components/content/AnalyticsReport";
import GrowthReportView from "@/components/content/report/GrowthReportView";
import { GROWTH_REPORT, reportPayload } from "@/lib/__fixtures__/growthReport.mjs";
import { GROWTH_REPORT } from "@/lib/__fixtures__/growthReport.mjs";
import { DiscoverGate } from "@/components/content/DiscoverPage";
import PlanList from "@/components/content/PlanList";
import PostMiniCard from "@/components/content/PostMiniCard";
Expand Down Expand Up @@ -5041,56 +5043,6 @@ export const SCENES = [
</div>
),
},
// The growth report over fixtures: `reads` answers the GET with one state
// and the POST with the "generating" one, so every state is a URL.
...[
["no_sources", "nothing connected", "Growth report, nothing to read from", "Every source is a dashed chip with its reason; the panel sends the person to the Toolbox or to a scheduler. Nothing to click that would spend a model run."],
["empty", "sources ready, never written", "Growth report, before the first run", "Ready sources are ticked by default and the one button writes the report. The line under it names what will be read and how long it keeps."],
["generating", "a run writing, no earlier copy", "Growth report being written", "The status line names the sources being read and the skeleton has the loaded layout's shape, so the swap changes texture, not geometry."],
["generating_with_old", "a run writing over a stale copy", "Refreshing a stale report", "The day-old report stays readable, dimmed, while the new one is written; the pickers are disabled for the run."],
["fresh", "written three hours ago", "Growth report, fresh", "The whole report: verdict, KPIs with their deltas, a line, ranked bars, a table, a pie with its legend, signals, actions, and the gaps at the foot."],
["stale", "written forty hours ago", "Growth report, stale", "Served as it is, with the status line saying how old it is and Refresh as the primary button. Nothing regenerates by itself."],
["failed", "the run failed, no earlier copy", "Growth report run failed", "The failure is said in the backend's words with the validation problems under it, and Try again is right there."],
["failed_with_old", "the run failed, an older copy exists", "Refresh failed, old report kept", "A failed refresh never takes away the report the person had; the error sits above it."],
].map(([state, label, title, note]) => ({
id: `analytics-report-${state.replace(/_/g, "-")}`,
state: label,
group: "AnalyticsReport",
title,
note,
render: () => (
<div className="p-5">
<AnalyticsReport
projectId="preview"
onLinkAccounts={() => {}}
reads={{
get: async () => reportPayload(state),
generate: async () => reportPayload("generating", { report: reportPayload(state).report }),
}}
/>
</div>
),
})),
{
id: "growth-report-view",
state: "the stored report alone",
group: "GrowthReportView",
title: "A growth report, as the artifact library shows it",
note: "The same view the Analytics tab draws, with no pickers: this is what opens from the library and the artifact pane.",
render: () => <div className="p-5"><GrowthReportView report={GROWTH_REPORT} /></div>,
},
{
id: "growth-report-view-sparse",
state: "one KPI block and one gap",
group: "GrowthReportView",
title: "A report with one block",
note: "A run that could read one source writes one block and says what it could not check. The layout holds at the smallest count.",
render: () => (
<div className="p-5">
<GrowthReportView report={{ ...GROWTH_REPORT, blocks: GROWTH_REPORT.blocks.slice(0, 1), sources: GROWTH_REPORT.sources.slice(0, 1), could_not_check: ["Everything but Search Console: no other source was connected."] }} />
</div>
),
},
{
id: "analytics-no-scheduler",
state: "no scheduler connected",
Expand Down Expand Up @@ -5711,6 +5663,45 @@ export const SCENES = [
<StoredArtifactRun className="p-4" artifact={{ meta: { artifact_id: "duct/artifacts/search-growth" }, structured_json: SEARCH_GROWTH_QUIET }} />
),
},
...[
["growth-overview", GROWTH_OVERVIEW_SAMPLE, "Growth overview report", "a full run: four numbers, a line, channels, a table, posts, product numbers",
"The Growth overview artifact (src/artifacts/growth-overview) drawn from its sample run. What to check: channels show each one's share of the sessions listed, worked out by the app; the second strip of numbers (Product) sits under its own title; the search table's Change column is worked out from two numbers."],
["social-posts", SOCIAL_POSTS_SAMPLE, "Social posts report", "a full run: posts ranked, views by platform, visits from social",
"The Social posts artifact (src/artifacts/social-posts). What to check: a post's title wraps rather than clips and its platform sits under it; Views by platform shows each platform's share of the total, not a pie."],
["product-growth", PRODUCT_GROWTH_SAMPLE, "Product report", "a full run: a funnel, key events, friction and experiments",
"The Product artifact (src/artifacts/product-growth). What to check: each funnel step shows its share of the first; rage and dead clicks are percentages of the page's sessions; an experiment's status and result read as words, not as a number column."],
["product-growth-quiet", PRODUCT_GROWTH_QUIET, "Product report, a month where nothing moved", "edge: the numbers alone",
"Every block with nothing in it is left out; the sources and what could not be checked stay."],
].map(([id, run, title, state, note]) => ({
id: `${id}-report`,
group: "Reports",
title,
state,
note,
render: () => (
<StoredArtifactRun className="p-4" artifact={{ meta: { artifact_id: `duct/artifacts/${id.replace(/-quiet$/, "")}` }, structured_json: run }} />
),
})),
{
id: "growth-report-stored-before",
group: "Reports",
title: "A growth report stored in the old shape",
state: "a report written in the block shape, read into its artifact",
note: "A Growth overview written as blocks and rows, the shape every growth report had until they became artifacts. lib/legacyGrowthReport.js reads it into a run of the Growth overview artifact, so there is one renderer. What to check: the numbers, the line, the channels, the queries, the posts, signals and actions all come through; nothing is drawn that the old report did not have.",
render: () => (
<StoredArtifactRun className="p-4" legacy artifact={{ meta: { template: "growth_overview" }, structured_json: GROWTH_REPORT }} />
),
},
{
id: "growth-report-stored-unreadable",
group: "Reports",
title: "A growth report in the old shape that cannot be read",
state: "edge: no headline numbers to draw",
note: "An old report with no headline numbers cannot fill its artifact, so it is not drawn wrong: the verdict stays, and the person is told to refresh it.",
render: () => (
<StoredArtifactRun className="p-4" legacy artifact={{ meta: { template: "seo" }, structured_json: { ...GROWTH_REPORT, blocks: [] } }} />
),
},
{
id: "artifact-run-newer",
group: "Reports",
Expand Down
40 changes: 40 additions & 0 deletions app/src/artifacts/growth-overview/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Growth overview

How growth went over a period against the one before, across search, traffic, social posts and signups, with what moved and what to do. The insights agent
fills it: this folder is the report's shape, and a run is the numbers and
sentences that go in. It follows the same rules as
[`../search-growth/AGENTS.md`](../search-growth/AGENTS.md); read that first.
The format every artifact follows is
[`docs/engineering/artifact-format.md`](../../../../docs/engineering/artifact-format.md).

## What is here

| File | What it is |
|---|---|
| `artifact.json` | The manifest: what this is, what it reads, how it refreshes |
| `report.json` | The layout: the blocks, in order, each bound to the run |
| `data.schema.json` | The contract: what the agent must return |
| `sample.json` | A run to show before any real one exists |
| `tests/` | Fixture runs, and `checks.json`: what must hold for each |
| `skills/fill-growth-overview/` | How the agent fills a run: which pull fills which part |
| `artifact.lock.json` | Generated: a hash of every file here |

## What must not change

- **The agent writes data, never layout.**
- **The run quotes; the app works out.** A count carries both periods'
figures and the app writes the change; a ranking carries values and the app
writes any share.
- **Its parts match the Search growth report's.** `headline`, `signals`,
`actions`, `sources`, `could_not_check` and a series have the same shape in
all four growth reports, so a run of one can be compared with the next and
the Home tile reads any of them.
- **A block with nothing in it is left out, not drawn empty.**

## Changing it

1. Change `report.json` and `data.schema.json` together, then `sample.json`,
the runs under `tests/runs/` and the fill skill.
2. `npm --prefix app run artifacts:build`, then `npm --prefix app test` and
the backend's tests.
3. Look at it: `/preview`, scene `growth-overview-report`.
69 changes: 69 additions & 0 deletions app/src/artifacts/growth-overview/artifact.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"$schema": "https://getduct.ai/schemas/artifact/v1.json",
"id": "duct/artifacts/growth-overview",
"version": "1.0.0",
"title": "Growth overview",
"description": "How growth went over a period against the one before, across search, traffic, social posts and signups, with what moved and what to do. Use when someone asks how growth is going overall, or which channel moved.",
"author": {
"name": "Duct",
"handle": "duct"
},
"license": "MIT",
"goals": [
"Weekly active users",
"Monthly active customers",
"Net new revenue",
"Qualified leads",
"more growth across channels"
],
"icons": [
{
"src": "icons/icon.svg",
"sizes": "any",
"type": "image/svg+xml"
}
],
"display": [
"tile",
"page"
],
"app": {
"kind": "layout",
"entry": "report.json",
"data": "data.schema.json"
},
"permissions": {
"connectors": {
"required": [
{
"anyOf": [
"duct/connector/gsc",
"duct/connector/ga4",
"duct/mcp/posthog",
"duct/connector/publishers",
"duct/mcp/openseo",
"duct/connector/google-ads",
"duct/connector/mixpanel"
],
"adds": "Any one of search, traffic, posts, product or ads numbers."
}
],
"optional": []
},
"model": false,
"actions": false
},
"skills": [
{
"ref": "skills/fill-growth-overview"
}
],
"refresh": {
"manual": true,
"suggestAfter": "P1D",
"schedule": null,
"compare": "previous"
},
"sample": "sample.json",
"cost": "medium"
}
17 changes: 17 additions & 0 deletions app/src/artifacts/growth-overview/artifact.lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"lockVersion": 1,
"id": "duct/artifacts/growth-overview",
"version": "1.0.0",
"files": {
"AGENTS.md": "84e6b10545a60f30328426cb397f8b5bebc032091da568ceb1f5af00b8953d2f",
"artifact.json": "27830d96be9b7698d530c6fdbdb73a3965897704c23b8b4d57b464151015cce6",
"data.schema.json": "1ba35ce1763e34527cd5b20e883348b33e8f25d53f7ea5cb12a058cfb3a21fd0",
"icons/icon.svg": "fb20b83f2022b8178ce8072ca46a622e1cf58858bdfe50e7a7f73ef0e7980a7b",
"report.json": "eaca0c9c661e2a456f39356ec988d7cf08b37d6fdbc88c9a3b2f9fe253c06163",
"sample.json": "0dfb343acc050ae1e6765a366b367d4309706d5e955e3c2796cf8e100196ac50",
"skills/fill-growth-overview/SKILL.md": "a42f0775f5546aa807b12c1eb2f2630485c5ea91b9cff6bc68543388ec97a046",
"tests/checks.json": "ee94584e95058c11b6941a55cc115125b9571f45936d31831b69fbb7a58fd450",
"tests/runs/broken.json": "871a91bd7a6867a15647fb6defcc03dac468c46e051f18adefb63b167ae1270b",
"tests/runs/nothing-moved.json": "0ec929764c8ddcf091a5fd973d35a5506f8477723ff301d68de43a2e63ba929a"
}
}
Loading
Loading