@crvouga/mockingbird-service-vibe 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog — @crvouga/mockingbird-service-vibe
2
+
3
+ ## 0.1.0 (2026-10-05)
4
+
5
+ Initial release.
package/DISCOVERY.md ADDED
@@ -0,0 +1,55 @@
1
+ # @crvouga/mockingbird-service-vibe discovery
2
+
3
+ This is the installed-package index for coding agents and tooling. All relative links resolve
4
+ inside `node_modules/@crvouga/mockingbird-service-vibe/`; no repository checkout is needed to discover the mock's
5
+ supported surface or documented behavior.
6
+
7
+ ## Capability and behavior sources
8
+
9
+ | Question | Authoritative file | What it contains |
10
+ | --- | --- | --- |
11
+ | Behaviour and integration | [`README.md`](README.md) | Routes, state transitions, auth, webhooks, controls, presets and deliberate omissions. |
12
+ | Exact capabilities | [`SUPPORT.md`](SUPPORT.md) | Supported, unsupported and parity-covered operations or commands, including reasons for gaps. |
13
+ | Wire contract | [`openapi.yaml`](openapi.yaml) | Machine-readable paths, methods, schemas, responses and parity annotations. |
14
+ | Public API | [`dist/index.d.ts`](dist/index.d.ts) | The installed package's exact TypeScript exports and signatures. |
15
+ | Package metadata | [`package.json`](package.json) | Runtime/entry-point claims, vendor links, parity scope/tier and `mockingbird.discovery`. |
16
+
17
+ Read these together: the contract/capability matrix says *what* is available, while the README
18
+ defines stateful behavior, lifecycle rules, test controls, and intentional oracle differences.
19
+ If prose and an executable surface disagree, report a parity mismatch instead of adding a
20
+ consumer-side workaround.
21
+
22
+ ## Parity and oracle
23
+
24
+ - Declared parity surface: **OAuth and asynchronous JSON reports**.
25
+ - Parity tier: **cold** (the repository controls when live checks run).
26
+ - Oracle: **Live vendor API or sandbox**.
27
+ - Repository command: `bun run parity:service -- vibe`.
28
+ - Evidence model: Run from a Mockingbird checkout; credentials come only from .env.local or GitHub Actions secrets. Missing credentials exit 2.
29
+
30
+ The npm package contains evidence summaries and the exact contract, not credentials or the
31
+ repository-only parity harness. Self-parity/property and acceptance tests run in the Mockingbird
32
+ repository; live parity is an additional oracle check, not a substitute for the packaged matrix.
33
+
34
+ ## Runtime introspection
35
+
36
+ - `GET /__admin/health`
37
+ - `GET /__admin`
38
+ - `GET /__admin/state`
39
+ - `GET /__admin/requests`
40
+ - `GET /__admin/metrics`
41
+ - `GET /__admin/faults/presets`
42
+ - `GET /__admin/ui`
43
+
44
+ For HTTP services, use `x-mockingbird-namespace` (or the documented credential/path carrier) so
45
+ parallel tests do not share state. Admin state, journal, metrics and fault-preset endpoints are
46
+ designed for assertions and diagnosis by consuming test suites.
47
+
48
+ ## Report a mismatch or missing capability
49
+
50
+ Follow the [agent reporting contract](https://github.com/crvouga/mockingbird/blob/main/docs/REPORTING_ISSUES.md). Include package version,
51
+ operation/command, a minimal redacted request, actual mock result, expected oracle result or vendor
52
+ documentation, and whether the mismatch appears in the matrix. Never include keys, tokens,
53
+ customer data, prompts, PHI, card data, or unredacted recordings.
54
+
55
+ Service key: `vibe`.
package/README.md ADDED
@@ -0,0 +1,95 @@
1
+ # @crvouga/mockingbird-service-vibe
2
+
3
+ > Familiar calls. Faithful echoes. Part of [Mockingbird](https://github.com/crvouga/mockingbird).
4
+
5
+ WIP Vibe revision **2026-06-01** OAuth and asynchronous campaign-spend reports.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ bun add @crvouga/mockingbird-service-vibe
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```ts
16
+ import { createRuntime, DEFAULT_ADVERTISER } from "@crvouga/mockingbird-service-vibe"
17
+ const vibe = createRuntime({ rows: [{
18
+ advertiser_id: DEFAULT_ADVERTISER, impression_date: "2026-01-01", spend: "12.50",
19
+ }] })
20
+ const response = await vibe.fetch(new Request("http://vibe.test/reports", {
21
+ method: "POST",
22
+ headers: { authorization: "Bearer mock_vibe_token", "x-vibe-revision": "2026-06-01", "content-type": "application/json" },
23
+ body: JSON.stringify({ start_date: "2026-01-01", end_date: "2026-01-02", advertiser_ids: [DEFAULT_ADVERTISER], dimensions: ["impression_date"], metrics: ["spend"] }),
24
+ }))
25
+ const report = await response.json()
26
+ console.log(report.id, report.status)
27
+ ```
28
+
29
+ Run `mockingbird-vibe serve --port 12128`, then inject `http://localhost:12128` as the
30
+ consumer's API origin. Downloads point at this same origin. There is no universal vendor
31
+ environment variable for that override; keep the consumer's production HTTPS policy intact.
32
+
33
+ ### Contract
34
+
35
+ - `POST /oauth2/token`: form-encoded client_credentials with HTTP Basic credentials.
36
+ Default synthetic client is mock_client / mock_client_secret. Optional scope must be a
37
+ subset of the client's scopes. Response includes bearer token, scope and expires_in.
38
+ This endpoint does not require X-Vibe-Revision; failures use the standard OAuth envelope.
39
+ - `POST /reports`: JSON report request, Bearer token and pinned revision. Returns 201
40
+ with UUID/status/created_at. Advertisers must belong to the client. Windows are start-inclusive,
41
+ end-exclusive, positive and at most 45 days. JSON/DAY fixtures only.
42
+ - `GET /reports/{report_id}`: only the owning client can poll. Default clock progression:
43
+ CREATED initially, PROCESSING at one second, READY at two seconds. READY includes the
44
+ local download_url and generation/expiration timestamps; FAILED includes failure_reason.
45
+ - Internal `/__admin/blobs/{id}?token=…`: local stand-in for the vendor's pre-signed download.
46
+ Returns a JSON array of synthetic rows, preserves numeric-as-string metrics and nulls,
47
+ and expires 24 hours after generation. Capability values are deterministic test stand-ins,
48
+ not production signing. No browser tracking or real campaign data is fetched.
49
+
50
+ Seed `clients`, pre-aggregated `rows` and `settings` through constructor options or shared
51
+ `/__admin/state`. Reports retain fixture rows at creation time and select requested columns.
52
+ Fixture dates are already in the requested reporting timezone; no attribution or aggregation
53
+ engine is implied. Default bearer mock_vibe_token is valid for one hour from initial seeding.
54
+
55
+ ### Test controls
56
+
57
+ Collections: clients, tokens, rows, reports, settings. Settings expose processingMs, readyMs
58
+ and tokenTtlSeconds. Reports expose readyAt (null means stuck), failure and missingArtifact.
59
+ Use the shared clock to advance lifecycle/expiry, and shared Timeline/reset/state/journal APIs.
60
+ Reset restores constructor fixtures. Journals contain metadata, never report rows or credentials.
61
+ Namespaces work by header, mapped bearer token or `/__admin/ns/{name}` path. Download links
62
+ retain namespace and custom `adminPrefix` routing.
63
+
64
+ Presets: rate_limited (scripted 429/Retry-After), server_error (500), connection_drop,
65
+ report_failed and report_stuck. Shared fault rules also provide deterministic latency.
66
+ These are test controls; they do not model a real sliding-window quota or actual processing SLA.
67
+ No webhooks are needed for this subset.
68
+
69
+ Acceptance tests exercise all four issue #271 behaviors, OAuth expiry/scope, local artifact
70
+ expiry/missing files, namespaces/reset/redacted journals and served HTTP. Property tests run
71
+ every parity-enabled operation and detect divergence. `bun scripts/parity.ts` uses
72
+ VIBE_ACCESS_TOKEN and VIBE_REPORT_ID for a read-only existing-report envelope check; live
73
+ authenticated parity has not run. `bun scripts/parity.ts --unauthenticated` compares missing/
74
+ invalid synthetic-token errors against the real endpoint. This probe passed and confirms
75
+ `token_invalid` plus `WWW-Authenticate: Bearer`, differing from the documentation's
76
+ `invalid_token` example. The rest of the contract follows the published OpenAPI reference.
77
+
78
+ ### Deliberately not modelled
79
+
80
+ Ad purchases, campaign mutation, attribution inference, production JWT signing, OAuth browser
81
+ consent/refresh, CSV or non-DAY reports, metric aggregation, timezone conversion, and report
82
+ filter expressions. Seed already-aggregated rows for the requested dimensions. The mock
83
+ rejects CSV/non-DAY requests even though the vendor supports them; those are outside this
84
+ initial consumer subset. It does not claim full vendor API or live rate-limit parity.
85
+
86
+ ## API
87
+
88
+ - `VibeAPI`: FetchAPI, reset and state collections.
89
+ - `createRuntime`: shared admin/namespace/clock/fault surface.
90
+ - `VIBE_NAMESPACE`, `VIBE_PRESETS`, `DEFAULT_ADVERTISER`: service constants.
91
+ - `document`, `operationIds`, `supportedOperationIds`: generated contract metadata.
92
+ - `createServer`, `serveTarget`, `DEFAULT_PORT` from `./server`: Node HTTP/CLI entry points.
93
+
94
+ Public types: Client, Token, Row, Report, Settings, VibeAPIOptions, OperationId,
95
+ SupportedOperationId; server types are VibeServerOptions and VibeServer.
package/SUPPORT.md ADDED
@@ -0,0 +1,14 @@
1
+ # Vibe Public API — operation support
2
+
3
+ Generated from `openapi.yaml`; do not edit by hand.
4
+
5
+ - operations in spec: **4**
6
+ - supported by the mock: **4**
7
+ - parity enabled: **3**
8
+
9
+ | operationId | route | mock | parity | notes |
10
+ | --- | --- | --- | --- | --- |
11
+ | `CreateReport` | `POST /reports` | ✅ supported | ⚠️ unsafe (opt-in) | |
12
+ | `GetReport` | `GET /reports/{report_id}` | ✅ supported | ✅ | |
13
+ | `OAuthToken` | `POST /oauth2/token` | ✅ supported | ⚠️ unsafe (opt-in) | |
14
+ | `DownloadReport` | `GET /__admin/blobs/{id}` | ✅ supported | ❌ disabled | Mock-only capability URL; exercised by acceptance tests. |