@nebulacomponents/citable 1.5.1 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/README.md +13 -6
- package/dist/universal/.agents/skills/citable/SKILL.md +18 -2
- package/dist/universal/.agents/skills/citable/VERSION +1 -1
- package/dist/universal/.agents/skills/citable/commands/measurement.md +31 -1
- package/dist/universal/.agents/skills/citable/manifest.json +12 -8
- package/dist/universal/.agents/skills/citable/references/evidence-authority.md +43 -0
- package/dist/universal/.agents/skills/citable/schemas/bing-webmaster.schema.json +25 -0
- package/dist/universal/.agents/skills/citable/schemas/connection.schema.json +1 -0
- package/dist/universal/.agents/skills/citable/schemas/crawler-identity.schema.json +42 -0
- package/dist/universal/.agents/skills/citable/schemas/evidence-authority.schema.json +15 -0
- package/dist/universal/.agents/skills/citable/schemas/observation.schema.json +3 -2
- package/dist/universal/.claude/skills/citable/SKILL.md +18 -2
- package/dist/universal/.claude/skills/citable/VERSION +1 -1
- package/dist/universal/.claude/skills/citable/commands/measurement.md +31 -1
- package/dist/universal/.claude/skills/citable/manifest.json +12 -8
- package/dist/universal/.claude/skills/citable/references/evidence-authority.md +43 -0
- package/dist/universal/.claude/skills/citable/schemas/bing-webmaster.schema.json +25 -0
- package/dist/universal/.claude/skills/citable/schemas/connection.schema.json +1 -0
- package/dist/universal/.claude/skills/citable/schemas/crawler-identity.schema.json +42 -0
- package/dist/universal/.claude/skills/citable/schemas/evidence-authority.schema.json +15 -0
- package/dist/universal/.claude/skills/citable/schemas/observation.schema.json +3 -2
- package/dist/universal/.cursor/skills/citable/SKILL.md +18 -2
- package/dist/universal/.cursor/skills/citable/VERSION +1 -1
- package/dist/universal/.cursor/skills/citable/commands/measurement.md +31 -1
- package/dist/universal/.cursor/skills/citable/manifest.json +12 -8
- package/dist/universal/.cursor/skills/citable/references/evidence-authority.md +43 -0
- package/dist/universal/.cursor/skills/citable/schemas/bing-webmaster.schema.json +25 -0
- package/dist/universal/.cursor/skills/citable/schemas/connection.schema.json +1 -0
- package/dist/universal/.cursor/skills/citable/schemas/crawler-identity.schema.json +42 -0
- package/dist/universal/.cursor/skills/citable/schemas/evidence-authority.schema.json +15 -0
- package/dist/universal/.cursor/skills/citable/schemas/observation.schema.json +3 -2
- package/dist/universal/.gemini/skills/citable/SKILL.md +18 -2
- package/dist/universal/.gemini/skills/citable/VERSION +1 -1
- package/dist/universal/.gemini/skills/citable/commands/measurement.md +31 -1
- package/dist/universal/.gemini/skills/citable/manifest.json +12 -8
- package/dist/universal/.gemini/skills/citable/references/evidence-authority.md +43 -0
- package/dist/universal/.gemini/skills/citable/schemas/bing-webmaster.schema.json +25 -0
- package/dist/universal/.gemini/skills/citable/schemas/connection.schema.json +1 -0
- package/dist/universal/.gemini/skills/citable/schemas/crawler-identity.schema.json +42 -0
- package/dist/universal/.gemini/skills/citable/schemas/evidence-authority.schema.json +15 -0
- package/dist/universal/.gemini/skills/citable/schemas/observation.schema.json +3 -2
- package/dist/universal/.github/skills/citable/SKILL.md +18 -2
- package/dist/universal/.github/skills/citable/VERSION +1 -1
- package/dist/universal/.github/skills/citable/commands/measurement.md +31 -1
- package/dist/universal/.github/skills/citable/manifest.json +12 -8
- package/dist/universal/.github/skills/citable/references/evidence-authority.md +43 -0
- package/dist/universal/.github/skills/citable/schemas/bing-webmaster.schema.json +25 -0
- package/dist/universal/.github/skills/citable/schemas/connection.schema.json +1 -0
- package/dist/universal/.github/skills/citable/schemas/crawler-identity.schema.json +42 -0
- package/dist/universal/.github/skills/citable/schemas/evidence-authority.schema.json +15 -0
- package/dist/universal/.github/skills/citable/schemas/observation.schema.json +3 -2
- package/dist/universal/.kiro/skills/citable/SKILL.md +18 -2
- package/dist/universal/.kiro/skills/citable/VERSION +1 -1
- package/dist/universal/.kiro/skills/citable/commands/measurement.md +31 -1
- package/dist/universal/.kiro/skills/citable/manifest.json +12 -8
- package/dist/universal/.kiro/skills/citable/references/evidence-authority.md +43 -0
- package/dist/universal/.kiro/skills/citable/schemas/bing-webmaster.schema.json +25 -0
- package/dist/universal/.kiro/skills/citable/schemas/connection.schema.json +1 -0
- package/dist/universal/.kiro/skills/citable/schemas/crawler-identity.schema.json +42 -0
- package/dist/universal/.kiro/skills/citable/schemas/evidence-authority.schema.json +15 -0
- package/dist/universal/.kiro/skills/citable/schemas/observation.schema.json +3 -2
- package/dist/universal/.opencode/skills/citable/SKILL.md +18 -2
- package/dist/universal/.opencode/skills/citable/VERSION +1 -1
- package/dist/universal/.opencode/skills/citable/commands/measurement.md +31 -1
- package/dist/universal/.opencode/skills/citable/manifest.json +12 -8
- package/dist/universal/.opencode/skills/citable/references/evidence-authority.md +43 -0
- package/dist/universal/.opencode/skills/citable/schemas/bing-webmaster.schema.json +25 -0
- package/dist/universal/.opencode/skills/citable/schemas/connection.schema.json +1 -0
- package/dist/universal/.opencode/skills/citable/schemas/crawler-identity.schema.json +42 -0
- package/dist/universal/.opencode/skills/citable/schemas/evidence-authority.schema.json +15 -0
- package/dist/universal/.opencode/skills/citable/schemas/observation.schema.json +3 -2
- package/dist/universal/.pi/agent/skills/citable/SKILL.md +18 -2
- package/dist/universal/.pi/agent/skills/citable/VERSION +1 -1
- package/dist/universal/.pi/agent/skills/citable/commands/measurement.md +31 -1
- package/dist/universal/.pi/agent/skills/citable/manifest.json +12 -8
- package/dist/universal/.pi/agent/skills/citable/references/evidence-authority.md +43 -0
- package/dist/universal/.pi/agent/skills/citable/schemas/bing-webmaster.schema.json +25 -0
- package/dist/universal/.pi/agent/skills/citable/schemas/connection.schema.json +1 -0
- package/dist/universal/.pi/agent/skills/citable/schemas/crawler-identity.schema.json +42 -0
- package/dist/universal/.pi/agent/skills/citable/schemas/evidence-authority.schema.json +15 -0
- package/dist/universal/.pi/agent/skills/citable/schemas/observation.schema.json +3 -2
- package/dist/universal/.qoder/skills/citable/SKILL.md +18 -2
- package/dist/universal/.qoder/skills/citable/VERSION +1 -1
- package/dist/universal/.qoder/skills/citable/commands/measurement.md +31 -1
- package/dist/universal/.qoder/skills/citable/manifest.json +12 -8
- package/dist/universal/.qoder/skills/citable/references/evidence-authority.md +43 -0
- package/dist/universal/.qoder/skills/citable/schemas/bing-webmaster.schema.json +25 -0
- package/dist/universal/.qoder/skills/citable/schemas/connection.schema.json +1 -0
- package/dist/universal/.qoder/skills/citable/schemas/crawler-identity.schema.json +42 -0
- package/dist/universal/.qoder/skills/citable/schemas/evidence-authority.schema.json +15 -0
- package/dist/universal/.qoder/skills/citable/schemas/observation.schema.json +3 -2
- package/dist/universal/.rovodev/skills/citable/SKILL.md +18 -2
- package/dist/universal/.rovodev/skills/citable/VERSION +1 -1
- package/dist/universal/.rovodev/skills/citable/commands/measurement.md +31 -1
- package/dist/universal/.rovodev/skills/citable/manifest.json +12 -8
- package/dist/universal/.rovodev/skills/citable/references/evidence-authority.md +43 -0
- package/dist/universal/.rovodev/skills/citable/schemas/bing-webmaster.schema.json +25 -0
- package/dist/universal/.rovodev/skills/citable/schemas/connection.schema.json +1 -0
- package/dist/universal/.rovodev/skills/citable/schemas/crawler-identity.schema.json +42 -0
- package/dist/universal/.rovodev/skills/citable/schemas/evidence-authority.schema.json +15 -0
- package/dist/universal/.rovodev/skills/citable/schemas/observation.schema.json +3 -2
- package/dist/universal/.trae/skills/citable/SKILL.md +18 -2
- package/dist/universal/.trae/skills/citable/VERSION +1 -1
- package/dist/universal/.trae/skills/citable/commands/measurement.md +31 -1
- package/dist/universal/.trae/skills/citable/manifest.json +12 -8
- package/dist/universal/.trae/skills/citable/references/evidence-authority.md +43 -0
- package/dist/universal/.trae/skills/citable/schemas/bing-webmaster.schema.json +25 -0
- package/dist/universal/.trae/skills/citable/schemas/connection.schema.json +1 -0
- package/dist/universal/.trae/skills/citable/schemas/crawler-identity.schema.json +42 -0
- package/dist/universal/.trae/skills/citable/schemas/evidence-authority.schema.json +15 -0
- package/dist/universal/.trae/skills/citable/schemas/observation.schema.json +3 -2
- package/dist/universal/.trae-cn/skills/citable/SKILL.md +18 -2
- package/dist/universal/.trae-cn/skills/citable/VERSION +1 -1
- package/dist/universal/.trae-cn/skills/citable/commands/measurement.md +31 -1
- package/dist/universal/.trae-cn/skills/citable/manifest.json +12 -8
- package/dist/universal/.trae-cn/skills/citable/references/evidence-authority.md +43 -0
- package/dist/universal/.trae-cn/skills/citable/schemas/bing-webmaster.schema.json +25 -0
- package/dist/universal/.trae-cn/skills/citable/schemas/connection.schema.json +1 -0
- package/dist/universal/.trae-cn/skills/citable/schemas/crawler-identity.schema.json +42 -0
- package/dist/universal/.trae-cn/skills/citable/schemas/evidence-authority.schema.json +15 -0
- package/dist/universal/.trae-cn/skills/citable/schemas/observation.schema.json +3 -2
- package/dist/universal/manifest.json +147 -99
- package/package.json +1 -1
- package/schemas/bing-webmaster.schema.json +25 -0
- package/schemas/connection.schema.json +1 -0
- package/schemas/crawler-identity.schema.json +42 -0
- package/schemas/evidence-authority.schema.json +15 -0
- package/schemas/observation.schema.json +3 -2
- package/skill/SKILL.md +18 -2
- package/skill/commands/measurement.md +31 -1
- package/skill/references/evidence-authority.md +43 -0
- package/src/cli/index.js +44 -1
- package/src/commands/connect.js +90 -0
- package/src/commands/observe.js +81 -22
- package/src/connectors/ga4.js +59 -0
- package/src/connectors/gsc.js +41 -0
- package/src/connectors/http.js +19 -0
- package/src/connectors/index.js +14 -0
- package/src/observations/authority.js +13 -0
- package/src/observations/common.js +3 -1
- package/src/observations/crawlerIdentity.js +60 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nebulacomponents/citable",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Production-grade SEO, AEO, and GEO agent skill with auditable detection, claim governance, evidence validation, and multi-agent installation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"seo",
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "citable://schemas/bing-webmaster.schema.json",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
|
+
"title": "Normalized Bing Webmaster observation",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"required": ["dataset", "date", "url", "metrics", "dimensions", "interpretation_boundary"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"dataset": { "type": "string", "enum": ["search_performance", "ai_performance"] },
|
|
10
|
+
"date": { "type": "string", "format": "date" },
|
|
11
|
+
"url": { "type": ["string", "null"], "format": "uri", "pattern": "^https?://" },
|
|
12
|
+
"metrics": { "type": "object", "additionalProperties": { "type": ["number", "null"] } },
|
|
13
|
+
"dimensions": {
|
|
14
|
+
"type": "object", "additionalProperties": false,
|
|
15
|
+
"properties": {
|
|
16
|
+
"query": { "type": ["string", "null"] },
|
|
17
|
+
"grounding_query": { "type": ["string", "null"] },
|
|
18
|
+
"source": { "type": ["string", "null"] },
|
|
19
|
+
"country": { "type": ["string", "null"] },
|
|
20
|
+
"device": { "type": ["string", "null"] }
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"interpretation_boundary": { "type": "array", "minItems": 1, "items": { "type": "string", "minLength": 1 } }
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"connection_id": { "type": "string", "pattern": "^CONNECTION-[A-Z0-9][A-Z0-9_-]*$" },
|
|
20
20
|
"provider": { "type": "string", "minLength": 1 },
|
|
21
21
|
"property_id": { "type": ["string", "null"] },
|
|
22
|
+
"credential_env": { "type": "string", "pattern": "^[A-Z][A-Z0-9_]*$" },
|
|
22
23
|
"state": { "type": "string", "enum": ["not_configured", "configured", "synchronized", "partial", "authorization_expired", "permission_denied", "quota_limited", "temporarily_unavailable"] },
|
|
23
24
|
"authentication": { "type": "string", "enum": ["none", "environment", "os_keychain", "external_secret_manager", "owner_import"] },
|
|
24
25
|
"scopes": { "type": "array", "items": { "type": "string" } },
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "citable://schemas/crawler-identity.schema.json",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
|
+
"title": "Crawler identity evidence contract",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"required": ["provider", "declared_user_agent", "observed_source_ip", "range_source", "cidr_membership", "dns", "edge", "origin", "region", "collector", "stages", "verification_status"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"provider": { "type": "string", "minLength": 1 },
|
|
10
|
+
"declared_user_agent": { "type": "string", "minLength": 1 },
|
|
11
|
+
"observed_source_ip": { "type": ["string", "null"] },
|
|
12
|
+
"range_source": {
|
|
13
|
+
"type": "object", "additionalProperties": false,
|
|
14
|
+
"required": ["url", "retrieved_at", "authority", "checksum", "checksum_scope", "checksum_valid"],
|
|
15
|
+
"properties": {
|
|
16
|
+
"url": { "type": ["string", "null"], "format": "uri" },
|
|
17
|
+
"retrieved_at": { "type": ["string", "null"], "format": "date-time" },
|
|
18
|
+
"authority": { "type": "string", "enum": ["provider_published", "owner_controlled", "third_party", "unknown"] },
|
|
19
|
+
"checksum": { "type": ["string", "null"], "pattern": "^[a-f0-9]{64}$" },
|
|
20
|
+
"checksum_scope": { "type": "string", "enum": ["source_snapshot", "not_captured"] },
|
|
21
|
+
"checksum_valid": { "type": "boolean" }
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"cidr_membership": { "type": "string", "enum": ["matched", "not_matched", "not_tested", "invalid"] },
|
|
25
|
+
"dns": {
|
|
26
|
+
"type": "object", "additionalProperties": false, "required": ["status", "method"],
|
|
27
|
+
"properties": { "status": { "type": "string", "enum": ["verified", "failed", "not_tested"] }, "method": { "type": ["string", "null"] } }
|
|
28
|
+
},
|
|
29
|
+
"edge": {
|
|
30
|
+
"type": "object", "additionalProperties": false, "required": ["observed", "decision"],
|
|
31
|
+
"properties": { "observed": { "type": "boolean" }, "decision": { "type": ["string", "null"] } }
|
|
32
|
+
},
|
|
33
|
+
"origin": {
|
|
34
|
+
"type": "object", "additionalProperties": false, "required": ["observed", "status"],
|
|
35
|
+
"properties": { "observed": { "type": "boolean" }, "status": { "type": ["integer", "null"], "minimum": 100, "maximum": 599 } }
|
|
36
|
+
},
|
|
37
|
+
"region": { "type": ["string", "null"] },
|
|
38
|
+
"collector": { "type": "string", "minLength": 1 },
|
|
39
|
+
"stages": { "type": "array", "uniqueItems": true, "items": { "type": "string", "enum": ["declared", "synthetically_observed", "range_matched", "dns_verified", "edge_observed", "origin_observed", "fully_verified", "contradictory", "insufficient_evidence"] } },
|
|
40
|
+
"verification_status": { "type": "string", "enum": ["declared", "synthetically_observed", "range_matched", "dns_verified", "edge_observed", "origin_observed", "fully_verified", "contradictory", "insufficient_evidence"] }
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "citable://schemas/evidence-authority.schema.json",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
|
+
"title": "Multidimensional evidence authority",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"required": ["source_authority", "collection_authority", "authenticity_status", "representativeness"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"source_authority": { "type": "string", "enum": ["provider_published", "standards_body", "owner_controlled", "independently_controlled", "third_party_commercial", "synthetic", "inferred", "unknown"] },
|
|
10
|
+
"collection_authority": { "type": "string", "enum": ["direct_api", "production_log", "browser_capture", "owner_export", "third_party_export", "manual_entry", "model_generated_inference", "static_analysis", "synthetic_probe"] },
|
|
11
|
+
"authenticity_status": { "type": "string", "enum": ["cryptographically_authenticated", "provider_range_verified", "owner_attested", "transport_authenticated", "checksum_protected_only", "unverified"] },
|
|
12
|
+
"representativeness": { "type": "string", "enum": ["production_population", "complete_export", "statistically_sampled", "controlled_experiment", "convenience_sample", "single_observation", "unknown"] },
|
|
13
|
+
"limitations": { "type": "array", "items": { "type": "string", "minLength": 1 } }
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"required": ["observation_id", "kind", "state", "collected_at", "collection_method", "confidence", "source", "evidence_hash", "data"],
|
|
8
8
|
"properties": {
|
|
9
9
|
"observation_id": { "type": "string", "minLength": 1 },
|
|
10
|
-
"kind": { "type": "string", "enum": ["render", "index", "citation", "citation_review", "crawler_log", "passage", "canonical_freshness", "performance", "corroboration", "metric"] },
|
|
10
|
+
"kind": { "type": "string", "enum": ["render", "index", "citation", "citation_review", "crawler_log", "bing_webmaster", "passage", "canonical_freshness", "performance", "corroboration", "metric"] },
|
|
11
11
|
"state": { "type": "string", "enum": ["observed", "not_observed", "not_evidenced", "incomplete", "review_required", "failed"] },
|
|
12
12
|
"collected_at": { "type": "string", "format": "date-time" },
|
|
13
13
|
"collection_method": { "type": "string", "enum": ["live_api", "browser", "owner_import", "synthetic_fetch", "static_analysis", "human_review"] },
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"source": { "type": "string", "minLength": 1 },
|
|
16
16
|
"evidence_hash": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
|
|
17
17
|
"data": { "type": "object" },
|
|
18
|
-
"limitations": { "type": "array", "items": { "type": "string" } }
|
|
18
|
+
"limitations": { "type": "array", "items": { "type": "string" } },
|
|
19
|
+
"authority": { "$ref": "citable://schemas/evidence-authority.schema.json" }
|
|
19
20
|
}
|
|
20
21
|
}
|
package/skill/SKILL.md
CHANGED
|
@@ -7,12 +7,16 @@ description: >
|
|
|
7
7
|
generative engine optimization, structured data governance, claim substantiation,
|
|
8
8
|
crawler policy, entity consistency, content discoverability, or wants a site audited
|
|
9
9
|
for how search and AI systems will retrieve, understand, cite, or recommend it.
|
|
10
|
-
version: 1.
|
|
10
|
+
version: 1.7.0
|
|
11
11
|
---
|
|
12
12
|
|
|
13
|
-
# Citable — search
|
|
13
|
+
# Citable — evidence and change control for search and AI citation readiness
|
|
14
14
|
|
|
15
15
|
Citable is an operational quality and governance layer, not a content generator.
|
|
16
|
+
It records what a property makes technically available, what its content can
|
|
17
|
+
support, and what external systems have actually been observed doing. It does
|
|
18
|
+
not score visibility; it establishes what is eligible, supportable, observed,
|
|
19
|
+
changed, and still unknown.
|
|
16
20
|
It treats discoverability as an engineering system: registries as the source of
|
|
17
21
|
truth, deterministic detectors for observable conditions, rubrics for semantic
|
|
18
22
|
judgment, evidence packages for every run, and fail-closed behaviour wherever a
|
|
@@ -70,6 +74,11 @@ Within retrieval, distinguish `allowed_by_policy`, `synthetic_fetch_succeeded`,
|
|
|
70
74
|
citation testing, distinguish mention, citation, material support, canonical
|
|
71
75
|
source selection, and recommendation. These states are not interchangeable.
|
|
72
76
|
|
|
77
|
+
Evidence preservation, authority, authenticity, collection method, and
|
|
78
|
+
representativeness are also independent. Follow
|
|
79
|
+
`references/evidence-authority.md`; a checksum or CIDR match alone never proves
|
|
80
|
+
source authenticity, complete coverage, or verified crawler identity.
|
|
81
|
+
|
|
73
82
|
## Tooling
|
|
74
83
|
|
|
75
84
|
The `citable` CLI in this repository performs the deterministic work. Always
|
|
@@ -86,9 +95,16 @@ citable validate [registries|claims|evidence|schema|links]
|
|
|
86
95
|
citable compare-snapshots [runA runB]
|
|
87
96
|
citable action-plan [run-id] # ordered actions, blockers, semantic gates, verification
|
|
88
97
|
citable observe <mode> [options] # render/index/citation/log/passage/consensus/performance evidence
|
|
98
|
+
citable observe bing --dataset <search_performance|ai_performance> --input <csv|json>
|
|
89
99
|
citable apply --input <spec> [--write] # reviewed, hash-locked remediation; dry run by default
|
|
90
100
|
citable monitor [runA runB] # observation regression alerts
|
|
91
101
|
citable metrics import --provider <name> --input <csv|json>
|
|
102
|
+
citable connect status
|
|
103
|
+
citable connect configure --provider <gsc|ga4> --connection-id <id> --property-id <id> [--credential-env <name>] [--write]
|
|
104
|
+
citable connect discover --provider <gsc|ga4>
|
|
105
|
+
citable connect validate --connection-id <id>
|
|
106
|
+
citable connect sync --connection-id <id> --start-date YYYY-MM-DD --end-date YYYY-MM-DD
|
|
107
|
+
citable connect disconnect --connection-id <id> [--write]
|
|
92
108
|
citable objectives init --input <json|yaml> [--write]
|
|
93
109
|
citable objectives validate
|
|
94
110
|
citable evaluate [objective-id] [--ref-date YYYY-MM-DD]
|
|
@@ -10,7 +10,7 @@ imports, and a disclosed custom citation-adapter protocol. It does not claim
|
|
|
10
10
|
Bing AI Performance automation or equivalence between an API adapter and a
|
|
11
11
|
consumer answer product. Preserve collector and product mode on every result.
|
|
12
12
|
|
|
13
|
-
# implemented metric and objective workflow
|
|
13
|
+
# implemented metric, connector, and objective workflow
|
|
14
14
|
|
|
15
15
|
`citable metrics import --provider <name> --input <csv|json>` validates every
|
|
16
16
|
row against a declared entry in `metrics.yaml` and writes immutable metric
|
|
@@ -27,6 +27,21 @@ absence of provider credentials is `not_configured`, not a finding and not
|
|
|
27
27
|
evidence of zero activity. Credentials must never enter registries or evidence
|
|
28
28
|
packages.
|
|
29
29
|
|
|
30
|
+
Live GSC and GA4 connections are explicitly optional. Configure only a
|
|
31
|
+
property identifier and the name of the environment variable that holds its
|
|
32
|
+
OAuth token; never place the token itself in `.citable/connections.yaml`.
|
|
33
|
+
`citable connect configure` and `disconnect` are dry runs unless `--write` is
|
|
34
|
+
used. `connect discover`, `validate`, and `sync` require read-only provider
|
|
35
|
+
authorization. `sync` writes declared metric observations with provider
|
|
36
|
+
limitations and advances a non-secret cursor. Provider errors are recorded as
|
|
37
|
+
connection state, not converted into zero observations or audit findings.
|
|
38
|
+
|
|
39
|
+
The GSC adapter collects final Search Analytics rows and inherits Search
|
|
40
|
+
Console aggregation, privacy filtering, and top-row availability limits. The GA4 adapter collects Data API
|
|
41
|
+
rows restricted to the `Organic Search` default channel group and inherits the
|
|
42
|
+
property's reporting identity, thresholding, attribution, and consent choices.
|
|
43
|
+
Neither source establishes that an intervention caused an observed change.
|
|
44
|
+
|
|
30
45
|
# measure seo
|
|
31
46
|
Inputs the operator exports (Search Console/Bing/analytics CSV or JSON).
|
|
32
47
|
Workflow: validate segmentation (brand vs non-brand, intent, page type,
|
|
@@ -55,6 +70,21 @@ agent × URL × status; flag 403/429/5xx concentrations against declared-allow
|
|
|
55
70
|
crawlers; note that user-agent strings are spoofable and IP validation is the
|
|
56
71
|
confirmation step (crawler registry ip_validation_method). Compare observed
|
|
57
72
|
access against `crawlers.yaml` decisions (CRAWL-001 logic applied to logs).
|
|
73
|
+
Normalize JSON or CSV edge/origin events into the crawler identity contract.
|
|
74
|
+
Do not label CIDR membership alone verified: preserve range-source provenance,
|
|
75
|
+
DNS, edge, origin, region, collector, stages, and contradiction state.
|
|
76
|
+
Remove credentials, cookies, secrets, and unnecessary personal data before
|
|
77
|
+
import. Citable rejects common sensitive field names but cannot establish that
|
|
78
|
+
arbitrary URL or query values are lawful or appropriately minimized.
|
|
79
|
+
|
|
80
|
+
# Bing owner observations
|
|
81
|
+
|
|
82
|
+
Use `citable observe bing --dataset search_performance|ai_performance --input
|
|
83
|
+
<csv|json>`. This release normalizes owner exports because no supported Bing AI
|
|
84
|
+
Performance API contract has been captured. Citation counts do not indicate
|
|
85
|
+
ranking, authority, placement, page importance, or material support. Grounding
|
|
86
|
+
queries may be sampled. Preserve traffic-source dimensions and never infer
|
|
87
|
+
causation from a temporal change.
|
|
58
88
|
|
|
59
89
|
# monitor-contradictions
|
|
60
90
|
Compare approved entity + claim records against: owned pages (automated, via
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Evidence authority and crawler identity
|
|
2
|
+
|
|
3
|
+
An evidence checksum establishes preservation only. It does not establish that
|
|
4
|
+
the source was authentic, the collection was complete, or the observation was
|
|
5
|
+
representative. Report four axes independently on every new observation:
|
|
6
|
+
|
|
7
|
+
1. `source_authority`: provider-published, standards-body, owner-controlled,
|
|
8
|
+
independently controlled, third-party commercial, synthetic, inferred, or
|
|
9
|
+
unknown.
|
|
10
|
+
2. `collection_authority`: direct API, production log, browser capture, owner
|
|
11
|
+
export, third-party export, manual entry, model-generated inference, static
|
|
12
|
+
analysis, or synthetic probe.
|
|
13
|
+
3. `authenticity_status`: cryptographically authenticated, provider-range
|
|
14
|
+
verified, owner-attested, transport-authenticated, checksum-protected only,
|
|
15
|
+
or unverified.
|
|
16
|
+
4. `representativeness`: production population, complete export,
|
|
17
|
+
statistically sampled, controlled experiment, convenience sample, single
|
|
18
|
+
observation, or unknown.
|
|
19
|
+
|
|
20
|
+
Never convert these axes into one authority score.
|
|
21
|
+
|
|
22
|
+
## Crawler identity
|
|
23
|
+
|
|
24
|
+
Contract support and verified observations are different outcomes. The
|
|
25
|
+
`crawler-identity` schema can exist without any production event satisfying it.
|
|
26
|
+
A user-agent match is `declared`. A synthetic request is
|
|
27
|
+
`synthetically_observed`. An observed IP in an imported range is only
|
|
28
|
+
`range_matched`.
|
|
29
|
+
|
|
30
|
+
`fully_verified` requires all of:
|
|
31
|
+
|
|
32
|
+
- a provider and declared user agent;
|
|
33
|
+
- observed source IP matching the captured CIDR set;
|
|
34
|
+
- provider-published range source URL, retrieval time, captured source snapshot,
|
|
35
|
+
and valid snapshot checksum;
|
|
36
|
+
- documented forward/reverse DNS verification where applicable;
|
|
37
|
+
- an explicit edge observation and decision;
|
|
38
|
+
- a correlated origin observation and status;
|
|
39
|
+
- region and collector identity.
|
|
40
|
+
|
|
41
|
+
A failed range or DNS check, or a claimed verification without the required
|
|
42
|
+
chain, is `contradictory`. Missing links are `insufficient_evidence`. Verification
|
|
43
|
+
applies only to the captured event; it does not establish all crawler traffic.
|
package/src/cli/index.js
CHANGED
|
@@ -16,6 +16,7 @@ import { observe } from '../commands/observe.js';
|
|
|
16
16
|
import { applyRemediation } from '../commands/applyRemediation.js';
|
|
17
17
|
import { monitor } from '../commands/monitor.js';
|
|
18
18
|
import { evaluateObjective, importMetrics, initializeObjective, validateObjectives } from '../commands/measurement.js';
|
|
19
|
+
import { configureConnection, connectionStatus, discoverConnections, disconnectConnection, syncConnection, validateConnection } from '../commands/connect.js';
|
|
19
20
|
|
|
20
21
|
const HELP = `citable — SEO / AEO / GEO audit, remediation, validation, and governance
|
|
21
22
|
|
|
@@ -38,11 +39,17 @@ Commands
|
|
|
38
39
|
validate [mode] registries (default) | claims | evidence | schema | links
|
|
39
40
|
compare-snapshots [a b] Regression diff between two audit runs
|
|
40
41
|
action-plan [run] Turn audit findings into ordered remediation work
|
|
41
|
-
observe <mode> Collect render, index, citation, log, passage,
|
|
42
|
+
observe <mode> Collect render, index, citation, log, Bing, passage,
|
|
42
43
|
consensus, performance, or corroboration evidence
|
|
43
44
|
apply Apply a reviewed, hash-locked remediation spec
|
|
44
45
|
monitor [runA runB] Compare observation runs and emit regression alerts
|
|
45
46
|
metrics import Import declared metric observations from CSV/JSON
|
|
47
|
+
connect status List optional connectors and configured connections
|
|
48
|
+
connect configure Configure non-secret connection state (--write to save)
|
|
49
|
+
connect discover Discover provider properties using environment auth
|
|
50
|
+
connect validate Verify configured property access
|
|
51
|
+
connect sync Collect declared metrics into immutable observations
|
|
52
|
+
connect disconnect Remove optional connection state (--write to confirm)
|
|
46
53
|
objectives init Validate/add one objective from --input (--write to save)
|
|
47
54
|
objectives validate Validate objective contracts and metric references
|
|
48
55
|
evaluate [objective-id] Compare objective baseline and evaluation windows
|
|
@@ -54,6 +61,12 @@ Options
|
|
|
54
61
|
--ref-date <YYYY-MM-DD> Reference date for expiry/staleness checks (default: today)
|
|
55
62
|
--input <file> Import file or remediation specification
|
|
56
63
|
--provider <name> Provider label for imported observations
|
|
64
|
+
--dataset <name> Provider export dataset (for example ai_performance)
|
|
65
|
+
--connection-id <id> Connection registry identifier
|
|
66
|
+
--property-id <id> Provider property or site identifier
|
|
67
|
+
--credential-env <name> Environment variable containing the access token
|
|
68
|
+
--start-date <YYYY-MM-DD> Connector collection window start
|
|
69
|
+
--end-date <YYYY-MM-DD> Connector collection window end
|
|
57
70
|
--api-key <key> API key (prefer provider environment variables)
|
|
58
71
|
--site-url <property> Search Console property for live URL inspection
|
|
59
72
|
--access-token <token> OAuth token (prefer provider environment variables)
|
|
@@ -76,6 +89,12 @@ function parseArgs(argv) {
|
|
|
76
89
|
else if (a === '--ref-date') args.refDate = argv[++i];
|
|
77
90
|
else if (a === '--input') args.input = argv[++i];
|
|
78
91
|
else if (a === '--provider') args.provider = argv[++i];
|
|
92
|
+
else if (a === '--dataset') args.dataset = argv[++i];
|
|
93
|
+
else if (a === '--connection-id') args.connectionId = argv[++i];
|
|
94
|
+
else if (a === '--property-id') args.propertyId = argv[++i];
|
|
95
|
+
else if (a === '--credential-env') args.credentialEnv = argv[++i];
|
|
96
|
+
else if (a === '--start-date') args.startDate = argv[++i];
|
|
97
|
+
else if (a === '--end-date') args.endDate = argv[++i];
|
|
79
98
|
else if (a === '--api-key') args.apiKey = argv[++i];
|
|
80
99
|
else if (a === '--site-url') args.siteUrl = argv[++i];
|
|
81
100
|
else if (a === '--access-token') args.accessToken = argv[++i];
|
|
@@ -178,6 +197,30 @@ export async function main(argv = process.argv.slice(2), options = {}) {
|
|
|
178
197
|
out(args, `metrics import: ${r.summary.total} observation(s) from ${args.provider}\nEvidence package: ${r.dir}`, r);
|
|
179
198
|
break;
|
|
180
199
|
}
|
|
200
|
+
case 'connect': {
|
|
201
|
+
const mode = args._[0];
|
|
202
|
+
if (mode === 'status') {
|
|
203
|
+
const r = connectionStatus(root);
|
|
204
|
+
out(args, `connect status: ${r.connections.length} configured connection(s)\n` + r.available.map((item) => ` ${item.provider}: token via ${item.credential_env}`).join('\n'), r);
|
|
205
|
+
} else if (mode === 'configure') {
|
|
206
|
+
const r = configureConnection(root, args);
|
|
207
|
+
out(args, `connect configure: ${r.connection.connection_id} ${r.written ? 'written' : 'valid (dry run; use --write to save)'}`, r);
|
|
208
|
+
} else if (mode === 'discover') {
|
|
209
|
+
const r = await discoverConnections(root, args);
|
|
210
|
+
out(args, `connect discover ${r.provider}: ${r.properties.length} accessible property/properties`, r);
|
|
211
|
+
} else if (mode === 'validate') {
|
|
212
|
+
const r = await validateConnection(root, args);
|
|
213
|
+
out(args, `connect validate ${r.connection_id}: ${r.valid ? 'accessible' : 'not accessible'}`, r);
|
|
214
|
+
if (!r.valid) process.exitCode = 1;
|
|
215
|
+
} else if (mode === 'sync') {
|
|
216
|
+
const r = await syncConnection(root, args);
|
|
217
|
+
out(args, `connect sync ${r.connection_id}: ${r.summary.total} metric observation(s)\nEvidence package: ${r.dir}`, r);
|
|
218
|
+
} else if (mode === 'disconnect') {
|
|
219
|
+
const r = disconnectConnection(root, args);
|
|
220
|
+
out(args, `connect disconnect ${r.connection_id}: ${r.disconnected ? 'removed' : 'dry run; use --write to remove'}`, r);
|
|
221
|
+
} else throw new Error('usage: citable connect <status|configure|discover|validate|sync> [options]');
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
181
224
|
case 'objectives': {
|
|
182
225
|
const mode = args._[0];
|
|
183
226
|
if (mode === 'init') {
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { loadRegistries, saveRegistry } from '../registries/index.js';
|
|
2
|
+
import { envelope, observationRun } from '../observations/common.js';
|
|
3
|
+
import { getConnector, listConnectors } from '../connectors/index.js';
|
|
4
|
+
import { validateAgainst } from '../shared/schemaValidator.js';
|
|
5
|
+
|
|
6
|
+
function findConnection(root, connectionId) {
|
|
7
|
+
const loaded = loadRegistries(root);
|
|
8
|
+
if (loaded.problems.length) throw new Error(`registry validation failed: ${loaded.problems.join('; ')}`);
|
|
9
|
+
const connection = loaded.registries.connections.entries.find((item) => item.connection_id === connectionId);
|
|
10
|
+
if (!connection) throw new Error(`connection not found: ${connectionId}`);
|
|
11
|
+
return { ...loaded, connection };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function contextFor(connection, connector, options) {
|
|
15
|
+
const credentialEnv = connection.credential_env || connector.defaultCredentialEnv;
|
|
16
|
+
return { token: options.accessToken || options.env?.[credentialEnv] || process.env[credentialEnv], fetchImpl: options.fetchImpl, credentialEnv };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function connectionStatus(root) {
|
|
20
|
+
const { registries, problems } = loadRegistries(root);
|
|
21
|
+
if (problems.length) throw new Error(`registry validation failed: ${problems.join('; ')}`);
|
|
22
|
+
return { available: listConnectors(), connections: registries.connections.entries };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function configureConnection(root, { provider, connectionId, propertyId, credentialEnv, write = false }) {
|
|
26
|
+
if (!provider || !connectionId || !propertyId) throw new Error('connect configure requires --provider, --connection-id, and --property-id');
|
|
27
|
+
const connector = getConnector(provider);
|
|
28
|
+
const { registries, problems } = loadRegistries(root);
|
|
29
|
+
if (problems.length) throw new Error(`registry validation failed: ${problems.join('; ')}`);
|
|
30
|
+
const entry = { connection_id: connectionId, provider: connector.provider, property_id: String(propertyId), state: 'configured', authentication: 'environment', credential_env: credentialEnv || connector.defaultCredentialEnv, scopes: connector.readOnlyScopes, last_synchronized_at: null, cursor: null, limitations: [] };
|
|
31
|
+
const entries = registries.connections.entries.filter((item) => item.connection_id !== connectionId);
|
|
32
|
+
const candidate = { ...registries.connections, entries: [...entries, entry] };
|
|
33
|
+
const check = validateAgainst('connection.schema.json', candidate);
|
|
34
|
+
if (!check.valid) throw new Error(`connection violates contract: ${check.errors.join('; ')}`);
|
|
35
|
+
if (write) saveRegistry(root, 'connections', candidate);
|
|
36
|
+
return { connection: entry, written: write };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export async function discoverConnections(root, { provider, accessToken, env, fetchImpl } = {}) {
|
|
40
|
+
const connector = getConnector(provider);
|
|
41
|
+
const context = { token: accessToken || env?.[connector.defaultCredentialEnv] || process.env[connector.defaultCredentialEnv], fetchImpl };
|
|
42
|
+
return { provider: connector.provider, properties: await connector.discoverProperties(context), credential_env: connector.defaultCredentialEnv };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export async function validateConnection(root, { connectionId, accessToken, env, fetchImpl } = {}) {
|
|
46
|
+
const { connection } = findConnection(root, connectionId);
|
|
47
|
+
const connector = getConnector(connection.provider);
|
|
48
|
+
const result = await connector.validateConnection(connection, contextFor(connection, connector, { accessToken, env, fetchImpl }));
|
|
49
|
+
return { connection_id: connectionId, provider: connection.provider, state: result.valid ? 'configured' : 'permission_denied', ...result };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function disconnectConnection(root, { connectionId, write = false } = {}) {
|
|
53
|
+
const loaded = findConnection(root, connectionId);
|
|
54
|
+
const candidate = { ...loaded.registries.connections, entries: loaded.registries.connections.entries.filter((item) => item.connection_id !== connectionId) };
|
|
55
|
+
if (write) saveRegistry(root, 'connections', candidate);
|
|
56
|
+
return { connection_id: connectionId, disconnected: write, state: write ? 'not_configured' : loaded.connection.state };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export async function syncConnection(root, { connectionId, startDate, endDate, accessToken, env, fetchImpl } = {}) {
|
|
60
|
+
if (!startDate || !endDate) throw new Error('connect sync requires --start-date and --end-date');
|
|
61
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(startDate) || !/^\d{4}-\d{2}-\d{2}$/.test(endDate) || Number.isNaN(Date.parse(`${startDate}T00:00:00Z`)) || Number.isNaN(Date.parse(`${endDate}T00:00:00Z`))) throw new Error('connector dates must use valid YYYY-MM-DD values');
|
|
62
|
+
if (startDate > endDate) throw new Error('connector start-date must not be after end-date');
|
|
63
|
+
const loaded = findConnection(root, connectionId);
|
|
64
|
+
const connector = getConnector(loaded.connection.provider);
|
|
65
|
+
const metrics = loaded.registries.metrics.entries.filter((item) => item.provider.toLowerCase() === connector.provider && item.status !== 'deprecated');
|
|
66
|
+
if (!metrics.length) throw new Error(`no active metrics declared for provider ${connector.provider}`);
|
|
67
|
+
const supported = connector.describeMetrics();
|
|
68
|
+
const unsupported = metrics.filter((item) => !supported[item.external_name]);
|
|
69
|
+
if (unsupported.length) throw new Error(`unsupported ${connector.provider} metrics: ${unsupported.map((item) => item.external_name).join(', ')}`);
|
|
70
|
+
let result;
|
|
71
|
+
try {
|
|
72
|
+
result = await connector.sync(loaded.connection, metrics, { startDate, endDate, ...contextFor(loaded.connection, connector, { accessToken, env, fetchImpl }) });
|
|
73
|
+
} catch (error) {
|
|
74
|
+
if (error.connectorState) {
|
|
75
|
+
const failed = { ...loaded.registries.connections, entries: loaded.registries.connections.entries.map((item) => item.connection_id === connectionId ? { ...item, state: error.connectorState, limitations: [`${connector.provider} synchronization did not complete; inspect command output and provider access.`] } : item) };
|
|
76
|
+
saveRegistry(root, 'connections', failed);
|
|
77
|
+
}
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
const observations = result.rows.map((row) => envelope('metric', {
|
|
81
|
+
metric_id: row.metric.metric_id, provider: connector.provider, external_name: row.metric.external_name,
|
|
82
|
+
value: Number(row.value), unit: row.metric.unit === 'custom' ? row.metric.custom_unit : row.metric.unit,
|
|
83
|
+
aggregation: row.metric.aggregation, observed_at: row.observed_at, period_start: row.observed_at,
|
|
84
|
+
period_end: row.observed_at, dimensions: row.dimensions,
|
|
85
|
+
}, { method: 'live_api', source: connector.provider, limitations: [...row.metric.limitations, ...result.limitations] }));
|
|
86
|
+
const run = observationRun(root, 'connect sync', loaded.connection.property_id, observations);
|
|
87
|
+
const updated = { ...loaded.registries.connections, entries: loaded.registries.connections.entries.map((item) => item.connection_id === connectionId ? { ...item, state: 'synchronized', last_synchronized_at: new Date().toISOString(), cursor: result.cursor, limitations: result.limitations } : item) };
|
|
88
|
+
saveRegistry(root, 'connections', updated);
|
|
89
|
+
return { ...run, connection_id: connectionId, provider: connector.provider };
|
|
90
|
+
}
|
package/src/commands/observe.js
CHANGED
|
@@ -2,10 +2,15 @@ import { buildContext } from './context.js';
|
|
|
2
2
|
import { envelope, observationRun, readInput } from '../observations/common.js';
|
|
3
3
|
import { sha256 } from '../shared/io.js';
|
|
4
4
|
import { fetchUrl } from '../crawler/fetch.js';
|
|
5
|
-
import
|
|
5
|
+
import fs from 'node:fs';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { parse as parseCsv } from 'csv-parse/sync';
|
|
8
|
+
import { crawlerIdentity } from '../observations/crawlerIdentity.js';
|
|
9
|
+
import { validateAgainst } from '../shared/schemaValidator.js';
|
|
6
10
|
|
|
7
11
|
const originOf = (value) => { try { return new URL(value).origin; } catch { return null; } };
|
|
8
12
|
const words = (text) => String(text || '').trim().split(/\s+/).filter(Boolean);
|
|
13
|
+
const strictDate = (value) => /^\d{4}-\d{2}-\d{2}$/.test(value || '') && new Date(`${value}T00:00:00Z`).toISOString().slice(0, 10) === value;
|
|
9
14
|
|
|
10
15
|
function canonicalReview(raw, targetOrigin) {
|
|
11
16
|
const citations = raw.citations || [];
|
|
@@ -125,32 +130,85 @@ async function observeCitations(root, options) {
|
|
|
125
130
|
}
|
|
126
131
|
|
|
127
132
|
function observeLogs(root, options) {
|
|
128
|
-
|
|
129
|
-
const
|
|
130
|
-
const
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
133
|
+
if (!options.input || !fs.existsSync(options.input)) throw new Error('logs requires --input <json|csv>');
|
|
134
|
+
const raw = fs.readFileSync(options.input, 'utf8'), ext = path.extname(options.input).toLowerCase();
|
|
135
|
+
const value = ext === '.csv' ? { requests: parseCsv(raw, { columns: true, skip_empty_lines: true, trim: true }) } : JSON.parse(raw);
|
|
136
|
+
const input = { raw, value, file: path.resolve(options.input) };
|
|
137
|
+
const rows = (Array.isArray(value) ? value : value.requests || []).map((row) => ({
|
|
138
|
+
...row,
|
|
139
|
+
timestamp: row.timestamp || row.datetime || row.date,
|
|
140
|
+
url: row.url || row.request_url || row['cs-uri-stem'],
|
|
141
|
+
user_agent: row.user_agent || row.userAgent || row['cs(User-Agent)'],
|
|
142
|
+
source_ip: row.source_ip || row.clientIP || row['c-ip'],
|
|
143
|
+
status: Number(row.status || row.status_code || row['sc-status']),
|
|
144
|
+
bytes: row.bytes == null ? null : Number(row.bytes),
|
|
145
|
+
latency_ms: row.latency_ms == null ? null : Number(row.latency_ms),
|
|
146
|
+
edge_observed: row.edge_observed === true || row.edge_observed === 'true',
|
|
147
|
+
origin_observed: row.origin_observed === true || row.origin_observed === 'true',
|
|
148
|
+
origin_status: row.origin_status == null || row.origin_status === '' ? null : Number(row.origin_status),
|
|
149
|
+
claimed_verified: row.claimed_verified === true || row.claimed_verified === 'true',
|
|
150
|
+
}));
|
|
151
|
+
const sensitive = (Array.isArray(value) ? value : value.requests || []).flatMap((row) => Object.keys(row).filter((key) => /(^|[-_])(authorization|cookie|set-cookie|access[-_]?token|refresh[-_]?token|api[-_]?key|password|secret)($|[-_])/i.test(key)));
|
|
152
|
+
if (sensitive.length) throw new Error(`log import contains sensitive fields that must be removed before collection: ${[...new Set(sensitive)].join(', ')}`);
|
|
153
|
+
const ranges = value.provider_ranges || {}, rangeSources = value.range_sources || {}, metadata = value.metadata || {};
|
|
144
154
|
const observations = rows.map((row) => {
|
|
145
|
-
|
|
155
|
+
if (!row.timestamp || Number.isNaN(Date.parse(row.timestamp)) || !row.url || !row.user_agent || !Number.isInteger(row.status)) throw new Error('each log row requires valid timestamp, url, user_agent, and integer status');
|
|
156
|
+
const identity = crawlerIdentity(row, { ranges, rangeSources, collector: metadata.collector || 'owner_import' });
|
|
157
|
+
const fullyVerified = identity.verification_status === 'fully_verified';
|
|
146
158
|
return envelope('crawler_log', {
|
|
147
159
|
timestamp: row.timestamp, url: row.url, user_agent: row.user_agent, source_ip: row.source_ip,
|
|
148
160
|
status: row.status, bytes: row.bytes ?? null, latency_ms: row.latency_ms ?? null,
|
|
149
161
|
cache_status: row.cache_status ?? null, region: row.region ?? null,
|
|
150
|
-
|
|
151
|
-
}, { method: 'owner_import', source: input.file, raw: JSON.stringify(row), confidence:
|
|
162
|
+
crawler_identity: identity,
|
|
163
|
+
}, { method: 'owner_import', source: input.file, raw: JSON.stringify(row), confidence: fullyVerified ? 'confirmed' : identity.verification_status === 'contradictory' ? 'high' : 'low',
|
|
164
|
+
authority: { collection_authority: 'production_log', authenticity_status: fullyVerified ? 'provider_range_verified' : 'checksum_protected_only', representativeness: metadata.representativeness || 'unknown' },
|
|
165
|
+
limitations: fullyVerified ? ['Verification applies only to this imported production event and captured verification chain.'] : ['The crawler identity chain is incomplete or contradictory; user agent and CIDR matching alone are insufficient.'] });
|
|
166
|
+
});
|
|
167
|
+
return observationRun(root, 'observe logs', input.file, observations, { rawInputs: { server_logs: input.raw }, incomplete: observations.some((o) => o.data.crawler_identity.verification_status !== 'fully_verified') ? ['Some crawler identities are not fully verified.'] : [] });
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function observeBing(root, options) {
|
|
171
|
+
if (!options.input || !fs.existsSync(options.input)) throw new Error('bing requires --input <json|csv> --dataset <search_performance|ai_performance>');
|
|
172
|
+
if (!['search_performance', 'ai_performance'].includes(options.dataset)) throw new Error('bing dataset must be search_performance or ai_performance');
|
|
173
|
+
const raw = fs.readFileSync(options.input, 'utf8'), ext = path.extname(options.input).toLowerCase();
|
|
174
|
+
const value = ext === '.csv' ? parseCsv(raw, { columns: true, skip_empty_lines: true, trim: true }) : JSON.parse(raw);
|
|
175
|
+
const document = Array.isArray(value) ? { rows: value } : value;
|
|
176
|
+
const rows = document.rows || document.items || [];
|
|
177
|
+
if (!rows.length) throw new Error('Bing owner export contains no rows');
|
|
178
|
+
const numeric = (row, ...names) => {
|
|
179
|
+
const rawValue = names.map((name) => row[name]).find((item) => item !== '' && item != null);
|
|
180
|
+
if (rawValue == null) return null;
|
|
181
|
+
const result = Number(String(rawValue).replace(/%$/, ''));
|
|
182
|
+
if (!Number.isFinite(result)) throw new Error(`Bing metric ${names[0]} must be numeric`);
|
|
183
|
+
return String(rawValue).endsWith('%') ? result / 100 : result;
|
|
184
|
+
};
|
|
185
|
+
const observations = rows.map((row) => {
|
|
186
|
+
const date = row.date || row.Date;
|
|
187
|
+
if (!strictDate(date)) throw new Error('each Bing row requires a valid date in YYYY-MM-DD format');
|
|
188
|
+
const metrics = options.dataset === 'ai_performance' ? {
|
|
189
|
+
total_citations: numeric(row, 'total_citations', 'Total Citations', 'citations'),
|
|
190
|
+
average_cited_pages: numeric(row, 'average_cited_pages', 'Average Cited Pages'),
|
|
191
|
+
} : {
|
|
192
|
+
clicks: numeric(row, 'clicks', 'Clicks'), impressions: numeric(row, 'impressions', 'Impressions'),
|
|
193
|
+
ctr: numeric(row, 'ctr', 'CTR', 'Average CTR'), position: numeric(row, 'position', 'Average Position'),
|
|
194
|
+
crawl_requests: numeric(row, 'crawl_requests', 'Crawl Requests'), crawl_errors: numeric(row, 'crawl_errors', 'Crawl Errors'),
|
|
195
|
+
indexed_pages: numeric(row, 'indexed_pages', 'Indexed Pages'),
|
|
196
|
+
};
|
|
197
|
+
const boundaries = options.dataset === 'ai_performance'
|
|
198
|
+
? ['Citation counts do not indicate ranking, authority, placement, page importance, or material support.', 'Grounding queries are sampled and the dashboard aggregates supported Microsoft AI surfaces.']
|
|
199
|
+
: ['Bing search performance can combine traffic sources; source dimensions must be preserved.', 'Observed performance does not establish that an intervention caused a change.'];
|
|
200
|
+
if (!Object.values(metrics).some((value) => value != null)) throw new Error(`Bing ${options.dataset} row contains no recognized metrics`);
|
|
201
|
+
const data = {
|
|
202
|
+
dataset: options.dataset, date, url: row.url || row.URL || row.page || null, metrics,
|
|
203
|
+
dimensions: { query: row.query || row.Query || null, grounding_query: row.grounding_query || row['Grounding Query'] || null, source: row.source || row.Source || null, country: row.country || row.Country || null, device: row.device || row.Device || null },
|
|
204
|
+
interpretation_boundary: boundaries,
|
|
205
|
+
};
|
|
206
|
+
const check = validateAgainst('bing-webmaster.schema.json', data);
|
|
207
|
+
if (!check.valid) throw new Error(`Bing observation violates contract: ${check.errors.join('; ')}`);
|
|
208
|
+
return envelope('bing_webmaster', data, { method: 'owner_import', source: path.resolve(options.input), raw: JSON.stringify(row),
|
|
209
|
+
authority: { representativeness: document.metadata?.representativeness || 'unknown' }, limitations: boundaries });
|
|
152
210
|
});
|
|
153
|
-
return observationRun(root, 'observe
|
|
211
|
+
return observationRun(root, 'observe bing', path.resolve(options.input), observations, { rawInputs: { bing_owner_export: raw }, warnings: ['Bing AI Performance has no supported API contract captured by this release; this evidence is an owner export.'] });
|
|
154
212
|
}
|
|
155
213
|
|
|
156
214
|
async function observePassages(root, options) {
|
|
@@ -226,10 +284,11 @@ export async function observe(root, mode, options = {}) {
|
|
|
226
284
|
case 'index': return observeIndex(root, options);
|
|
227
285
|
case 'citations': return observeCitations(root, options);
|
|
228
286
|
case 'logs': return observeLogs(root, options);
|
|
287
|
+
case 'bing': return observeBing(root, options);
|
|
229
288
|
case 'passages': return observePassages(root, options);
|
|
230
289
|
case 'consensus': return observeConsensus(root, options);
|
|
231
290
|
case 'performance': return observePerformance(root, options);
|
|
232
291
|
case 'corroboration': return observeCorroboration(root, options);
|
|
233
|
-
default: throw new Error('observe mode must be render, index, citations, logs, passages, consensus, performance, or corroboration');
|
|
292
|
+
default: throw new Error('observe mode must be render, index, citations, logs, bing, passages, consensus, performance, or corroboration');
|
|
234
293
|
}
|
|
235
294
|
}
|