feat(seo): integrate analytics worker and real HTTP PostgreSQL acceptance
This commit is contained in:
1 parent
5750e1589e
commit
312fcc2acc
19 files changed
+1120
No files matched your search
@@ -0,0 +1,66 @@
|
||||
import 'reflect-metadata';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import { PassportModule, PassportStrategy } from '@nestjs/passport';
|
||||
import { Strategy, ExtractJwt } from 'passport-jwt';
|
||||
import { JwtService } from '@nestjs/jwt';
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { spawn } from 'child_process';
|
||||
import { resolve } from 'path';
|
||||
import { SeoTrackingModule } from './seo-tracking.module';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
|
||||
class DisposableStrategy extends PassportStrategy(Strategy) {
|
||||
constructor() {
|
||||
super({ jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
|
||||
secretOrKey: 'disposable-worker-http-only', ignoreExpiration: false });
|
||||
}
|
||||
validate(payload: any) { return payload; }
|
||||
}
|
||||
const url = process.env.SEO_TEST_DATABASE_URL;
|
||||
if (url && url !== 'postgresql://seo_test@127.0.0.1:55439/postgres') {
|
||||
throw new Error('Only the disposable local PostgreSQL cluster is permitted');
|
||||
}
|
||||
(url ? describe : describe.skip)('Worker -> actual Nest module -> disposable PostgreSQL', () => {
|
||||
it('exercises Python worker over real TCP, shared guards, version fencing and immutable history', async () => {
|
||||
const db = new PrismaClient({ datasources: { db: { url } } });
|
||||
const module = await Test.createTestingModule({
|
||||
imports: [PassportModule, SeoTrackingModule], providers: [DisposableStrategy],
|
||||
}).overrideProvider(PrismaService).useValue(db).compile();
|
||||
const app = module.createNestApplication({ logger: false });
|
||||
app.setGlobalPrefix('api');
|
||||
let blog: any;
|
||||
try {
|
||||
await app.listen(0, '127.0.0.1');
|
||||
blog = await db.blog.create({ data: {
|
||||
title: 'Disposable integration fixture: blackseed article URL',
|
||||
slug: 'dog-black-seed-nigella-sativa', content: 'Local integration fixture, never published',
|
||||
status: 'DRAFT', isPublished: false,
|
||||
canonicalUrl: 'https://canina.ir/blog/dog-black-seed-nigella-sativa',
|
||||
} });
|
||||
const jwt = new JwtService({ secret: 'disposable-worker-http-only' });
|
||||
const worker = resolve(__dirname, '../../../scripts/seo-performance/verify_real_http.py');
|
||||
const output = await new Promise<string>((ok, fail) => {
|
||||
const child = spawn('python3', [worker], { env: {
|
||||
...process.env, SEO_LOCAL_BASE: `http://127.0.0.1:${app.getHttpServer().address().port}`,
|
||||
SEO_FIXTURE_BLOG_ID: blog.id,
|
||||
CANINA_ADMIN_TOKEN: jwt.sign({ role: 'admin', sub: 'disposable-http-fixture' }, { expiresIn: '5m' }),
|
||||
SEO_CUSTOMER_TOKEN: jwt.sign({ role: 'customer' }, { expiresIn: '5m' }),
|
||||
} });
|
||||
let text = '';
|
||||
child.stdout.on('data', (chunk) => { text += chunk; });
|
||||
child.stderr.on('data', (chunk) => { text += chunk; });
|
||||
child.on('error', fail);
|
||||
child.on('close', (code) => code === 0 ? ok(text) : fail(new Error(text)));
|
||||
});
|
||||
console.log(output);
|
||||
expect(output).toContain('REAL_HTTP_ACCEPTANCE_PASSED');
|
||||
} finally {
|
||||
if (blog) {
|
||||
await db.contentResearchFinding.deleteMany({ where: { blogId: blog.id } });
|
||||
await db.blog.delete({ where: { id: blog.id } });
|
||||
}
|
||||
await app.close();
|
||||
await db.$disconnect();
|
||||
}
|
||||
}, 180000);
|
||||
});
|
||||
@@ -0,0 +1,26 @@
|
||||
# SEO tracking worker — local, not deployed
|
||||
|
||||
Run tests: `python3 -m unittest discover -v`
|
||||
|
||||
Read-only actual Google collection:
|
||||
`python3 seo_performance_tracker.py --probe-url https://canina.ir/blog/dog-black-seed-nigella-sativa --state article-probe.sqlite --receipt live-article-receipt.json`
|
||||
|
||||
Read all research findings with strict pagination: `python3 seo_performance_tracker.py --backend https://HOST --state tracker.sqlite --receipt receipt.json`. Supply `CANINA_ADMIN_TOKEN` through the environment, never command arguments/logs. CLI performs no remote mutations. Dependencies: Python 3, requests, google-auth. Credentials stay in their original path.
|
||||
|
||||
`deliver_snapshots(store, backend)` is an explicit opt-in library operation, exercised against both a local HTTP fixture and the actual Nest module over TCP with disposable PostgreSQL (see `VERIFICATION.md`). It posts the sibling v2 ingestion contract (contract.md) and retains immutable payload for retries. Local keys include finding, date period, feedbackVersion. It rereads feedbackVersion before delivery, but this is not an atomic guard; snapshot metadata records the observed revision and snapshots never execute article directives. Actual article creation must atomically claim backend `/action` with expectedVersion and feedbackVersion; this worker does not publish articles. SourceMetadata.worker retains Clarity, query rows, provenance and mandatory directive.
|
||||
|
||||
`deliver_alerts(store, session, endpoint)` is an opt-in structured department receiver adapter. Pending events remain durable in SQLite, deduplicated per source/error/finding/day; successful receiver HTTP acknowledgement marks delivery. Receiver must itself persist and deduplicate idempotencyKey. No actual Telegram/department receiver configured or tested. No background daemon/cron installed. Automatic retry is not scheduled; rerun explicit delivery to retry.
|
||||
|
||||
Measurement: inclusive 14 date labels ending UTC today minus 3 days, GSC final; GA4 timezone metadata retained. For the verified property GA4 returned America/Los_Angeles, aligning GSC date labels, but not proving session-level cross-source attribution. Page metrics queried separately from anonymized/top-row query data; never sum query rows to invent full page metrics. No rows = null/no_data, not zero. Scroll unavailable absent instrumentation. Query response may omit anonymized queries. GA4 thresholding metadata retained; no automated scaling/pruning policy implemented without approved comparative evidence.
|
||||
|
||||
## Verified read-only outcome (2026-10-28)
|
||||
Actual REST requests succeeded using AuthorizedSession. For 2026-10-12 through 2026-10-25, sampled existing article `/blog/dog-black-seed-nigella-sativa`: GSC 5 clicks, 32 impressions, position 3.4375; GA4 2 active users, 33 total engagement seconds, average 16.5 seconds/user, bounce 0.5. GSC query rows empty despite nonzero page metrics (not contradictory; query coverage is limited). Two runs produced one immutable local snapshot and two pending unavailable-source alerts. Receipts contain actual request results, not authenticated-session-construction claims. Discovery fetched a single sample page and is explicitly not a site-wide audit.
|
||||
|
||||
## Blockers / boundaries
|
||||
- Clarity frontend project wiring exists; reporting credentials/access not verified. No Clarity data fabricated.
|
||||
- Repo Order/OrderItem has product linkage but no observed article landing/session/order identity chain; related product sales are correlation, not article/keyword causal attribution. Commerce metrics remain null.
|
||||
- Authenticated list/ingestion now exercised against the actual Nest SEO module and real disposable PostgreSQL with a test-only JWT strategy and the shared guards. This does not verify production identity lookup or API-key authentication. Real department/Telegram receipt remains unverified; production writes forbidden.
|
||||
- Mandatory CEO directives carried with revision; existing article publishers are not integrated by this worker.
|
||||
- Integrated into the authorized develop worktree under `scripts/seo-performance/`. No push/Stage/deploy/cron. See `VERIFICATION.md` for exact local acceptance and limitations.
|
||||
- Historical spec zero defaults/threshold recommendations were unsafe and intentionally not restored. Local snapshot same-key remeasurement is immutable; a new period/revision creates a new record. Correcting an earlier snapshot requires an explicit future revision design.
|
||||
- See `VERIFICATION.md` for source baseline and graph provenance. Original graph is SHA-unbound navigation, not completeness proof.
|
||||
@@ -0,0 +1,28 @@
|
||||
# Worker integration acceptance — 2026-10-28
|
||||
|
||||
Source baseline: develop `df5584d21461f68eb05ffb59ae79ddde4acc622e`, including backend commits 6102556 and 39f5b70. Existing graph-cache timestamp, .specify/ and evidence/ changes were not owned and are excluded. Sibling consumer work was excluded.
|
||||
|
||||
Graph navigation: copied graph.json to `/opt/data/cache/scratch/seo-http-impact`, queried `SeoTrackingController SeoTrackingService authentication snapshots worker`. Original SHA256 6a73473cee9e207543fdeeb668bea544f766200a1b16b8a3a9ce18d4e42e51af; source binding unknown. Graph is navigation only; directly inspected module/controller/service, PrismaService, tests and worker contract at baseline.
|
||||
|
||||
## Executed
|
||||
- Python `python3 -m unittest discover -v`: 17 tests pass, exit 0.
|
||||
- Backend `SEO_TEST_DATABASE_URL=postgresql://seo_test@127.0.0.1:55439/postgres npm test -- --runInBand seo-tracking`: 4 suites, 16 tests pass, exit 0. Receipt in evidence/real-http-receipt.json and focused output in evidence/backend-focused.txt.
|
||||
- `npm run build`: exit 0.
|
||||
- Full backend `npm test -- --runInBand` without integration env: 94 suites pass, 1 fails, 4 skip; 815 tests pass, 1 fails, 8 skip. Failure is existing WikiService pagination assertion, previously reproduced on clean baseline by backend owner; see backend/src/seo-tracking/VERIFICATION.md. Full output in evidence/backend-full.txt. This is NOT full-suite green.
|
||||
- Spec Kit 1.2.3 prerequisite script with explicit feature directory, --require-spec --require-tasks --include-tasks: exit 0. Artifact presence only, not full acceptance.
|
||||
|
||||
New integration test imports the actual SeoTrackingModule, replaces only PrismaService with a real PrismaClient pointed at disposable PostgreSQL, uses a local Passport JWT strategy with actual shared JwtAuthGuard/RolesGuard, and binds loopback ephemeral TCP. Python calls real requests, creates finding, patches feedback (version 1), rejects stale feedback action (409), links correct action (version 2), reads worker findings, makes actual read-only Google requests, persists SQLite state, closes/reopens state, delivers snapshot through real HTTP, GETs database history, retries identical POST (same ID), rejects changed payload (409), and verifies one history row. Missing/invalid JWT and customer role are denied. Fixture blog/finding and cascading snapshots are cleaned up. This is test-auth, NOT production user lookup/Redis/API-key acceptance.
|
||||
|
||||
Actual Google result for existing published blackseed article, 2026-10-12..25: HTTP 200 GSC 5 clicks / 32 impressions / position 3.4375; query rows empty (limited coverage). HTTP 200 GA4 2 active users / 33 engagement seconds / 16.5 seconds per user / bounce 0.5; timezone America/Los_Angeles. Scroll, commerce and Clarity remain null/unavailable. No causal sales or automated scaling claim.
|
||||
|
||||
First integration run failed because pg_ctl defaulted to port 5432, not the allowed 55439. Restarted this known disposable cluster with explicit loopback port 55439 and scratch Unix socket; rerun passed. This was test setup failure, NOT behavioral RED or evidence of a contract bug. No worker/backend contract mismatch was found, so no production implementation fix or claimed new RED/GREEN cycle. New integration assertions are acceptance coverage of existing code.
|
||||
|
||||
## Reproduce
|
||||
Provision a disposable PostgreSQL 16 schema from backend/prisma/schema.prisma (never production) at the exact test URL. Then from backend:
|
||||
|
||||
`SEO_TEST_DATABASE_URL=postgresql://seo_test@127.0.0.1:55439/postgres SEO_HTTP_RECEIPT=/absolute/scratch/receipt.json npm test -- --runInBand seo-tracking.worker-http.spec.ts`
|
||||
|
||||
Requires Python requests/google-auth and existing read-only Google credential path used by worker; never copy credentials into Git. This opt-in test makes Google reads and only local test-database writes. No cron or deployment exists.
|
||||
|
||||
## Still open
|
||||
Actual publisher consumers/finalization enforcement, many-actions/goals/history requirements, production identity/API-key, browser/full frontend matrix, real department alert receipt, Clarity reporting, event instrumentation and causal commerce attribution. Full release acceptance remains open; no push/CI/Stage/deployment/production writes authorized or performed. Broader spec tasks intentionally remain unchecked rather than conflating partial evidence with closure.
|
||||
@@ -0,0 +1,7 @@
|
||||
# SEO tracking contract v2 (local implementation)
|
||||
Base `/api/admin/seo-tracking`, existing JWT or API key authentication mandatory, admin role (API keys require admin scope). No new unauthenticated worker path.
|
||||
GET list page integer 1..100000, limit 1..100, status enum, sortBy createdAt|updatedAt|title|status, sortOrder asc|desc; returns data and standard meta. GET /:uuid returns finding including version, feedbackVersion, blog, snapshots.
|
||||
POST finding: title,hypothesis,targetKeywords[],primaryKeyword,expectedOutcome required; optional blogId UUID, status, goalMetric (metric name), goalTarget nonnegative, actionId external reference. PATCH /:id feedback: {feedback:string, expectedVersion:integer>=0} required; atomic claim advances version and feedbackVersion; stale 409; return updated finding. Clearing feedback uses empty string and advances version.
|
||||
PATCH /:id/action: {expectedVersion, feedbackVersion, blogId?, actionId?, status?}; atomic finding version AND feedbackVersion claim. Feedback present requires acknowledgement of exact feedbackVersion. This protects this endpoint; existing blog publishers are NOT automatically integrated and must consume this contract before claiming enforcement.
|
||||
POST /:id/snapshots: ingestionKey string <=128, periodStart/periodEnd ISO timestamps (start<end), sourceMetadata object with gsc,ga4,commerce each {status: available|unavailable|error, source:string, fetchedAt:ISO timestamp, error?:string}; optional metric fields. Metrics absent/null remain null, actual zero remains zero. All non-available source metrics MUST be null/omitted. Available sources require all their metrics except ga4ScrollDepthRate (optional if uninstrumented). Counts integer >=0, rates [0,1], other metrics >=0 finite. Key unique per finding: identical retry returns existing; changed payload same key returns 409. No revenue inferred from aggregate orders. No recommendations from incomplete data; ingestion accepts optional recommendation only with all sources available.
|
||||
Legacy snapshots with null provenance are unverified historical data, not measured zero. Legacy findings require normalized searchText backfill before normalized search can be complete. No live migration/scheduling/deployment authorized.
|
||||
@@ -0,0 +1,8 @@
|
||||
npm notice run backend@0.0.1 test
|
||||
npm notice run jest --runInBand seo-tracking
|
||||
|
||||
Test Suites: 4 passed, 4 total
|
||||
Tests: 16 passed, 16 total
|
||||
Snapshots: 0 total
|
||||
Time: 10.064 s
|
||||
Ran all test suites matching seo-tracking.
|
||||
@@ -0,0 +1,165 @@
|
||||
npm notice run backend@0.0.1 test
|
||||
npm notice run jest --runInBand
|
||||
FAIL src/wiki/wiki.service.spec.ts
|
||||
● WikiService › findAll › should paginate and filter terms with fallback to default sortBy
|
||||
|
||||
expect(jest.fn()).toHaveBeenCalledWith(...expected)
|
||||
|
||||
- Expected
|
||||
+ Received
|
||||
|
||||
@@ -1,21 +1,39 @@
|
||||
Object {
|
||||
"orderBy": Object {
|
||||
"term": "desc",
|
||||
},
|
||||
- "skip": 0,
|
||||
- "take": 10,
|
||||
+ "skip": undefined,
|
||||
+ "take": 100,
|
||||
"where": Object {
|
||||
"OR": Array [
|
||||
Object {
|
||||
"term": Object {
|
||||
"contains": "مفصل",
|
||||
"mode": "insensitive",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
+ "key": Object {
|
||||
+ "contains": "مفصل",
|
||||
+ "mode": "insensitive",
|
||||
+ },
|
||||
+ },
|
||||
+ Object {
|
||||
"definition": Object {
|
||||
+ "contains": "مفصل",
|
||||
+ "mode": "insensitive",
|
||||
+ },
|
||||
+ },
|
||||
+ Object {
|
||||
+ "term": Object {
|
||||
+ "contains": "مفصل",
|
||||
+ "mode": "insensitive",
|
||||
+ },
|
||||
+ },
|
||||
+ Object {
|
||||
+ "key": Object {
|
||||
"contains": "مفصل",
|
||||
"mode": "insensitive",
|
||||
},
|
||||
},
|
||||
],,
|
||||
|
||||
Number of calls: 1
|
||||
|
||||
56 | });
|
||||
57 |
|
||||
> 58 | expect(mockPrisma.scientificTerm.findMany).toHaveBeenCalledWith({
|
||||
| ^
|
||||
59 | where: {
|
||||
60 | OR: [
|
||||
61 | { term: { contains: "مفصل", mode: "insensitive" } },
|
||||
|
||||
at Object.<anonymous> (wiki/wiki.service.spec.ts:58:50)
|
||||
|
||||
[Nest] 3581768 - 10/28/2026, 7:18:58 AM ERROR [SslService] Failed to parse SSL certificate
|
||||
[Nest] 3581768 - 10/28/2026, 7:18:58 AM ERROR [SslService] Error: error:0480006C:PEM routines::no start line
|
||||
at new X509Certificate (node:internal/crypto/x509:121:21)
|
||||
at SslService.getStatus (/opt/data/content-maintenance/engine/worktree-concurrency-tdd/backend/src/admin/ssl.service.ts:104:20)
|
||||
at Object.<anonymous> (/opt/data/content-maintenance/engine/worktree-concurrency-tdd/backend/src/admin/ssl.service.spec.ts:179:30)
|
||||
at Promise.finally.completed (/opt/data/content-maintenance/engine/worktree-concurrency-tdd/backend/node_modules/jest-circus/build/jestAdapterInit.js:1561:28)
|
||||
at new Promise (<anonymous>)
|
||||
at callAsyncCircusFn (/opt/data/content-maintenance/engine/worktree-concurrency-tdd/backend/node_modules/jest-circus/build/jestAdapterInit.js:1501:10)
|
||||
at _callCircusTest (/opt/data/content-maintenance/engine/worktree-concurrency-tdd/backend/node_modules/jest-circus/build/jestAdapterInit.js:1011:40)
|
||||
at _runTest (/opt/data/content-maintenance/engine/worktree-concurrency-tdd/backend/node_modules/jest-circus/build/jestAdapterInit.js:951:3)
|
||||
at /opt/data/content-maintenance/engine/worktree-concurrency-tdd/backend/node_modules/jest-circus/build/jestAdapterInit.js:853:7
|
||||
at _runTestsForDescribeBlock (/opt/data/content-maintenance/engine/worktree-concurrency-tdd/backend/node_modules/jest-circus/build/jestAdapterInit.js:866:11)
|
||||
at _runTestsForDescribeBlock (/opt/data/content-maintenance/engine/worktree-concurrency-tdd/backend/node_modules/jest-circus/build/jestAdapterInit.js:861:11)
|
||||
at _runTestsForDescribeBlock (/opt/data/content-maintenance/engine/worktree-concurrency-tdd/backend/node_modules/jest-circus/build/jestAdapterInit.js:861:11)
|
||||
at run (/opt/data/content-maintenance/engine/worktree-concurrency-tdd/backend/node_modules/jest-circus/build/jestAdapterInit.js:765:3)
|
||||
at runAndTransformResultsToJestFormat (/opt/data/content-maintenance/engine/worktree-concurrency-tdd/backend/node_modules/jest-circus/build/jestAdapterInit.js:1993:21)
|
||||
at jestAdapter (/opt/data/content-maintenance/engine/worktree-concurrency-tdd/backend/node_modules/jest-circus/build/runner.js:111:19)
|
||||
at runTestInternal (/opt/data/content-maintenance/engine/worktree-concurrency-tdd/backend/node_modules/jest-runner/build/index.js:276:16)
|
||||
at runTest (/opt/data/content-maintenance/engine/worktree-concurrency-tdd/backend/node_modules/jest-runner/build/index.js:344:7) {
|
||||
library: 'PEM routines',
|
||||
reason: 'no start line',
|
||||
code: 'ERR_OSSL_PEM_NO_START_LINE'
|
||||
}
|
||||
[Nest] 3581768 - 10/28/2026, 7:19:05 AM ERROR [ZibalEBankService] [Zibal EBank API] Error requesting /ebank/v1/account/list/: transport failed
|
||||
[Nest] 3581768 - 10/28/2026, 7:19:05 AM ERROR [ZibalEBankService] [Zibal EBank API] Error requesting /ebank/v1/account/list/: transport failed
|
||||
[Nest] 3581768 - 10/28/2026, 7:19:20 AM ERROR [ZibalEBankService] [Zibal EBank API] Error requesting /ebank/v1/account/list/: aborted
|
||||
[Nest] 3581768 - 10/28/2026, 7:19:05 AM ERROR [ZibalEBankService] [Zibal EBank API] Error requesting /ebank/v1/account/list/: Zibal EBank HTTP 503
|
||||
[Nest] 3581768 - 10/28/2026, 7:19:17 AM ERROR [PaymentService] Security Alert: Amount mismatch on trackId=tr-1! Zibal reported 1000000 Rials, but expected 5000000 Rials in DB.
|
||||
[Nest] 3581768 - 10/28/2026, 7:19:27 AM WARN [BlogsService] Cache revalidation failed for updated blog [post]: cache down
|
||||
|
||||
Summary of all failing tests
|
||||
FAIL wiki/wiki.service.spec.ts
|
||||
● WikiService › findAll › should paginate and filter terms with fallback to default sortBy
|
||||
|
||||
expect(jest.fn()).toHaveBeenCalledWith(...expected)
|
||||
|
||||
- Expected
|
||||
+ Received
|
||||
|
||||
@@ -1,21 +1,39 @@
|
||||
Object {
|
||||
"orderBy": Object {
|
||||
"term": "desc",
|
||||
},
|
||||
- "skip": 0,
|
||||
- "take": 10,
|
||||
+ "skip": undefined,
|
||||
+ "take": 100,
|
||||
"where": Object {
|
||||
"OR": Array [
|
||||
Object {
|
||||
"term": Object {
|
||||
"contains": "مفصل",
|
||||
"mode": "insensitive",
|
||||
},
|
||||
},
|
||||
Object {
|
||||
+ "key": Object {
|
||||
+ "contains": "مفصل",
|
||||
+ "mode": "insensitive",
|
||||
+ },
|
||||
+ },
|
||||
+ Object {
|
||||
"definition": Object {
|
||||
+ "contains": "مفصل",
|
||||
+ "mode": "insensitive",
|
||||
+ },
|
||||
+ },
|
||||
+ Object {
|
||||
+ "term": Object {
|
||||
+ "contains": "مفصل",
|
||||
+ "mode": "insensitive",
|
||||
+ },
|
||||
+ },
|
||||
+ Object {
|
||||
+ "key": Object {
|
||||
"contains": "مفصل",
|
||||
"mode": "insensitive",
|
||||
},
|
||||
},
|
||||
],,
|
||||
|
||||
Number of calls: 1
|
||||
|
||||
56 | });
|
||||
57 |
|
||||
> 58 | expect(mockPrisma.scientificTerm.findMany).toHaveBeenCalledWith({
|
||||
| ^
|
||||
59 | where: {
|
||||
60 | OR: [
|
||||
61 | { term: { contains: "مفصل", mode: "insensitive" } },
|
||||
|
||||
at Object.<anonymous> (wiki/wiki.service.spec.ts:58:50)
|
||||
|
||||
|
||||
Test Suites: 1 failed, 4 skipped, 94 passed, 95 of 99 total
|
||||
Tests: 1 failed, 8 skipped, 815 passed, 824 total
|
||||
Snapshots: 0 total
|
||||
Time: 44.533 s, estimated 47 s
|
||||
Ran all test suites.
|
||||
@@ -0,0 +1,254 @@
|
||||
{
|
||||
"observedAt": "2026-10-28T07:18:43.957972+00:00",
|
||||
"backend": "disposable local Nest module + real PostgreSQL",
|
||||
"auth": "test-only JWT strategy with real JwtAuthGuard/RolesGuard; NOT production identity/API-key",
|
||||
"checks": {
|
||||
"missing_invalid_nonadmin_denied": true,
|
||||
"feedback_stale_action_and_correct_link": true,
|
||||
"worker_snapshot_history_network_retry_conflict": true
|
||||
},
|
||||
"google": {
|
||||
"findingId": "c89ce29f-e9f7-40ab-a7bb-03a2286219aa",
|
||||
"articleUrl": "https://canina.ir/blog/dog-black-seed-nigella-sativa",
|
||||
"periodStart": "2026-10-12",
|
||||
"periodEnd": "2026-10-25",
|
||||
"feedbackRevision": 1,
|
||||
"sources": {
|
||||
"gsc": {
|
||||
"status": "available",
|
||||
"metrics": {
|
||||
"clicks": 5,
|
||||
"impressions": 32,
|
||||
"position": 3.4375
|
||||
},
|
||||
"rows": [
|
||||
{
|
||||
"keys": [
|
||||
"https://canina.ir/blog/dog-black-seed-nigella-sativa"
|
||||
],
|
||||
"clicks": 5,
|
||||
"impressions": 32,
|
||||
"ctr": 0.15625,
|
||||
"position": 3.4375
|
||||
}
|
||||
],
|
||||
"periodStart": "2026-10-12",
|
||||
"periodEnd": "2026-10-25",
|
||||
"observedAt": "2026-10-28T07:18:42.716059+00:00",
|
||||
"metadata": {},
|
||||
"coverage": "GSC top rows; anonymized queries omitted",
|
||||
"source": "GSC",
|
||||
"httpStatus": 200
|
||||
},
|
||||
"gscQueries": {
|
||||
"status": "no_data",
|
||||
"metrics": null,
|
||||
"rows": [],
|
||||
"periodStart": "2026-10-12",
|
||||
"periodEnd": "2026-10-25",
|
||||
"observedAt": "2026-10-28T07:18:42.979366+00:00",
|
||||
"metadata": {},
|
||||
"coverage": "GSC top rows; anonymized queries omitted",
|
||||
"source": "GSC",
|
||||
"httpStatus": 200
|
||||
},
|
||||
"ga4": {
|
||||
"status": "available",
|
||||
"metrics": {
|
||||
"activeUsers": 2,
|
||||
"userEngagementDuration": 33.0,
|
||||
"avgEngagementSec": 16.5,
|
||||
"bounceRate": 0.5,
|
||||
"scrollDepthRate": null
|
||||
},
|
||||
"rows": [
|
||||
{
|
||||
"dimensionValues": [
|
||||
{
|
||||
"value": "https://canina.ir/blog/dog-black-seed-nigella-sativa"
|
||||
}
|
||||
],
|
||||
"metricValues": [
|
||||
{
|
||||
"value": "2"
|
||||
},
|
||||
{
|
||||
"value": "33"
|
||||
},
|
||||
{
|
||||
"value": "0.5"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"periodStart": "2026-10-12",
|
||||
"periodEnd": "2026-10-25",
|
||||
"observedAt": "2026-10-28T07:18:43.791790+00:00",
|
||||
"metadata": {
|
||||
"currencyCode": "USD",
|
||||
"timeZone": "America/Los_Angeles"
|
||||
},
|
||||
"coverage": "GA4 reporting rows; inspect metadata for thresholding",
|
||||
"source": "GA4",
|
||||
"httpStatus": 200
|
||||
},
|
||||
"clarity": {
|
||||
"status": "unavailable",
|
||||
"metrics": null,
|
||||
"error": "reporting_credentials_not_configured",
|
||||
"observedAt": "2026-10-28T07:18:43.791896+00:00"
|
||||
},
|
||||
"commerce": {
|
||||
"status": "unavailable",
|
||||
"metrics": null,
|
||||
"error": "article_to_order_linkage_not_verified",
|
||||
"observedAt": "2026-10-28T07:18:43.791906+00:00"
|
||||
}
|
||||
},
|
||||
"decision": {
|
||||
"action": "INSUFFICIENT_EVIDENCE",
|
||||
"reason": "No approved comparative decision policy; unavailable signals cannot justify scaling or pruning. Correlation is not keyword-caused sales.",
|
||||
"mandatoryDirective": "Measure only; do not publish",
|
||||
"feedbackRevision": 1
|
||||
},
|
||||
"observedAt": "2026-10-28T07:18:43.791921+00:00",
|
||||
"periodAlignment": "same date labels; GSC Pacific and GA4 property timezone may differ; not session-level alignment"
|
||||
},
|
||||
"persistedSnapshot": {
|
||||
"id": "26dac670-0b45-4450-bbec-638446732554",
|
||||
"findingId": "c89ce29f-e9f7-40ab-a7bb-03a2286219aa",
|
||||
"snapshotDate": "2026-10-28T07:18:43.874Z",
|
||||
"periodStart": "2026-10-12T00:00:00.000Z",
|
||||
"periodEnd": "2026-10-26T00:00:00.000Z",
|
||||
"sourceMetadata": {
|
||||
"ga4": {
|
||||
"source": "ga4",
|
||||
"status": "available",
|
||||
"fetchedAt": "2026-10-28T07:18:43.791790+00:00"
|
||||
},
|
||||
"gsc": {
|
||||
"source": "gsc",
|
||||
"status": "available",
|
||||
"fetchedAt": "2026-10-28T07:18:42.716059+00:00"
|
||||
},
|
||||
"worker": {
|
||||
"sources": {
|
||||
"ga4": {
|
||||
"rows": [
|
||||
{
|
||||
"metricValues": [
|
||||
{
|
||||
"value": "2"
|
||||
},
|
||||
{
|
||||
"value": "33"
|
||||
},
|
||||
{
|
||||
"value": "0.5"
|
||||
}
|
||||
],
|
||||
"dimensionValues": [
|
||||
{
|
||||
"value": "https://canina.ir/blog/dog-black-seed-nigella-sativa"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": "GA4",
|
||||
"status": "available",
|
||||
"metrics": {
|
||||
"bounceRate": 0.5,
|
||||
"activeUsers": 2,
|
||||
"scrollDepthRate": null,
|
||||
"avgEngagementSec": 16.5,
|
||||
"userEngagementDuration": 33
|
||||
},
|
||||
"coverage": "GA4 reporting rows; inspect metadata for thresholding",
|
||||
"metadata": {
|
||||
"timeZone": "America/Los_Angeles",
|
||||
"currencyCode": "USD"
|
||||
},
|
||||
"periodEnd": "2026-10-25",
|
||||
"httpStatus": 200,
|
||||
"observedAt": "2026-10-28T07:18:43.791790+00:00",
|
||||
"periodStart": "2026-10-12"
|
||||
},
|
||||
"gsc": {
|
||||
"rows": [
|
||||
{
|
||||
"ctr": 0.15625,
|
||||
"keys": [
|
||||
"https://canina.ir/blog/dog-black-seed-nigella-sativa"
|
||||
],
|
||||
"clicks": 5,
|
||||
"position": 3.4375,
|
||||
"impressions": 32
|
||||
}
|
||||
],
|
||||
"source": "GSC",
|
||||
"status": "available",
|
||||
"metrics": {
|
||||
"clicks": 5,
|
||||
"position": 3.4375,
|
||||
"impressions": 32
|
||||
},
|
||||
"coverage": "GSC top rows; anonymized queries omitted",
|
||||
"metadata": {},
|
||||
"periodEnd": "2026-10-25",
|
||||
"httpStatus": 200,
|
||||
"observedAt": "2026-10-28T07:18:42.716059+00:00",
|
||||
"periodStart": "2026-10-12"
|
||||
},
|
||||
"clarity": {
|
||||
"error": "reporting_credentials_not_configured",
|
||||
"status": "unavailable",
|
||||
"metrics": null,
|
||||
"observedAt": "2026-10-28T07:18:43.791896+00:00"
|
||||
},
|
||||
"commerce": {
|
||||
"error": "article_to_order_linkage_not_verified",
|
||||
"status": "unavailable",
|
||||
"metrics": null,
|
||||
"observedAt": "2026-10-28T07:18:43.791906+00:00"
|
||||
},
|
||||
"gscQueries": {
|
||||
"rows": [],
|
||||
"source": "GSC",
|
||||
"status": "no_data",
|
||||
"metrics": null,
|
||||
"coverage": "GSC top rows; anonymized queries omitted",
|
||||
"metadata": {},
|
||||
"periodEnd": "2026-10-25",
|
||||
"httpStatus": 200,
|
||||
"observedAt": "2026-10-28T07:18:42.979366+00:00",
|
||||
"periodStart": "2026-10-12"
|
||||
}
|
||||
},
|
||||
"feedbackVersion": 1,
|
||||
"periodAlignment": "same date labels; GSC Pacific and GA4 property timezone may differ; not session-level alignment",
|
||||
"mandatoryDirective": "Measure only; do not publish"
|
||||
},
|
||||
"commerce": {
|
||||
"error": "article_to_order_linkage_not_verified",
|
||||
"source": "commerce",
|
||||
"status": "unavailable",
|
||||
"fetchedAt": "2026-10-28T07:18:43.791906+00:00"
|
||||
}
|
||||
},
|
||||
"ingestionKey": "bb6b6afac66b9fc1664dd7c8e9143e80d1d2d04b4cb064aeed7068648f03e625",
|
||||
"gscImpressions": 32,
|
||||
"gscClicks": 5,
|
||||
"gscPosition": 3.4375,
|
||||
"ga4ActiveUsers": 2,
|
||||
"ga4AvgEngagementSec": 16.5,
|
||||
"ga4BounceRate": 0.5,
|
||||
"ga4ScrollDepthRate": null,
|
||||
"attributedOrdersCount": null,
|
||||
"attributedSalesValue": null,
|
||||
"actionRecommendation": null,
|
||||
"analysisNotes": null,
|
||||
"createdAt": "2026-10-28T07:18:43.874Z"
|
||||
},
|
||||
"productionWrites": false,
|
||||
"scheduled": false
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
# Worker scope and acceptance
|
||||
Bound to baseline specs/002-seo-performance-tracking; this local directory is not a Git worktree, so artifacts are local only, not committed/deployed. No backend/UI edits, cron or production writes authorized.
|
||||
Replace fabricated zeros with explicit unavailable/no_data and null. Collect all findings by pagination, exact canonical URL Google matching, same inclusive date period ending UTC today minus three days (GSC final data; GA4 property timezone retained separately). Google successful API response, not session construction, proves access. GSC top-row reporting is not exhaustive keyword coverage. No causal commerce attribution without source linkage. Store snapshots/outbox durably and deduplicate period+revision; feedback revision binds mandatory directive and backend must reject stale revisions. No invented optimization thresholds: insufficient evidence until approved policy and comparison data exist.
|
||||
Plan: injectable REST collectors; local SQLite snapshot/outbox; backend adapter with strict pagination; explicit opt-in delivery, local read-only probe mode. Failure errors sanitized to class/status only. Tests precede implementation (9 RED failures observed). Test doubles are confined to tests.
|
||||
Tasks: implement collectors/store/orchestrator; test authentication/429/timeouts/partial pages and reruns; live read-only Google probe; backend integration contract pending sibling; document blockers and acceptance evidence. No automatic deployment.
|
||||
@@ -0,0 +1,190 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only collection by default. Local durable snapshots; delivery is explicit."""
|
||||
import argparse
|
||||
import datetime as dt
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sqlite3
|
||||
from urllib.parse import quote, urlsplit
|
||||
import requests
|
||||
|
||||
GSC_CREDS_PATH='/opt/data/credentials/gsc-service-account.json'
|
||||
GA4_PROPERTY_ID='552453291'
|
||||
GSC_SITE='sc-domain:canina.ir'
|
||||
|
||||
def now(): return dt.datetime.now(dt.timezone.utc).isoformat()
|
||||
def period(today=None,days=14):
|
||||
if days<1: raise ValueError('days must be positive')
|
||||
end=(today or dt.datetime.now(dt.timezone.utc).date())-dt.timedelta(days=3)
|
||||
return str(end-dt.timedelta(days=days-1)),str(end)
|
||||
def digest(value): return hashlib.sha256(json.dumps(value,sort_keys=True,ensure_ascii=False).encode()).hexdigest()
|
||||
def get_google_session():
|
||||
from google.oauth2 import service_account
|
||||
from google.auth.transport.requests import AuthorizedSession
|
||||
return AuthorizedSession(service_account.Credentials.from_service_account_file(GSC_CREDS_PATH,scopes=['https://www.googleapis.com/auth/webmasters.readonly','https://www.googleapis.com/auth/analytics.readonly']))
|
||||
def unavailable(reason): return {'status':'unavailable','metrics':None,'error':reason,'observedAt':now()}
|
||||
|
||||
class GoogleCollector:
|
||||
def __init__(self,session,page_size=25000): self.session,self.page_size=session,page_size
|
||||
def collect(self,source,url,body,dates):
|
||||
rows=[]; offset=0; metadata={}; seen=set()
|
||||
try:
|
||||
while True:
|
||||
payload=dict(body)
|
||||
if source=='GSC': payload.update(rowLimit=self.page_size,startRow=offset)
|
||||
else: payload.update(limit=str(self.page_size),offset=str(offset))
|
||||
response=self.session.post(url,json=payload,timeout=30)
|
||||
if response.status_code!=200: return unavailable(f'http_{response.status_code}')
|
||||
data=response.json(); batch=data.get('rows',[])
|
||||
if not isinstance(batch,list): raise ValueError('invalid rows')
|
||||
metadata.update(data.get('metadata',{}))
|
||||
if batch:
|
||||
signature=digest(batch)
|
||||
if signature in seen: raise ValueError('repeated pagination')
|
||||
seen.add(signature)
|
||||
rows.extend(batch); offset+=len(batch)
|
||||
if source=='GA4':
|
||||
if offset>=int(data.get('rowCount',offset)): break
|
||||
if not batch: raise ValueError('incomplete pagination')
|
||||
elif len(batch)<self.page_size: break
|
||||
return {'status':'available' if rows else 'no_data','metrics':None,'rows':rows,'periodStart':dates[0],'periodEnd':dates[1],'observedAt':now(),'metadata':metadata,'coverage':'GSC top rows; anonymized queries omitted' if source=='GSC' else 'GA4 reporting rows; inspect metadata for thresholding','source':source,'httpStatus':200}
|
||||
except Exception as exc:
|
||||
return unavailable(type(exc).__name__)
|
||||
def gsc(self,url,dates):
|
||||
result = self.collect('GSC',f'https://www.googleapis.com/webmasters/v3/sites/{quote(GSC_SITE,safe="")}/searchAnalytics/query',{'startDate':dates[0],'endDate':dates[1],'dataState':'final','dimensions':['query'],'dimensionFilterGroups':[{'filters':[{'dimension':'page','operator':'equals','expression':url}]}]},dates)
|
||||
return result
|
||||
def gsc_page(self,url,dates):
|
||||
result=self.collect('GSC',f'https://www.googleapis.com/webmasters/v3/sites/{quote(GSC_SITE,safe="")}/searchAnalytics/query',{'startDate':dates[0],'endDate':dates[1],'dataState':'final','dimensions':['page'],'dimensionFilterGroups':[{'filters':[{'dimension':'page','operator':'equals','expression':url}]}]},dates)
|
||||
if result['status']=='available':
|
||||
try:
|
||||
row=result['rows'][0]
|
||||
if len(result['rows'])!=1 or row['keys']!=[url]: raise ValueError('exact URL mismatch')
|
||||
result['metrics']={k:row[k] for k in ('clicks','impressions','position')}
|
||||
except Exception as exc: return unavailable(type(exc).__name__)
|
||||
return result
|
||||
def ga4(self,url,dates):
|
||||
result=self.collect('GA4',f'https://analyticsdata.googleapis.com/v1beta/properties/{GA4_PROPERTY_ID}:runReport',{'dateRanges':[{'startDate':dates[0],'endDate':dates[1]}],'dimensions':[{'name':'pageLocation'}],'metrics':[{'name':'activeUsers'},{'name':'userEngagementDuration'},{'name':'bounceRate'}],'dimensionFilter':{'filter':{'fieldName':'pageLocation','stringFilter':{'matchType':'EXACT','value':url,'caseSensitive':True}}}},dates)
|
||||
if result['status']=='available':
|
||||
try:
|
||||
rows=result['rows']
|
||||
if len(rows)!=1 or rows[0]['dimensionValues'][0]['value']!=url: raise ValueError('exact URL mismatch')
|
||||
vals=rows[0]['metricValues']; users=int(vals[0]['value']); duration=float(vals[1]['value'])
|
||||
result['metrics']={'activeUsers':users,'userEngagementDuration':duration,'avgEngagementSec':duration/users if users else None,'bounceRate':float(vals[2]['value']),'scrollDepthRate':None}
|
||||
except Exception as exc: return unavailable(type(exc).__name__)
|
||||
return result
|
||||
|
||||
class Store:
|
||||
def __init__(self,path):
|
||||
self.db=sqlite3.connect(path)
|
||||
self.db.execute('CREATE TABLE IF NOT EXISTS snapshots (key TEXT PRIMARY KEY, payload TEXT NOT NULL, delivered INTEGER DEFAULT 0)')
|
||||
self.db.execute('CREATE TABLE IF NOT EXISTS outbox (key TEXT PRIMARY KEY,payload TEXT NOT NULL, delivered INTEGER DEFAULT 0)')
|
||||
def snapshot(self,payload):
|
||||
key=digest([payload.get(k) for k in ('findingId','periodStart','periodEnd','feedbackRevision')]); payload=dict(payload,idempotencyKey=key)
|
||||
with self.db:
|
||||
cur=self.db.execute('INSERT OR IGNORE INTO snapshots(key,payload) VALUES (?,?)',(key,json.dumps(payload,ensure_ascii=False)))
|
||||
return bool(cur.rowcount)
|
||||
def alert(self,source,error,finding):
|
||||
payload={'source':source,'error':error,'findingId':finding,'department':'TECHNICAL_SEO' if source=='GSC' else 'ENGINEERING','observedAt':now(),'status':'pending'}
|
||||
key=digest([source,error,finding,dt.datetime.now(dt.timezone.utc).date().isoformat()])
|
||||
with self.db: self.db.execute('INSERT OR IGNORE INTO outbox(key,payload) VALUES (?,?)',(key,json.dumps(payload)))
|
||||
def pending(self): return self.db.execute('SELECT key,payload FROM outbox WHERE delivered=0').fetchall()
|
||||
|
||||
class Backend:
|
||||
def __init__(self,base,session): self.base,self.session=base.rstrip('/')+'/api/admin/seo-tracking',session
|
||||
def findings(self):
|
||||
page=1; found={}; total=None
|
||||
while True:
|
||||
r=self.session.get(self.base,params={'page':page,'limit':100},timeout=30)
|
||||
if r.status_code!=200: raise RuntimeError(f'backend_http_{r.status_code}')
|
||||
data=r.json(); meta=data['meta']; batch=data['data']
|
||||
if int(meta['page'])!=page: raise ValueError('pagination mismatch')
|
||||
if total is None: total=int(meta['total'])
|
||||
if int(meta['total'])!=total: raise ValueError('findings changed during pagination')
|
||||
for item in batch:
|
||||
if item['id'] in found: raise ValueError('duplicate finding')
|
||||
found[item['id']]=item
|
||||
if page>=int(meta['totalPages']): break
|
||||
if not batch: raise ValueError('incomplete pagination')
|
||||
page+=1
|
||||
if len(found)!=total: raise ValueError('finding count mismatch')
|
||||
return list(found.values())
|
||||
|
||||
def decision(finding,sources):
|
||||
return {'action':'INSUFFICIENT_EVIDENCE','reason':'No approved comparative decision policy; unavailable signals cannot justify scaling or pruning. Correlation is not keyword-caused sales.','mandatoryDirective':finding.get('ceoFeedback'),'feedbackRevision':finding.get('feedbackVersion',finding.get('feedbackRevision',finding.get('feedbackSubmittedAt')))}
|
||||
|
||||
def collect_finding(finding,collector,dates,store):
|
||||
blog=finding.get('blog') or {}; url=finding.get('articleUrl') or blog.get('canonicalUrl')
|
||||
if not url and blog.get('slug'): url='https://canina.ir/blog/'+quote(blog['slug'],safe='')
|
||||
if not url or urlsplit(url).hostname!='canina.ir' or urlsplit(url).scheme!='https':
|
||||
store.alert('BACKEND','missing_or_invalid_article_url',finding['id']); return None
|
||||
sources={'gsc':collector.gsc_page(url,dates),'gscQueries':collector.gsc(url,dates),'ga4':collector.ga4(url,dates),'clarity':unavailable('reporting_credentials_not_configured'),'commerce':unavailable('article_to_order_linkage_not_verified')}
|
||||
payload={'findingId':finding['id'],'articleUrl':url,'periodStart':dates[0],'periodEnd':dates[1],'feedbackRevision':finding.get('feedbackVersion',finding.get('feedbackRevision',finding.get('feedbackSubmittedAt'))),'sources':sources,'decision':decision(finding,sources),'observedAt':now(),'periodAlignment':'same date labels; GSC Pacific and GA4 property timezone may differ; not session-level alignment'}
|
||||
for source,data in sources.items():
|
||||
if data['status']=='unavailable': store.alert(source.upper(),data['error'],finding['id'])
|
||||
store.snapshot(payload); return payload
|
||||
|
||||
def snapshot_body(payload,key):
|
||||
sources=payload['sources']; metadata={}; body={'ingestionKey':key,'periodStart':payload['periodStart']+'T00:00:00.000Z','periodEnd':str(dt.date.fromisoformat(payload['periodEnd'])+dt.timedelta(days=1))+'T00:00:00.000Z'}
|
||||
mappings={'gsc':{'clicks':'gscClicks','impressions':'gscImpressions','position':'gscPosition'},'ga4':{'activeUsers':'ga4ActiveUsers','avgEngagementSec':'ga4AvgEngagementSec','bounceRate':'ga4BounceRate'},'commerce':{'orders':'attributedOrdersCount','revenue':'attributedSalesValue'}}
|
||||
for source,mapping in mappings.items():
|
||||
data=sources.get(source) or unavailable('missing_source'); metrics=data.get('metrics')
|
||||
available=data['status']=='available' and metrics is not None and all(metrics.get(k) is not None for k in mapping)
|
||||
metadata[source]={'status':'available' if available else 'unavailable','source':source,'fetchedAt':data.get('observedAt',now())}
|
||||
if available:
|
||||
for k,v in mapping.items(): body[v]=metrics[k]
|
||||
else: metadata[source]['error']=data.get('error','no_reported_metrics')
|
||||
metadata['worker']={'feedbackVersion':payload.get('feedbackRevision'),'mandatoryDirective':payload.get('decision',{}).get('mandatoryDirective'),'periodAlignment':payload.get('periodAlignment'),'sources':sources}
|
||||
body['sourceMetadata']=metadata
|
||||
return body
|
||||
|
||||
def deliver_snapshots(store,backend):
|
||||
"""Explicit mutation function, never invoked in read-only CLI. Backend dedupes ingestionKey."""
|
||||
count=0
|
||||
for key,raw in store.db.execute('SELECT key,payload FROM snapshots WHERE delivered=0').fetchall():
|
||||
payload=json.loads(raw)
|
||||
try:
|
||||
response=backend.session.get(backend.base+'/'+payload['findingId'],timeout=30)
|
||||
if response.status_code!=200: raise RuntimeError('detail_unavailable')
|
||||
if response.json().get('feedbackVersion')!=payload['feedbackRevision']:
|
||||
store.alert('BACKEND','stale_feedback',payload['findingId']); continue
|
||||
# Measurement snapshots do not apply directives or advance article status.
|
||||
response=backend.session.post(backend.base+'/'+payload['findingId']+'/snapshots',json=snapshot_body(payload,key),timeout=30)
|
||||
if response.status_code not in (200,201): raise RuntimeError(f'http_{response.status_code}')
|
||||
with store.db: store.db.execute('UPDATE snapshots SET delivered=1 WHERE key=?',(key,))
|
||||
count+=1
|
||||
except Exception as exc: store.alert('BACKEND',type(exc).__name__,payload['findingId'])
|
||||
return count
|
||||
|
||||
def deliver_alerts(store,session,endpoint):
|
||||
"""Send structured department events to configured receiver; require durable receiver ack."""
|
||||
count=0
|
||||
for key,raw in store.pending():
|
||||
try:
|
||||
response=session.post(endpoint,json=dict(json.loads(raw),idempotencyKey=key),timeout=30)
|
||||
if response.status_code not in (200,201,202): continue
|
||||
with store.db: store.db.execute('UPDATE outbox SET delivered=1 WHERE key=?',(key,))
|
||||
count+=1
|
||||
except Exception: pass # event remains pending; no secret-bearing exception logging
|
||||
return count
|
||||
|
||||
def main():
|
||||
p=argparse.ArgumentParser(); p.add_argument('--backend'); p.add_argument('--probe-url'); p.add_argument('--days',type=int,default=14); p.add_argument('--state',default='tracker.sqlite'); p.add_argument('--receipt',default='receipt.json'); args=p.parse_args()
|
||||
store=Store(args.state); dates=period(days=args.days); results=[]
|
||||
try: collector=GoogleCollector(get_google_session())
|
||||
except Exception as exc:
|
||||
store.alert('GOOGLE',type(exc).__name__,'global'); Path(args.receipt).write_text(json.dumps({'status':'blocked','error':type(exc).__name__,'observedAt':now()})); return 1
|
||||
if args.probe_url: findings=[{'id':'read-only-probe','articleUrl':args.probe_url}]
|
||||
elif args.backend:
|
||||
session=requests.Session(); token=os.getenv('CANINA_ADMIN_TOKEN')
|
||||
if token: session.headers['Authorization']='Bearer '+token
|
||||
try: findings=Backend(args.backend,session).findings()
|
||||
except Exception as exc:
|
||||
store.alert('BACKEND',type(exc).__name__,'global'); Path(args.receipt).write_text(json.dumps({'status':'blocked','error':type(exc).__name__,'observedAt':now()})); return 1
|
||||
else: p.error('--backend or --probe-url required')
|
||||
for finding in findings:
|
||||
if finding.get('blog') or finding.get('articleUrl'): results.append(collect_finding(finding,collector,dates,store))
|
||||
Path(args.receipt).write_text(json.dumps({'observedAt':now(),'period':dates,'findingCount':len(findings),'collectedCount':sum(x is not None for x in results),'results':results,'remoteWrites':False},ensure_ascii=False,indent=2))
|
||||
return 0
|
||||
if __name__=='__main__': raise SystemExit(main())
|
||||
@@ -0,0 +1,21 @@
|
||||
import unittest, tempfile, json
|
||||
from pathlib import Path
|
||||
from unittest.mock import Mock
|
||||
import seo_performance_tracker as w
|
||||
|
||||
class DeliveryTests(unittest.TestCase):
|
||||
def test_retry_and_ack(self):
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
st=w.Store(Path(d)/'s.db');st.alert('GSC','http_403','f'); session=Mock(); session.post.return_value.status_code=429
|
||||
self.assertEqual(w.deliver_alerts(st,session,'http://localhost/alerts'),0);self.assertEqual(len(st.pending()),1)
|
||||
session.post.return_value.status_code=202
|
||||
self.assertEqual(w.deliver_alerts(st,session,'http://localhost/alerts'),1);self.assertEqual(w.deliver_alerts(st,session,'http://localhost/alerts'),0)
|
||||
def test_contract_null(self):
|
||||
p={'findingId':'f','periodStart':'2026-10-01','periodEnd':'2026-10-14','feedbackRevision':2,'sources':{'gsc':w.unavailable('http_403'),'ga4':w.unavailable('Timeout'),'commerce':w.unavailable('missing')}}
|
||||
x=w.snapshot_body(p,'key'); self.assertEqual(x['ingestionKey'],'key');self.assertNotIn('gscClicks',x);self.assertEqual(x['sourceMetadata']['gsc']['status'],'unavailable');self.assertNotIn('actionRecommendation',x)
|
||||
def test_stale_feedback_blocks_delivery(self):
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
st=w.Store(Path(d)/'s.db');st.snapshot({'findingId':'f','periodStart':'2026-10-01','periodEnd':'2026-10-14','feedbackRevision':2,'sources':{}})
|
||||
s=Mock();s.get.return_value.status_code=200;s.get.return_value.json.return_value={'feedbackVersion':3}
|
||||
self.assertEqual(w.deliver_snapshots(st,w.Backend('http://localhost',s)),0);s.post.assert_not_called();self.assertEqual(len(st.pending()),1)
|
||||
if __name__=='__main__':unittest.main()
|
||||
@@ -0,0 +1,27 @@
|
||||
"""Local HTTP integration; synthetic fixture responses exist only in this test."""
|
||||
import unittest,threading,json,tempfile
|
||||
from http.server import BaseHTTPRequestHandler,ThreadingHTTPServer
|
||||
from pathlib import Path
|
||||
import requests
|
||||
import seo_performance_tracker as w
|
||||
class Integration(unittest.TestCase):
|
||||
def test_http_pagination_collection_and_delivery(self):
|
||||
calls=[]
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
def log_message(self,*a): pass
|
||||
def do_GET(self):
|
||||
if '?' in self.path:
|
||||
p=1 if 'page=1&' in self.path else 2
|
||||
data={'data':[{'id':str(p)}],'meta':{'page':p,'total':2,'totalPages':2}}
|
||||
else:data={'feedbackVersion':1}
|
||||
self.send_response(200);self.end_headers();self.wfile.write(json.dumps(data).encode())
|
||||
def do_POST(self):
|
||||
calls.append(json.loads(self.rfile.read(int(self.headers['Content-Length']))));self.send_response(201);self.end_headers();self.wfile.write(b'{}')
|
||||
server=ThreadingHTTPServer(('127.0.0.1',0),Handler);thread=threading.Thread(target=server.serve_forever,daemon=True);thread.start()
|
||||
try:
|
||||
backend=w.Backend('http://127.0.0.1:'+str(server.server_port),requests.Session());self.assertEqual(len(backend.findings()),2)
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
store=w.Store(Path(d)/'s');store.snapshot({'findingId':'1','periodStart':'2026-10-01','periodEnd':'2026-10-14','feedbackRevision':1,'sources':{}})
|
||||
self.assertEqual(w.deliver_snapshots(store,backend),1);self.assertEqual(w.deliver_snapshots(store,backend),0)
|
||||
self.assertEqual(calls[0]['sourceMetadata']['commerce']['status'],'unavailable');store.db.close()
|
||||
finally:server.shutdown();server.server_close();thread.join()
|
||||
@@ -0,0 +1,9 @@
|
||||
"""Regression: arbitrary legacy thresholds must not drive editorial changes."""
|
||||
import unittest
|
||||
from seo_performance_tracker import decision
|
||||
class TestConservativeDecisions(unittest.TestCase):
|
||||
def test_aggregate_sales_do_not_prove_keyword_causality(self):
|
||||
self.assertEqual(decision({}, {'orders': 99, 'clicks': 1000})['action'],'INSUFFICIENT_EVIDENCE')
|
||||
def test_directive_is_carried_without_inventing_action(self):
|
||||
r=decision({'ceoFeedback':'Revise citations','feedbackVersion':4},{})
|
||||
self.assertEqual(r['mandatoryDirective'],'Revise citations');self.assertEqual(r['feedbackRevision'],4)
|
||||
@@ -0,0 +1,55 @@
|
||||
import unittest, tempfile, datetime, json
|
||||
from pathlib import Path
|
||||
from unittest.mock import Mock
|
||||
import requests
|
||||
import seo_performance_tracker as w
|
||||
|
||||
class WorkerTests(unittest.TestCase):
|
||||
def test_period(self):
|
||||
self.assertEqual(w.period(datetime.date(2026,10,28),14),('2026-10-12','2026-10-25'))
|
||||
def test_unavailable_is_null(self):
|
||||
for status in (401,403,429,500):
|
||||
s=Mock(); s.post.return_value.status_code=status
|
||||
result=w.GoogleCollector(s).gsc('https://canina.ir/blog/a',('2026-10-01','2026-10-14'))
|
||||
self.assertEqual(result['status'],'unavailable'); self.assertIsNone(result['metrics']); self.assertEqual(result['error'],f'http_{status}')
|
||||
def test_timeout(self):
|
||||
s=Mock(); s.post.side_effect=requests.Timeout('secret response')
|
||||
self.assertEqual(w.GoogleCollector(s).ga4('https://canina.ir/blog/a',('2026-10-01','2026-10-14'))['error'],'Timeout')
|
||||
def test_exact_ga4(self):
|
||||
s=Mock(); s.post.return_value.status_code=200; s.post.return_value.json.return_value={'rows':[],'rowCount':0}
|
||||
r=w.GoogleCollector(s).ga4('https://canina.ir/blog/a',('2026-10-01','2026-10-14'))
|
||||
f=s.post.call_args.kwargs['json']['dimensionFilter']['filter']
|
||||
self.assertEqual(f['fieldName'],'pageLocation'); self.assertEqual(f['stringFilter']['matchType'],'EXACT'); self.assertEqual(r['status'],'no_data'); self.assertIsNone(r['metrics'])
|
||||
def test_gsc_pagination(self):
|
||||
s=Mock(); a=Mock(status_code=200); b=Mock(status_code=200)
|
||||
a.json.return_value={'rows':[{'keys':['x'],'clicks':1,'impressions':2,'position':4,'ctr':.5}]}; b.json.return_value={}
|
||||
s.post.side_effect=[a,b]
|
||||
r=w.GoogleCollector(s,page_size=1).gsc('https://canina.ir/blog/a',('2026-10-01','2026-10-14'))
|
||||
self.assertEqual(s.post.call_count,2); self.assertEqual(r['rows'][0]['clicks'],1)
|
||||
def test_partial_pagination_discards_aggregates(self):
|
||||
s=Mock(); a=Mock(status_code=200); a.json.return_value={'rows':[{'keys':['x']}]}; s.post.side_effect=[a,requests.Timeout()]
|
||||
r=w.GoogleCollector(s,page_size=1).gsc('https://canina.ir/blog/a',('2026-10-01','2026-10-14'))
|
||||
self.assertEqual(r['status'],'unavailable'); self.assertIsNone(r['metrics'])
|
||||
def test_idempotent_local_and_revision(self):
|
||||
with tempfile.TemporaryDirectory() as d:
|
||||
store=w.Store(Path(d)/'state.sqlite'); p={'findingId':'1','periodStart':'a','periodEnd':'b','feedbackRevision':1}
|
||||
self.assertTrue(store.snapshot(p)); self.assertFalse(store.snapshot(p)); p['feedbackRevision']=2; self.assertTrue(store.snapshot(p))
|
||||
store.alert('GSC','http_403','1');store.alert('GSC','http_403','1');self.assertEqual(len(store.pending()),1)
|
||||
def test_conservative_and_directives(self):
|
||||
r=w.decision({'ceoFeedback':'Do not scale','feedbackRevision':3},{})
|
||||
self.assertEqual(r['action'],'INSUFFICIENT_EVIDENCE'); self.assertEqual(r['mandatoryDirective'],'Do not scale'); self.assertEqual(r['feedbackRevision'],3)
|
||||
def test_ga4_pagination_and_row_count(self):
|
||||
s=Mock(); a=Mock(status_code=200); b=Mock(status_code=200)
|
||||
a.json.return_value={'rows':[{'dimensionValues':[{'value':'x'}]}],'rowCount':2};b.json.return_value={'rows':[{'dimensionValues':[{'value':'y'}]}],'rowCount':2};s.post.side_effect=[a,b]
|
||||
result=w.GoogleCollector(s,page_size=1).collect('GA4','https://example.invalid',{},('a','b'))
|
||||
self.assertEqual(len(result['rows']),2);self.assertEqual(s.post.call_args.kwargs['json']['offset'],'1')
|
||||
def test_malformed_json_sanitized(self):
|
||||
s=Mock();s.post.return_value.status_code=200;s.post.return_value.json.side_effect=ValueError('secret')
|
||||
r=w.GoogleCollector(s).gsc('https://canina.ir/blog/a',('a','b'))
|
||||
self.assertEqual(r['error'],'ValueError');self.assertNotIn('secret',json.dumps(r))
|
||||
def test_backend_pagination(self):
|
||||
s=Mock(); a=Mock(status_code=200);b=Mock(status_code=200)
|
||||
a.json.return_value={'data':[{'id':'1'}],'meta':{'page':1,'totalPages':2,'total':2}}; b.json.return_value={'data':[{'id':'2'}],'meta':{'page':2,'totalPages':2,'total':2}}
|
||||
s.get.side_effect=[a,b]; self.assertEqual(len(w.Backend('http://localhost',s).findings()),2)
|
||||
|
||||
if __name__=='__main__':unittest.main()
|
||||
@@ -0,0 +1,82 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Opt-in acceptance: called by Jest against disposable local Nest/PG only."""
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import tempfile
|
||||
import requests
|
||||
import seo_performance_tracker as w
|
||||
|
||||
|
||||
def main():
|
||||
base = os.environ['SEO_LOCAL_BASE']
|
||||
assert base.startswith('http://127.0.0.1:'), 'local test server only'
|
||||
session = requests.Session()
|
||||
session.headers['Authorization'] = 'Bearer ' + os.environ['CANINA_ADMIN_TOKEN']
|
||||
backend = w.Backend(base, session)
|
||||
checks = {}
|
||||
|
||||
def call(method, suffix='', body=None, expected=200):
|
||||
response = session.request(method, backend.base + suffix, json=body, timeout=30)
|
||||
assert response.status_code == expected, (method, suffix, response.status_code, response.text)
|
||||
return response.json()
|
||||
|
||||
assert requests.get(backend.base, timeout=30).status_code == 401
|
||||
assert requests.get(backend.base, headers={'Authorization': 'Bearer invalid'}, timeout=30).status_code == 401
|
||||
assert requests.get(backend.base, headers={'Authorization': 'Bearer ' + os.environ['SEO_CUSTOMER_TOKEN']}, timeout=30).status_code == 403
|
||||
checks['missing_invalid_nonadmin_denied'] = True
|
||||
created = call('POST', body={
|
||||
'title': 'Disposable blackseed research acceptance', 'hypothesis': 'Integration fixture only',
|
||||
'primaryKeyword': 'blackseed', 'targetKeywords': ['blackseed'],
|
||||
'expectedOutcome': 'Measure existing published article without publishing',
|
||||
'blogId': os.environ['SEO_FIXTURE_BLOG_ID'],
|
||||
}, expected=201)
|
||||
suffix = '/' + created['id']
|
||||
feedback = call('PATCH', suffix + '/feedback', {'expectedVersion': 0, 'feedback': 'Measure only; do not publish'})
|
||||
assert (feedback['version'], feedback['feedbackVersion']) == (1, 1)
|
||||
call('PATCH', suffix + '/action', {'expectedVersion': 1, 'feedbackVersion': 0, 'actionId': 'disposable-fixture'}, expected=409)
|
||||
action = call('PATCH', suffix + '/action', {'expectedVersion': 1, 'feedbackVersion': 1, 'actionId': 'disposable-fixture', 'status': 'ACTIONED'})
|
||||
assert (action['version'], action['actionId']) == (2, 'disposable-fixture')
|
||||
checks['feedback_stale_action_and_correct_link'] = True
|
||||
finding = next(f for f in backend.findings() if f['id'] == created['id'])
|
||||
assert finding['blog']['slug'] == 'dog-black-seed-nigella-sativa'
|
||||
with tempfile.TemporaryDirectory(prefix='seo-worker-') as directory:
|
||||
store = w.Store(Path(directory) / 'state.sqlite')
|
||||
collector = w.GoogleCollector(w.get_google_session())
|
||||
payload = w.collect_finding(finding, collector, w.period(), store)
|
||||
assert payload is not None
|
||||
# Reopen durable worker state before delivery to exercise process restart semantics.
|
||||
store.db.close()
|
||||
store = w.Store(Path(directory) / 'state.sqlite')
|
||||
assert w.deliver_snapshots(store, backend) == 1
|
||||
assert w.deliver_snapshots(store, backend) == 0
|
||||
history = call('GET', suffix)
|
||||
assert len(history['snapshots']) == 1
|
||||
first = history['snapshots'][0]
|
||||
assert first['attributedSalesValue'] is None
|
||||
assert first['ga4ScrollDepthRate'] is None
|
||||
key, raw = store.db.execute('SELECT key,payload FROM snapshots').fetchone()
|
||||
body = w.snapshot_body(json.loads(raw), key)
|
||||
# Actual network retry of identical immutable request, not just local delivered flag.
|
||||
retried = call('POST', suffix + '/snapshots', body, expected=201)
|
||||
assert retried['id'] == first['id']
|
||||
call('POST', suffix + '/snapshots', dict(body, analysisNotes='changed payload'), expected=409)
|
||||
assert len(call('GET', suffix)['snapshots']) == 1
|
||||
assert not store.snapshot(payload)
|
||||
checks['worker_snapshot_history_network_retry_conflict'] = True
|
||||
receipt = {
|
||||
'observedAt': w.now(), 'backend': 'disposable local Nest module + real PostgreSQL',
|
||||
'auth': 'test-only JWT strategy with real JwtAuthGuard/RolesGuard; NOT production identity/API-key',
|
||||
'checks': checks, 'google': payload, 'persistedSnapshot': first,
|
||||
'productionWrites': False, 'scheduled': False,
|
||||
}
|
||||
destination = os.environ.get('SEO_HTTP_RECEIPT')
|
||||
if destination:
|
||||
Path(destination).parent.mkdir(parents=True, exist_ok=True)
|
||||
Path(destination).write_text(json.dumps(receipt, ensure_ascii=False, indent=2))
|
||||
store.db.close()
|
||||
print('REAL_HTTP_ACCEPTANCE_PASSED ' + json.dumps(checks))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,27 @@
|
||||
# Independent acceptance matrix
|
||||
|
||||
Audit date: 2026-10-28 UTC. Status `OPEN` means not independently exercised in this read-only PMO audit, not an assertion that concurrent implementation lacks it. Bind receipts to the final integrated SHA; identify environment, actual command/request, sanitized response, assertion, exit code and artifact path. Store planned execution evidence under `evidence/seo-tracking/<SHA>/<row-id>/`; this is a naming convention, not a claim those artifacts exist. This audit ran Spec Kit prerequisites and read-only transport/source checks only; no application acceptance is claimed.
|
||||
|
||||
| ID / requirement | Owner(s) | Concrete scenario and expected assertion | Required independent evidence | Status |
|
||||
|---|---|---|---|---|
|
||||
| Q01 / R2 auth | Engineering + Security/QA | GET list/detail and POST finding/snapshot, PATCH feedback/action with no credential →401; real non-admin login →403; authorized login succeeds; no guard bypass | Real HTTP responses from isolated app and fresh approved-vault Stage login (not forged live JWT) | OPEN |
|
||||
| Q02 / R2 input | Engineering/DBA | Invalid UUID, extra fields, oversized/negative page, unapproved sort, NaN/negative metrics, inverted/future window, foreign finding/target are rejected without writes | HTTP validation and before/after real DB assertions | OPEN |
|
||||
| Q03 / R1 multiplicity | Research/SEO + Engineering | Persist one finding with ≥2 actions/targets, ≥3 keywords and ≥2 independently defined goals; query all after process/database client restart; deleting target preserves evidence/history | Actual API write/read isolated DB, persisted relations/history, goal units/baselines | OPEN |
|
||||
| Q04 / R2 query | Backend + Frontend | Two pages with equal sort values have no duplicates/missing IDs; real total consistent; Persian/Arabic variants search correctly; filter/search resets page and uses server state | API + browser request/DOM assertions and stable ID set comparison | OPEN |
|
||||
| Q05 / R3 feedback race | Backend + QA | Two saves with same expected version: only one succeeds, other 409; later GET has winning text/actor/time/version; no silent overwrite on UI retry | Concurrent real HTTP/DB test and browser conflict/reload interaction | OPEN |
|
||||
| Q06 / R3 downstream enforcement | Content/Medical + SEO + Engineering | Capture current directive, begin actual editorial/SEO action, change feedback before finalize; stale action is blocked; retry rereads directive and action evidence identifies compliance/version | Real consumer integration logs/artifact and absence of stale side effect; controller-only test insufficient | OPEN |
|
||||
| Q07 / R4 nullable semantics | Worker + Backend + UI | Real zero-count provider window displays 0; 401/403/timeout/unsupported/missing metric displays null + reason/time, never 0; rank without observations is not zero; one missing metric does not falsify others | Sanitized provider response→HTTP→DB→DOM trace; deterministic error unit test supplement | OPEN |
|
||||
| Q08 / R6 idempotence | Engineering/DBA + Worker | Concurrent identical ingestion and retry after restart create exactly one snapshot; changed payload same key →409; new window appends; old data unchanged | Real PostgreSQL uniqueness/race/restart test and exact count/ID comparison | OPEN |
|
||||
| Q09 / R6 history | Backend + UI | More than 30 windows retrievable with stable pagination/explicit bounds; source window/canonical URL/units/time preserved; no misleading chart continuity across missing periods | API history and UI inspection against actual DB set | OPEN |
|
||||
| Q10 / R4 Google | Research/SEO + DevOps | Real authorized GSC domain/GA4 property read for linked canonical URL/window; reconcile counts/aggregates/date timezone; test canonical aliases/provider pagination/quota errors | Actual sanitized API results, query dimensions and comparison receipt; mocks do not pass live row | OPEN |
|
||||
| Q11 / R4 Clarity | Frontend/UX + DevOps | Discover approved report access and fetch/import real behavior report with provenance; if unavailable, UI identifies exact limitation and owner, no made-up Clarity scores | Actual report/request or explicit unsupported receipt; script presence alone insufficient | OPEN |
|
||||
| Q12 / R4 event goals | Growth + Frontend/UX | Subscription success vs attempt, add_to_cart quantity/value, checkout, article→product/shop/internal navigation and purchase events verified independently; no duplicate route event; scroll threshold/denominator and engagement/bounce units correct | Browser network/collector payload plus real reporting receipt by URL/window; missing instrumentation recorded unavailable | OPEN |
|
||||
| Q13 / R5 commerce | Growth/Commerce + DBA + QA | Prove lawful article/session/order join; paid/completed/refunded/deduped orders and currency/window/model reconcile; unknown join/cross-device/consent loss never maps total orders to article or zero attributable revenue | Documented mechanism and sanitized real aggregate reconciliation; explicit unknown limitations if unsupported | OPEN |
|
||||
| Q14 / R2 UI | Frontend/UX + QA | Real sidebar route loads data; loading/empty/error/retry, nullable sources/limitations/history/goals/directive conflicts visible; mobile viewport/keyboard and RTL inputs usable | Authenticated Stage DOM/network interaction evidence on actual built bundle | OPEN |
|
||||
| Q15 / R7 alerts | DevOps + department owners + PMO | Provider failure creates routed deduped department work/alert, failed delivery persists/retries, recovery recorded; actual receiving department receipt, no raw secret/error dump | Real approved delivery and receiving-side readback; mocked Telegram send insufficient | OPEN |
|
||||
| Q16 / R6 decisions | SEO + Medical + PMO | Sparse/missing/comparable-vs-incomparable windows yield uncertainty; arbitrary thresholds cannot prune/delete/change content or force PRUNED; recommendation remains distinct from task authorization/execution | Tests plus task/decision audit; no destructive live probe | OPEN |
|
||||
| Q17 / constraints schema/release | DBA + DevOps + QA | Reviewed schema compatibility/separate authorized migration; full suites/builds pass final SHA; exact-SHA Actions terminal log, both image/container labels and live feature behavior agree | DDL/backup approval, actual test exits, Actions URL/log, manifest/images and Stage acceptance | OPEN |
|
||||
| Q18 / R7 scheduling | DevOps + Parsa | Deliver tested invocable worker with documented dry-run mutation boundary; no cron created/activated by agents; Parsa configures jobs individually | Worker CLI run and read-only scheduler inventory when available; explicit ownership note | OPEN |
|
||||
|
||||
## Omissions corrected by this audit
|
||||
Original spec collapsed research to one blog and one expected-outcome string, omitted many-action/goal history and Clarity acceptance, treated all metric defaults as zero, asserted commerce attribution without a join, limited anomalies to Telegram, omitted stale directive enforcement and durable idempotence, and instructed automatic cron creation. Those are acceptance obligations now; edits do not prove implementation. No arbitrary prune/scaling threshold is authorized.
|
||||
@@ -0,0 +1,26 @@
|
||||
# Technical plan: SEO performance tracking
|
||||
|
||||
## Evidence boundary
|
||||
Baseline inspected: local `13f4fdc58dff96f192c612a8d38f33d314f70fad`; concurrent implementation advanced to `39f5b705c57ca4bf807210e8b887cb8bced7926b` during audit. Bind final acceptance to the later integrated clean SHA, not these intermediate observations. Files in this directory are human-authored reviewed artifacts; `specify 1.2.3` and installed prerequisite checks were exercised, not a claim of automatic slash-command generation or registered Hermes integration. See release investigation and acceptance matrix for actual observations.
|
||||
|
||||
## Architecture and contract requirements
|
||||
- Backend `backend/src/seo-tracking`: guarded NestJS controller/service, DTO validation, bounded stable list pagination; return repository-compatible `meta` contract and document exact field names rather than inventing a conflicting `totalPages` requirement. Discover current client route in `frontend/admin-panel/src/routes/adminRoutes.tsx`; sidebar and actual mounted route must agree.
|
||||
- Data model must represent finding→many actions/targets, many keywords/goals and directive/action history. Existing single `blogId` uniqueness is not sufficient. Review normalized child records or explicit validated structured storage; document queryability, identifiers, indexes and retention. Do not claim a migration is done just because schema text exists.
|
||||
- Versioned feedback transaction and downstream execution contract: expected finding/directive version, read-before-execute and recheck-before-finalize; stale conflicts stop effects. Verify actual editorial/SEO callers, not only the controller. Preserve feedback author/time/history and per-action compliance evidence.
|
||||
- Snapshot contract: explicit period, canonical URL/target, deterministic idempotency identity, per-source and per-metric availability/provenance, null unknown values, units/currency, provider schema semantics and history retrieval. Database uniqueness protects concurrency; duplicate identical requests succeed and changed payload conflicts. No default-zero model for absent sources.
|
||||
- Extend API/client/UI together for Clarity, goals, event metrics, attribution limitations and history. Mark supported vs missing contract fields explicitly. Do not hide business scope behind generic `sourceMetadata` when the UI cannot render or validate it.
|
||||
- Worker `scripts/seo_performance_tracker.py`: authenticated API integration, real bounded GSC/GA4 requests, discovered approved Clarity input, attribution adapter only if join evidence exists; unknown otherwise. Canonicalize URLs, define timezone/date windows and pagination, bound retries/timeouts/rate limits; use no secret defaults. Persist/restore deterministic run identity so retries after process restart are idempotent.
|
||||
- Alerts: durable deduplication plus routed department task/notification and delivery status/readback. Department routing must use verified existing contracts; raw Telegram alone does not fulfill assignment/delivery. Reporter does not fabricate completed QA or publish/prune content.
|
||||
- Admin UI: actual `SeoTrackingPage.tsx` and `services/seoTrackingApi.ts` paths currently exist (the earlier planned `SeoTracking.tsx`/`api/seoTracking.ts` paths were inaccurate). Display nullable metrics without `|| 0`, explicit source status/time/limitations, action/goal/directive and persistent history. Handle version conflict with reload/review, no silent resubmit over new feedback.
|
||||
|
||||
## Validation and release
|
||||
1. Save focused RED then GREEN runs; unit fixtures/adapters prove branches only. Run full backend tests/build (`npm test`, `npm run build`) and admin tests/typecheck/build (`npm test`, `npm run typecheck`, `npm run build`) in actual installed dependency environment. Record commands, exit codes and SHA.
|
||||
2. Isolated PostgreSQL + real Nest HTTP auth/role/validation tests verify committed migrations/schema, restart persistence, concurrent feedback and snapshot ingestion. No live production mutation and no forged live JWT. Exercise real downstream action consumer and department delivery separately.
|
||||
3. Live provider read-only acceptance records sanitized property/URL/window/results/provenance and reconciles with provider response. Missing credentials/report/event join remain explicit blocked rows. Do not replace this with synthetic HTTP responses.
|
||||
4. Any required schema change is separately authorized and applied before compatible code rollout, with reviewed DDL and rollback; the official Stage release is code-only and will not migrate automatically.
|
||||
5. Secure Git transport and exact remote ancestry must be established before non-force develop push. Official workflow executes SHA-pinned `deploy.sh` → `release-cache-stage.sh`; it builds/recreates backend/frontend and probes public readiness, but does not run application test suites. Therefore passing CI is not equivalent to complete feature QA.
|
||||
6. Match Actions run SHA and completed logs, source manifest, both image/container SHA labels, then authenticated Stage feature behavior and real metrics. Operational checkout is intentionally untouched; never reset/clean it. See `release-investigation.md` for observed dirty checkout and secure transport blocker.
|
||||
7. Parsa owns individual manual cron activation. Supply documentation only; no create/enable action. Production/main remains separate authorized release.
|
||||
|
||||
## Open acceptance dependencies
|
||||
Full many-action/goal representation, Clarity report authorization, trustworthy event instrumentation, commerce join/window/refund policy, actual directive execution consumers, alert delivery receipts and schema operation approval must be verified by owning departments. They cannot be declared implemented from this plan or a small unit suite. `acceptance-matrix.md` remains the closure checklist.
|
||||
@@ -0,0 +1,50 @@
|
||||
# Read-only release-path investigation
|
||||
|
||||
2026-10-28 UTC. No push, server edit, reset/clean, migration, deployment, cron action or external mutation performed. Local changes are feature documents plus an isolated scratch Graphify copy. Concurrent workers changed application files independently.
|
||||
|
||||
## Verified transport and source facts
|
||||
- Initial local application HEAD `13f4fdc58dff96f192c612a8d38f33d314f70fad`, later `39f5b705c57ca4bf807210e8b887cb8bced7926b` during audit; do not bind final integration acceptance to a moving HEAD.
|
||||
- `origin` is `/opt/data/cache/scratch/blog-freshness-develop.bundle`, not the authoritative network remote. `gitea` is `canina-gitea:parsa/canina.git`.
|
||||
- `/opt/data/.ssh/config:1–8` default parsa-host config disables host checking. Audit explicitly overrode it with `-o StrictHostKeyChecking=yes -o UserKnownHostsFile=/opt/data/.ssh/known_hosts`. `ssh-keygen -F '[172.22.0.1]:2234'` found existing pinned ED25519 entry; strict connection succeeded. No TOFU/keyscan trust was introduced.
|
||||
- Through that strictly pinned host channel, read `/data/ssh/*.pub` inside `gitea_main` (mount `/opt/services/git/gitea/gitea -> /data`). Verified Gitea ED25519 key fingerprint `SHA256:9SzVGbc5GOahn2qgjN64w1VIG/z/AHJBPCsm1oZa81g`; public key `ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMvMyQsjrxAOKL2E+rbeMKZJyLUwTqe78+2tJQmjcOJR`.
|
||||
- This exact public key already matches hashed entry 2 in user-owned `/opt/data/.ssh/known_hosts` (uid 10000, mode 0644), resolved by `ssh-keygen -F '[git.parsaaghayi.ir]:222'`. Existing gitea config instead points to root-owned `/opt/data/.ssh/gitea_known_hosts` (0600), inaccessible to current runtime.
|
||||
- Local read-only `git ls-remote gitea` with `GIT_SSH_COMMAND='ssh -F /opt/data/.ssh/config -o StrictHostKeyChecking=yes -o UserKnownHostsFile=/opt/data/.ssh/known_hosts -o HostKeyAlgorithms=ssh-ed25519'` passed host verification but failed `Load key /opt/data/.ssh/canina_gitea: Permission denied` then publickey authentication. Host trust is resolved; local private-key permission/provisioning is the remaining transport blocker. Do not print/copy secret key bytes or disable checking.
|
||||
- Host-side default Git SSH also disables checking (`ssh -G`), so audit did not rely on that default. Host `/root/.ssh/known_hosts` has the same verified Gitea ED25519 key. Explicit strict host-side `GIT_SSH_COMMAND='ssh -o StrictHostKeyChecking=yes -o UserKnownHostsFile=/root/.ssh/known_hosts -o HostKeyAlgorithms=ssh-ed25519' git -C /opt/services/canina/stage ls-remote origin refs/heads/develop refs/heads/main` succeeded: both refs `00ba4360cf7b161995ee94f220b61f9547e01723`. This proves read access, not push permission.
|
||||
- Gitea reports v1.22.6. No API token or browser password was requested.
|
||||
|
||||
## Actual server checkout / runtime observations
|
||||
Always use `git -C /opt/services/canina/stage`; never `--git-dir` from an unrelated cwd. Correct read-only `git -C ... status --short` really reports numerous staged modifications/deletions plus generated `docker-compose.yml`, `nginx.conf` changes and untracked `.revalidation.env`. These are not the previous bogus all-files-deleted result, but they still make the checkout unsafe for manual cleanup/reuse. It is on develop, HEAD `bb81f2c9449357428dd04ba97e921590a4163048`, not current remote/runtime SHA. Preserve all of it.
|
||||
|
||||
Running Stage labels both identify `00ba4360cf7b161995ee94f220b61f9547e01723`:
|
||||
- backend image `sha256:091a59b7ee5424465406603c2ade96689fdb9726109257630546538b2a1deba8`;
|
||||
- frontend image `sha256:a1609a9033be42d5cff7b998340fe5d869eb75f56b53596ba835ceee5129e12f`.
|
||||
These are provenance observations, not SEO feature acceptance. Host checkout lacks the remote object (`git cat-file -t 00ba...` fails); no fetch was done. Its old HEAD workflow is obsolete and branch-download based. To avoid falsely interpreting that old checkout as active release source, exact remote-SHA files were independently fetched read-only over HTTPS and their SHA256 matched local inspected files:
|
||||
|
||||
| Source URL suffix under `https://git.parsaaghayi.ir/parsa/canina/raw/commit/00ba4360cf7b161995ee94f220b61f9547e01723/` | SHA256 |
|
||||
|---|---|
|
||||
| `.gitea/workflows/deploy.yml` | `0ed605208bf6c904db01ef2463490748029242db4fa5e172b2be364215936e69` |
|
||||
| `scripts/deploy.sh` | `346b63cdce43a3e990e2e56670fe65465cb334768cfd46adfc0893d375ecf896` |
|
||||
| `scripts/release-cache-stage.sh` | `6c90100399cb4b967c8ebf3afa1ae838157da293e6e4e61717d342cb49fcd829` |
|
||||
|
||||
## Source-verified official CI contract
|
||||
Line references are to matching local files in `/opt/data/content-maintenance/engine/worktree-concurrency-tdd` at audit time; exact remote-SHA URLs above establish remote provenance.
|
||||
- `.gitea/workflows/deploy.yml:3–17`: push to develop/main, runner label `canina`, `DEPLOY_SHA=${{ github.sha }}` and Actions flag. Lines 27–35 download dispatcher/release scripts by exact commit SHA and invoke dispatcher with branch.
|
||||
- `scripts/deploy.sh:4–6`: normal develop → `release-cache-stage.sh`, main → `release-cache-prod.sh`. Alternate backend-only path is not the normal workflow and must not be used as a shortcut.
|
||||
- `scripts/release-cache-stage.sh:6`: Actions context + 40-char SHA required. Lines 74–98 acquire daemon helper + host inode lock with read-only descriptor; host lock metadata verified 0644 root.
|
||||
- Lines 100–129 fetch/check exact `origin/develop`, archive immutable isolated `cache-releases/<SHA>.attempt.*`, generate source hash manifest, deliberately preserve operational HEAD/config.
|
||||
- Lines 131–161 provision private runtime configuration, copy operational nginx, validate Compose/runtime. Lines 163–170 build and force-recreate only backend/frontend (`--no-deps`, no orphan prune), verify image/container revision labels.
|
||||
- Lines 171–234 check running/restart state and bounded public `/api/blogs?page=1&limit=1`, frontend `/`, nginx host readiness and final image parity. These are readiness checks, not authenticated SEO QA.
|
||||
- Normal script contains no application `npm test` run and no migration/seed. No new schema is applied by this path. Any required migration needs separate explicit authorization/backup/DDL review. Worker delivery/cron is not included in this code CI path.
|
||||
- The inspected main dispatcher uses code-only prod script too; this audit authorizes neither main push nor Production release. No historical Gate1/Gate2 or unused receipt helper is added as a requirement.
|
||||
|
||||
## Actionable secure path (not executed)
|
||||
1. Keep current verified user-owned `/opt/data/.ssh/known_hosts`; use the strict SSH override above, or have an authorized administrator provision an accessible least-privilege deploy credential. Do not chmod root-owned key files from this audit, copy keys into artifacts, run blind keyscan, or set checking=no.
|
||||
2. Alternative after authorization: package reviewed committed SHA locally; transfer into a new isolated user-owned server staging area through the pinned host transport, and use the existing server deploy key with explicit verified known_hosts. Never modify `/opt/services/canina/stage` worktree. Successful strict read refs do not prove server key push rights; confirm authorized credential scope before attempting release.
|
||||
3. Re-read authoritative refs and fetch into isolated local/integration repo once access is provisioned; check ancestry/full diff and integrate concurrent worker changes on develop without force. Save actual test/build and schema compatibility results at one final SHA.
|
||||
4. Only after release authorization and separate schema readiness: non-force push final develop SHA to authoritative Gitea transport. Observe supported push-triggered Actions run at exact SHA and terminal log; do not assume workflow_dispatch API support.
|
||||
5. Verify source manifest, backend and frontend image/container labels, actual Actions log/image correlation and authenticated Stage acceptance matrix rows. Old operational HEAD is intentionally not release parity. Keep scheduling disabled/uncreated until Parsa configures individual jobs.
|
||||
|
||||
## Spec/Graphify validation actually exercised
|
||||
`specify --version` →1.2.3; `specify check` exit 0 (CLI ready, agent integration not established). Explicit `SPECIFY_FEATURE=002-seo-performance-tracking SPECIFY_FEATURE_DIRECTORY=<this directory> .specify/scripts/bash/check-prerequisites.sh --json --require-spec --require-tasks --include-tasks` exit 0. Installed checker can persist feature path metadata; it was not rerun through setup-plan (which would overwrite plan).
|
||||
|
||||
Graph copied before querying to `/opt/data/cache/scratch/seo-qa-graph/graphify-out/graph.json`, source hash `6a73473cee9e207543fdeeb668bea544f766200a1b16b8a3a9ce18d4e42e51af`, `built_at_commit=e7ded849f6b1e3bdab2a20d89b3ec7dd0df79cab` (stale vs working source). Isolated `graphify query 'SEO tracking research finding feedback snapshot deploy stage release' --budget 1200` succeeded, 4304 graph nodes, 199 traversal nodes, output truncated; navigation only, not completeness evidence. Material findings confirmed directly in current controller/service, AnalyticsDeferred and release source. Concurrent original graph cache dirtiness was observed, not reset.
|
||||
@@ -0,0 +1,34 @@
|
||||
# Feature specification: SEO performance tracking closed loop
|
||||
|
||||
## Scope and status
|
||||
Reviewed scope for research → approved digital action → measured outcome → CEO directive → revised action. This document describes required behavior, not completed or deployed capability. Independent acceptance is in `acceptance-matrix.md`; release findings are in `release-investigation.md`. Unit tests, synthetic adapter fixtures, a local commit, and HTTP 200 are not end-to-end proof. All department handoffs require observable artifacts; no Gate1/Gate2 terminology or automatic scheduler activation.
|
||||
|
||||
## User stories and requirements
|
||||
|
||||
### R1 — Durable research and actions
|
||||
Research/SEO can store evidence URLs, observation date, title, hypothesis, intent, primary and secondary keywords, multiple measurable goals with units/windows/baselines, and multiple related actions/targets. A finding must support many actions, keywords and goals; a single optional blog relation is not the whole business model. Content, catalog, technical SEO, conversion, and UX actions may have different targets. Actions carry owning department, source finding, evidence, status, timestamps and immutable history. Preserve findings/history when targets disappear. Distinguish proposed recommendations from authorized executable actions and actual published artifacts.
|
||||
|
||||
### R2 — Authenticated management
|
||||
Authorized administrators can list/search/filter/sort findings with stable server pagination, truthful totals and bounded page sizes; normalized Persian/Arabic keyword search is tested. UI includes navigation, detail, goals, action/evidence history, source freshness, measurements, limitations and feedback. Unauthenticated requests receive 401; authenticated unauthorized users receive 403 for every read/write route. Validate payloads, UUIDs, numeric ranges, allowed sorting and periods; reject unknown fields. Never expose credentials or customer PII in UI/worker logs.
|
||||
|
||||
### R3 — CEO feedback is optional to submit, mandatory to obey
|
||||
Feedback persists atomically with timestamp, actor and monotonically changing directive/finding versions. Concurrent saves use expected version and return conflict rather than overwriting silently. Every downstream content/SEO action reads and binds the current directive version before work and rechecks at commit/publication/ingestion boundaries. A stale directive cannot authorize action or silently overwrite newer feedback. Merely displaying feedback or accepting a client-supplied version is insufficient: QA verifies the real execution consumer and conflict recovery. Human-readable rationale links each action to the directive it followed; ambiguous directives remain blocked for clarification.
|
||||
|
||||
### R4 — Real measurements and honest missing data
|
||||
Explicitly invoke a bounded worker to collect real GSC (`sc-domain:canina.ir`) and GA4 (`properties/552453291`) measurements for canonical target URLs and explicit closed date windows. Discover and validate actual permitted credentials/properties without printing secrets. Store provenance (source/property, request window, fetch time, canonical URL, source status, reason and units). Null/unavailable/error/unsupported/stale are not zero. A genuinely empty successful provider response may yield zero counts but not a fictional zero average rank. Partial source/metric availability remains visible; no fabricated fallback metrics or conclusions. Reconcile canonical/trailing slash/encoded URL variants and pagination/quotas; retries are bounded.
|
||||
|
||||
Clarity is explicitly in scope: discover approved export/API/report access, ingest meaningful behavior measurements with provenance, or display unsupported/unavailable with reason and responsible owner. Loading a Clarity script does not prove report integration. GA4 engagement time, bounce and scroll must use documented numerators/denominators; do not present the default scroll event (90% threshold) as arbitrary scroll-depth distribution. Include subscriptions/sign-ups, add-to-cart, checkout, article→product/shop/internal navigation, and completed purchase goals only where event collection and URL/window attribution are independently verified. Missing instrumentation is a tracked gap, not zero conversions.
|
||||
|
||||
### R5 — Commerce attribution has explicit limits
|
||||
Orders alone cannot establish that an article visitor purchased. Report attributable orders/revenue only with a documented lawful join/attribution mechanism, window/model, currency, paid/completed/refund treatment and deduplication. Separate total commerce from attributed commerce. Unknown joins, consent loss, cross-device loss, blockers or uninstrumented events produce unknown/unavailable and limitations; never assign all orders or zero orders to a finding by inference. Aggregate only necessary data and do not disclose customer identifiers.
|
||||
|
||||
### R6 — Persistent history and recommendations
|
||||
Append snapshots with a deterministic finding/target/window/source-contract ingestion identity, preserved across restart/retry. Same identity and payload returns the same snapshot; conflicting payload is rejected explicitly. Concurrent retries cannot duplicate records; historical windows remain retrievable through pagination rather than being lost behind a fixed latest-N response. Preserve source-specific and metric-specific partial availability and measurement semantics. Recommendations use actual comparable evidence and uncertainty, not arbitrary hard-coded thresholds. No automatic deletion, PRUNED transition, content pruning, or scaling based solely on thresholds. Any destructive/content change requires a separately authorized task and independent QA.
|
||||
|
||||
### R7 — Department delivery and scheduler ownership
|
||||
Research/SEO owns evidence and hypotheses; Content/Medical owns accurate editorial execution; Engineering/DBA owns contracts/schema/auth; Frontend/UX owns usable and measured interactions; Growth/Commerce owns attribution definitions; DevOps owns credentials/release/scheduler readiness; QA/PMO independently verifies receipts and routes defects. Provider/instrumentation/schema anomalies create or deliver actionable, deduplicated department alerts with finding/run/source/error context, bounded retry and durable delivery result. Telegram is a notification channel, not proof of department delivery. Test receipt and recovery, not just a mocked send call. Do not automatically publish content from the tracker.
|
||||
|
||||
Parsa manually configures each cron individually. Deliver an invocable worker, documented arguments, dry-run semantics and proposed schedule only; do not create, enable or alter cron jobs. Dry-run must have a tested explicit mutation boundary; real acceptance separately verifies authorized snapshot persistence.
|
||||
|
||||
## Operational constraints
|
||||
TDD requires saved RED and GREEN evidence before/after implementation. Real isolated database/HTTP integration, live provider readback and authenticated Stage browser acceptance are mandatory in addition to unit tests. Schema migration is a separate reviewed/authorized operation with backup/rollback and compatibility evidence; code CI must not run migrations/seeds. Use develop → exact-SHA CI → Stage behavior; promotion to main/Production requires separate authorization. No external writes, pushes, migrations, deployments or scheduler activation are authorized by this specification audit. Retain each unresolved acceptance row as blocked, not complete.
|
||||
@@ -0,0 +1,40 @@
|
||||
# Tasks: SEO tracking (unverified tasks remain open)
|
||||
|
||||
No checked task means implementation failure; unchecked means independent evidence is not recorded here. Department workers may implement in parallel, but final validation uses one integrated SHA. Acceptance row IDs refer to `acceptance-matrix.md`.
|
||||
|
||||
## Scope / prerequisites
|
||||
- [x] T001 PMO: inspect initial feature documents and actual installed Spec Kit 1.2.3; run `specify check` and explicit-feature prerequisite check (exit 0). Presence checks do not certify business quality.
|
||||
- [x] T002 QA: expand omissions and maintain independent acceptance matrix and read-only release investigation.
|
||||
- [ ] T003 Research/SEO + Growth + Medical: document many actions/targets/keywords/goals, evidence and units; resolve only genuinely unresolved business choices with Parsa (Q03, Q10–Q13).
|
||||
|
||||
## Tests before implementation (backend/UI/worker may proceed in non-overlapping files)
|
||||
- [ ] T010 Engineering/DBA: RED then GREEN real HTTP auth, roles, DTO boundaries, Persian search/stable pagination and database contracts (Q01–Q04).
|
||||
- [ ] T011 Engineering + Content/SEO: RED then GREEN concurrent feedback, stale directive and real downstream execution blocking (Q05–Q06).
|
||||
- [ ] T012 Engineering/DBA + worker: isolated PostgreSQL history/restart/concurrent idempotent ingestion, payload conflicts and partial availability (Q07–Q09).
|
||||
- [ ] T013 Frontend/UX: RED then GREEN list/navigation/detail, nullable metrics, goals/history, feedback success/failure/conflict and mobile keyboard tests (Q14).
|
||||
- [ ] T014 Worker + DevOps: test provider error/timeout/quota/pagination/canonical URL handling and durable department alert dedupe/delivery recovery (Q10–Q13, Q15).
|
||||
|
||||
## Integrated implementation / real acceptance
|
||||
- [ ] T020 Engineering/DBA: implement reviewed many-action/goal schema and API, versioned feedback/history, per-metric/source provenance and idempotency; prepare separate schema review/backup/rollback, do not apply remotely in code rollout.
|
||||
- [ ] T021 Frontend/UX: integrate actual mounted page/sidebar and API contract; expose all accepted scope and unknown limitations.
|
||||
- [ ] T022 Worker + Research/SEO: real GSC/GA4 collection and persistent snapshots; documented approved Clarity report input or explicit unavailable status; no fake metrics.
|
||||
- [ ] T023 Growth/Commerce: prove subscription/cart/checkout/navigation event collection and lawful article-to-order join; document unsupported/unknown where absent, no total-order attribution shortcut.
|
||||
- [ ] T024 Content/Medical + SEO: demonstrate current CEO directive reaches real article/SEO execution and stale work is prevented at finalization.
|
||||
- [ ] T025 QA/PMO: run every matrix row independently; save real source response, HTTP/database/browser and department delivery artifacts. Keep blocked rows open and distinguish fixture-only coverage.
|
||||
- [ ] T026 QA: full backend tests/build; admin tests/typecheck/build; worker tests against integrated SHA, with exact commands/counts/exit codes and RED/GREEN logs.
|
||||
|
||||
## Local integration evidence (2026-10-28; partial scope, not matrix closure)
|
||||
- [x] I001 Port worker source, 17 tests and docs into `scripts/seo-performance/` without credentials/state/cache.
|
||||
- [x] I002 Exercise actual Nest module over TCP with shared auth guards and disposable PostgreSQL: create finding, feedback revision, stale action 409, correct action link, worker list, SQLite reopen, snapshot POST/GET, identical network retry and changed-payload conflict. Test-only JWT identity; production authentication remains open.
|
||||
- [x] I003 Read real Google GSC/GA4 blackseed article measurements and persist through worker/HTTP/PG. Preserve Clarity/commerce/scroll as unavailable/null. Sanitized receipt: `scripts/seo-performance/evidence/real-http-receipt.json`.
|
||||
- [x] I004 Run focused backend (4 suites/16 tests), worker (17 tests) and backend build successfully. Full backend still fails existing WikiService assertion (815 pass/1 fail/8 skip); no claim that T026 or broad matrix passes.
|
||||
|
||||
See `scripts/seo-performance/VERIFICATION.md` for baseline, commands, setup failure and open boundaries. Existing T010–T026 remain open where their wider acceptance is not fully exercised. No new implementation fix or behavioral RED/GREEN claimed because integration found no contract mismatch.
|
||||
|
||||
## Authorized release only (not authorized by this audit)
|
||||
- [ ] T030 DevOps: resolve unreadable local deploy key through approved provisioning or authorized trusted-host Git transport; verify host pins and remote refs/ancestry without disabling verification.
|
||||
- [ ] T031 Engineering/DBA: obtain separate schema-operation authorization; apply/reconcile only reviewed compatible schema with backup/rollback evidence if required.
|
||||
- [ ] T032 Integration owner: clean reviewed owned files, exact SHA and non-force push to develop only after real tests; observe official exact-SHA Actions run through final log.
|
||||
- [ ] T033 QA + DevOps: verify both Stage image/container SHA labels, manifest and authenticated real browser/provider behavior. Never reset/clean dirty operational checkout.
|
||||
- [ ] T034 PMO: collect all department evidence; no Stage/main/Production claims from local tests; separately seek authorized main promotion only after complete Stage acceptance.
|
||||
- [ ] T035 DevOps: deliver worker invocation/dry-run documentation and proposed per-job cadence to Parsa. Do NOT create or activate cron; manual individual configuration is Parsa's preference.
|
||||
Reference in new issue
Block a user