terraproof 0.0.0-stage → 0.4.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/LICENSE +21 -0
- package/README.md +356 -2
- package/bin/terraproof.js +4 -0
- package/dist/router/apply.js +147 -0
- package/dist/router/classify.js +111 -0
- package/dist/router/explain.js +9 -0
- package/dist/router/index.js +272 -0
- package/dist/router/resolve.js +239 -0
- package/dist/router/score.js +60 -0
- package/dist/router/types.js +1 -0
- package/dist/router/validate.js +81 -0
- package/instructions/engineering.md +14 -0
- package/instructions/security.md +14 -0
- package/instructions/simplicity.md +13 -0
- package/package.json +65 -4
- package/routing/DOMAIN_ROUTING.md +161 -0
- package/routing/ROUTER_DESIGN.md +173 -0
- package/routing/SKILL_MANIFEST.md +86 -0
- package/routing/checks.json +121 -0
- package/routing/collections.json +47 -0
- package/routing/registry.json +2211 -0
- package/routing/rules.json +64 -0
- package/skills/accuracy-assessment/SKILL.md +213 -0
- package/skills/accuracy-assessment/UPSTREAM.md +7 -0
- package/skills/accuracy-assessment/references/stratified-estimator.md +127 -0
- package/skills/accuracy-assessment/skill.json +103 -0
- package/skills/brainstorming/SKILL.md +250 -0
- package/skills/brainstorming/UPSTREAM.md +29 -0
- package/skills/brainstorming/scripts/frame-template.html +213 -0
- package/skills/brainstorming/scripts/helper.js +167 -0
- package/skills/brainstorming/scripts/server.cjs +723 -0
- package/skills/brainstorming/scripts/start-server.sh +209 -0
- package/skills/brainstorming/scripts/stop-server.sh +120 -0
- package/skills/brainstorming/skill.json +73 -0
- package/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
- package/skills/brainstorming/visual-companion.md +299 -0
- package/skills/crs-and-units/SKILL.md +200 -0
- package/skills/crs-and-units/UPSTREAM.md +7 -0
- package/skills/crs-and-units/skill.json +74 -0
- package/skills/design-postgis-tables/SKILL.md +494 -0
- package/skills/design-postgis-tables/UPSTREAM.md +21 -0
- package/skills/design-postgis-tables/skill.json +90 -0
- package/skills/gdal/SKILL.md +125 -0
- package/skills/gdal/UPSTREAM.md +22 -0
- package/skills/gdal/references/gdal-recipes.md +103 -0
- package/skills/gdal/skill.json +66 -0
- package/skills/geomaster/README.md +105 -0
- package/skills/geomaster/SKILL.md +366 -0
- package/skills/geomaster/UPSTREAM.md +21 -0
- package/skills/geomaster/references/advanced-gis.md +376 -0
- package/skills/geomaster/references/big-data.md +363 -0
- package/skills/geomaster/references/code-examples.md +531 -0
- package/skills/geomaster/references/coordinate-systems.md +364 -0
- package/skills/geomaster/references/core-libraries.md +273 -0
- package/skills/geomaster/references/data-sources.md +330 -0
- package/skills/geomaster/references/gis-software.md +369 -0
- package/skills/geomaster/references/industry-applications.md +420 -0
- package/skills/geomaster/references/machine-learning.md +462 -0
- package/skills/geomaster/references/programming-languages.md +456 -0
- package/skills/geomaster/references/remote-sensing.md +370 -0
- package/skills/geomaster/references/scientific-domains.md +416 -0
- package/skills/geomaster/references/specialized-topics.md +428 -0
- package/skills/geomaster/references/troubleshooting.md +439 -0
- package/skills/geomaster/skill.json +157 -0
- package/skills/geopandas/SKILL.md +250 -0
- package/skills/geopandas/UPSTREAM.md +22 -0
- package/skills/geopandas/references/crs-management.md +231 -0
- package/skills/geopandas/references/data-io.md +323 -0
- package/skills/geopandas/references/data-structures.md +207 -0
- package/skills/geopandas/references/geometric-operations.md +262 -0
- package/skills/geopandas/references/spatial-analysis.md +294 -0
- package/skills/geopandas/references/visualization.md +230 -0
- package/skills/geopandas/scripts/_common.py +605 -0
- package/skills/geopandas/scripts/crs_reprojection_plan.py +210 -0
- package/skills/geopandas/scripts/export_plan.py +305 -0
- package/skills/geopandas/scripts/geometry_validity_report.py +227 -0
- package/skills/geopandas/scripts/sensitive_coordinates_checklist.py +230 -0
- package/skills/geopandas/scripts/spatial_join_audit.py +368 -0
- package/skills/geopandas/scripts/vector_inventory.py +140 -0
- package/skills/geopandas/skill.json +116 -0
- package/skills/geoparquet-validation/SKILL.md +125 -0
- package/skills/geoparquet-validation/UPSTREAM.md +24 -0
- package/skills/geoparquet-validation/references/distribution-best-practices.md +118 -0
- package/skills/geoparquet-validation/references/gpio-commands.md +264 -0
- package/skills/geoparquet-validation/references/tool-comparison.md +155 -0
- package/skills/geoparquet-validation/skill.json +71 -0
- package/skills/geospatial-data-discovery/SKILL.md +49 -0
- package/skills/geospatial-data-discovery/UPSTREAM.md +15 -0
- package/skills/geospatial-data-discovery/skill.json +51 -0
- package/skills/geospatial-frontend/SKILL.md +86 -0
- package/skills/geospatial-frontend/UPSTREAM.md +23 -0
- package/skills/geospatial-frontend/references/design-system.md +283 -0
- package/skills/geospatial-frontend/references/user-preferences.md +96 -0
- package/skills/geospatial-frontend/skill.json +87 -0
- package/skills/geozarr/SKILL.md +244 -0
- package/skills/geozarr/UPSTREAM.md +21 -0
- package/skills/geozarr/skill.json +97 -0
- package/skills/networkx/SKILL.md +440 -0
- package/skills/networkx/UPSTREAM.md +22 -0
- package/skills/networkx/references/algorithms.md +384 -0
- package/skills/networkx/references/generators.md +385 -0
- package/skills/networkx/references/graph-basics.md +284 -0
- package/skills/networkx/references/io.md +457 -0
- package/skills/networkx/references/visualization.md +531 -0
- package/skills/networkx/skill.json +93 -0
- package/skills/raster-processing/SKILL.md +222 -0
- package/skills/raster-processing/UPSTREAM.md +7 -0
- package/skills/raster-processing/skill.json +81 -0
- package/skills/sar-basics/SKILL.md +202 -0
- package/skills/sar-basics/UPSTREAM.md +7 -0
- package/skills/sar-basics/references/calibration-lut.md +98 -0
- package/skills/sar-basics/skill.json +97 -0
- package/skills/satellite-preprocessing/SKILL.md +241 -0
- package/skills/satellite-preprocessing/UPSTREAM.md +7 -0
- package/skills/satellite-preprocessing/skill.json +84 -0
- package/skills/scientific-visualization/SKILL.md +285 -0
- package/skills/scientific-visualization/UPSTREAM.md +25 -0
- package/skills/scientific-visualization/assets/color_palettes.py +263 -0
- package/skills/scientific-visualization/assets/nature.mplstyle +68 -0
- package/skills/scientific-visualization/assets/presentation.mplstyle +68 -0
- package/skills/scientific-visualization/assets/publication.mplstyle +77 -0
- package/skills/scientific-visualization/assets/publisher_profiles.json +269 -0
- package/skills/scientific-visualization/references/color_palettes.md +227 -0
- package/skills/scientific-visualization/references/journal_requirements.md +169 -0
- package/skills/scientific-visualization/references/matplotlib_examples.md +336 -0
- package/skills/scientific-visualization/references/publication_guidelines.md +196 -0
- package/skills/scientific-visualization/references/sources.md +76 -0
- package/skills/scientific-visualization/scripts/_common.py +136 -0
- package/skills/scientific-visualization/scripts/export_plan.py +493 -0
- package/skills/scientific-visualization/scripts/figure_export.py +642 -0
- package/skills/scientific-visualization/scripts/image_metadata.py +731 -0
- package/skills/scientific-visualization/scripts/palette_audit.py +327 -0
- package/skills/scientific-visualization/scripts/style_presets.py +501 -0
- package/skills/scientific-visualization/scripts/style_preview.py +232 -0
- package/skills/scientific-visualization/skill.json +95 -0
- package/skills/spectral-indices/SKILL.md +235 -0
- package/skills/spectral-indices/UPSTREAM.md +7 -0
- package/skills/spectral-indices/skill.json +88 -0
- package/skills/stac-and-cloud-access/SKILL.md +209 -0
- package/skills/stac-and-cloud-access/UPSTREAM.md +7 -0
- package/skills/stac-and-cloud-access/references/run-manifest.md +94 -0
- package/skills/stac-and-cloud-access/skill.json +98 -0
- package/skills/statistical-analysis/SKILL.md +446 -0
- package/skills/statistical-analysis/UPSTREAM.md +24 -0
- package/skills/statistical-analysis/references/assumptions_and_diagnostics.md +379 -0
- package/skills/statistical-analysis/references/bayesian_statistics.md +686 -0
- package/skills/statistical-analysis/references/effect_sizes_and_power.md +649 -0
- package/skills/statistical-analysis/references/reporting_standards.md +482 -0
- package/skills/statistical-analysis/references/test_selection_guide.md +129 -0
- package/skills/statistical-analysis/scripts/assumption_checks.py +652 -0
- package/skills/statistical-analysis/skill.json +127 -0
- package/skills/systematic-debugging/SKILL.md +283 -0
- package/skills/systematic-debugging/UPSTREAM.md +28 -0
- package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
- package/skills/systematic-debugging/condition-based-waiting.md +115 -0
- package/skills/systematic-debugging/defense-in-depth.md +122 -0
- package/skills/systematic-debugging/find-polluter.sh +72 -0
- package/skills/systematic-debugging/root-cause-tracing.md +169 -0
- package/skills/systematic-debugging/skill.json +88 -0
- package/skills/time-series-and-change/SKILL.md +217 -0
- package/skills/time-series-and-change/UPSTREAM.md +7 -0
- package/skills/time-series-and-change/references/change-methods.md +42 -0
- package/skills/time-series-and-change/skill.json +116 -0
- package/skills/vector-quality/SKILL.md +204 -0
- package/skills/vector-quality/UPSTREAM.md +7 -0
- package/skills/vector-quality/skill.json +82 -0
- package/skills/verification/SKILL.md +120 -0
- package/skills/verification/UPSTREAM.md +31 -0
- package/skills/verification/skill.json +67 -0
- package/skills/writing-plans/SKILL.md +171 -0
- package/skills/writing-plans/UPSTREAM.md +23 -0
- package/skills/writing-plans/plan-document-reviewer-prompt.md +49 -0
- package/skills/writing-plans/skill.json +80 -0
- package/sources/SOURCES.md +374 -0
- package/third_party/isaaccorley-geospatial-skills/LICENSE +176 -0
- package/third_party/isaaccorley-geospatial-skills/NOTICE.md +17 -0
- package/third_party/kdense-scientific-agent-skills/LICENSE +21 -0
- package/third_party/kdense-scientific-agent-skills/NOTICE.md +19 -0
- package/third_party/superpowers/LICENSE +21 -0
- package/third_party/superpowers/NOTICE.md +17 -0
- package/third_party/timescale-pg-aiguide/LICENSE +176 -0
- package/third_party/timescale-pg-aiguide/NOTICE.md +14 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export function scoreSkill(skill, classification, options, rules) {
|
|
2
|
+
let score = 0;
|
|
3
|
+
const reasons = [];
|
|
4
|
+
const promptLower = classification.rawPrompt.toLowerCase();
|
|
5
|
+
// 1. Explicit manual overrides
|
|
6
|
+
if (options.include && options.include.includes(skill.name)) {
|
|
7
|
+
score += rules.weights.explicitInclusion;
|
|
8
|
+
reasons.push("Explicitly included by user override (+20)");
|
|
9
|
+
}
|
|
10
|
+
if (options.exclude && options.exclude.includes(skill.name)) {
|
|
11
|
+
score += rules.weights.explicitExclusion;
|
|
12
|
+
reasons.push("Explicitly excluded by user override (-50)");
|
|
13
|
+
return { name: skill.name, layer: skill.layer, score, reasons };
|
|
14
|
+
}
|
|
15
|
+
// 2. Technology exact match (+5)
|
|
16
|
+
for (const tech of classification.technologies) {
|
|
17
|
+
if (skill.name.toLowerCase().includes(tech) || skill.triggers.some((t) => t.toLowerCase() === tech)) {
|
|
18
|
+
score += rules.weights.technologyExactMatch;
|
|
19
|
+
reasons.push(`Explicit technology match: ${tech} (+5)`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
// 3. Capability matches (+4)
|
|
23
|
+
for (const cap of classification.capabilities) {
|
|
24
|
+
if (skill.capabilities.some((sc) => sc.toLowerCase() === cap.toLowerCase() || sc.toLowerCase().includes(cap.toLowerCase()))) {
|
|
25
|
+
score += rules.weights.capabilityMatch;
|
|
26
|
+
reasons.push(`Capability match: ${cap} (+4)`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
// 4. Domain match (at most once, +3)
|
|
30
|
+
const matchedDomain = classification.domains.find((d) => skill.domains.includes(d));
|
|
31
|
+
if (matchedDomain) {
|
|
32
|
+
score += rules.weights.domainMatch;
|
|
33
|
+
reasons.push(`Domain relevance: ${matchedDomain} (+3)`);
|
|
34
|
+
}
|
|
35
|
+
// 5. Direct trigger matches in prompt with word boundaries
|
|
36
|
+
for (const trigger of skill.triggers) {
|
|
37
|
+
const triggerLower = trigger.toLowerCase().trim();
|
|
38
|
+
if (!triggerLower)
|
|
39
|
+
continue;
|
|
40
|
+
// Word-boundary matching
|
|
41
|
+
const escaped = triggerLower.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
42
|
+
const regex = new RegExp(`\\b${escaped}\\b`, "i");
|
|
43
|
+
if (regex.test(promptLower)) {
|
|
44
|
+
if (triggerLower.length > 4 || triggerLower.includes(" ")) {
|
|
45
|
+
score += rules.weights.strongTriggerMatch;
|
|
46
|
+
reasons.push(`Trigger matched: "${trigger}" (+3)`);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
score += rules.weights.weakTriggerMatch;
|
|
50
|
+
reasons.push(`Keyword matched: "${trigger}" (+1)`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
name: skill.name,
|
|
56
|
+
layer: skill.layer,
|
|
57
|
+
score,
|
|
58
|
+
reasons
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
const VALID_LAYERS = ["process", "domain", "implementation", "risk", "verification"];
|
|
4
|
+
export function validateRegistry(workspaceRoot) {
|
|
5
|
+
const errors = [];
|
|
6
|
+
const warnings = [];
|
|
7
|
+
const registryPath = path.join(workspaceRoot, "routing", "registry.json");
|
|
8
|
+
const collectionsPath = path.join(workspaceRoot, "routing", "collections.json");
|
|
9
|
+
if (!fs.existsSync(registryPath)) {
|
|
10
|
+
return { valid: false, errors: [`Missing registry.json at ${registryPath}`], warnings: [], skillsCount: 0, collectionsCount: 0 };
|
|
11
|
+
}
|
|
12
|
+
const registry = JSON.parse(fs.readFileSync(registryPath, "utf-8"));
|
|
13
|
+
const collections = fs.existsSync(collectionsPath)
|
|
14
|
+
? JSON.parse(fs.readFileSync(collectionsPath, "utf-8"))
|
|
15
|
+
: { version: "1.0.0", collections: {} };
|
|
16
|
+
const skillNames = Object.keys(registry.skills);
|
|
17
|
+
for (const [name, skill] of Object.entries(registry.skills)) {
|
|
18
|
+
// Check name consistency
|
|
19
|
+
if (skill.name !== name) {
|
|
20
|
+
errors.push(`Skill key '${name}' does not match skill.name '${skill.name}'`);
|
|
21
|
+
}
|
|
22
|
+
// Check layer
|
|
23
|
+
if (!VALID_LAYERS.includes(skill.layer)) {
|
|
24
|
+
errors.push(`Skill '${name}' has invalid layer '${skill.layer}'`);
|
|
25
|
+
}
|
|
26
|
+
// Check disk existence
|
|
27
|
+
const skillDir = path.join(workspaceRoot, skill.path);
|
|
28
|
+
if (!fs.existsSync(skillDir)) {
|
|
29
|
+
errors.push(`Skill '${name}' specified path '${skill.path}' does not exist on disk`);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
const skillMd = path.join(skillDir, "SKILL.md");
|
|
33
|
+
if (!fs.existsSync(skillMd)) {
|
|
34
|
+
errors.push(`Skill '${name}' is missing SKILL.md in '${skill.path}'`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// Ensure placeholders are not registered
|
|
38
|
+
if (name === "ai-chat" || name === "ai-tools") {
|
|
39
|
+
errors.push(`Placeholder '${name}' must not be registered in registry.json`);
|
|
40
|
+
}
|
|
41
|
+
// Every registered skill needs its own explanation; routed output reads it from the registry.
|
|
42
|
+
if (!skill.explanation || skill.explanation.trim() === "") {
|
|
43
|
+
errors.push(`Skill '${name}' has no explanation in routing/registry.json`);
|
|
44
|
+
}
|
|
45
|
+
// Warn on low trigger count
|
|
46
|
+
if (skill.triggers.length < 2) {
|
|
47
|
+
warnings.push(`Skill '${name}' has only ${skill.triggers.length} trigger(s); may under-match.`);
|
|
48
|
+
}
|
|
49
|
+
// Validate relationships
|
|
50
|
+
for (const req of skill.requires || []) {
|
|
51
|
+
if (!registry.skills[req]) {
|
|
52
|
+
errors.push(`Skill '${name}' requires unknown skill '${req}'`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
for (const rec of skill.recommended || []) {
|
|
56
|
+
if (!registry.skills[rec]) {
|
|
57
|
+
errors.push(`Skill '${name}' recommends unknown skill '${rec}'`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
for (const conf of skill.conflicts || []) {
|
|
61
|
+
if (!registry.skills[conf]) {
|
|
62
|
+
errors.push(`Skill '${name}' lists unknown conflict '${conf}'`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// Validate collections
|
|
67
|
+
for (const [cName, coll] of Object.entries(collections.collections)) {
|
|
68
|
+
for (const sName of coll.base) {
|
|
69
|
+
if (!registry.skills[sName]) {
|
|
70
|
+
errors.push(`Collection '${cName}' references unknown skill '${sName}'`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
valid: errors.length === 0,
|
|
76
|
+
errors,
|
|
77
|
+
warnings,
|
|
78
|
+
skillsCount: skillNames.length,
|
|
79
|
+
collectionsCount: Object.keys(collections.collections).length
|
|
80
|
+
};
|
|
81
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Engineering Principles
|
|
2
|
+
|
|
3
|
+
Universal engineering guidelines for code quality, maintainability, and stability.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Principles
|
|
8
|
+
|
|
9
|
+
1. **Maintainability**: Write clear, readable, and self-documenting code. Future maintainers should easily understand intent and behavior.
|
|
10
|
+
2. **Clear Naming**: Use precise, descriptive names for variables, functions, types, and files. Avoid cryptic abbreviations.
|
|
11
|
+
3. **Respect Existing Architecture**: Follow existing code conventions, folder structures, and patterns already established in the project.
|
|
12
|
+
4. **Minimal Changes**: Keep changes targeted to the requirement. Avoid touching unrelated files or making gratuitous refactorings.
|
|
13
|
+
5. **Avoid Unnecessary Dependencies**: Prefer standard libraries and existing utilities over adding external third-party dependencies.
|
|
14
|
+
6. **Explicit Error Handling**: Handle potential failure modes explicitly. Do not silently suppress errors or rely on unhandled exceptions.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Security Principles
|
|
2
|
+
|
|
3
|
+
Universal baseline security principles applicable across all engineering tasks.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Principles
|
|
8
|
+
|
|
9
|
+
1. **Secrets Management**: Never commit hardcoded API keys, tokens, credentials, or private certificates into source code or version control. Use secure environment variables or secret managers.
|
|
10
|
+
2. **Authentication**: Verify caller identities rigorously using robust, modern authentication protocols before granting access to resources.
|
|
11
|
+
3. **Authorization & Access Control**: Enforce explicit permission checks on every sensitive operation. Never assume trust based on UI state or client-side checks.
|
|
12
|
+
4. **Input Validation & Sanitization**: Treat all external input (user input, query parameters, webhook payloads, third-party responses) as untrusted. Validate types, lengths, formats, and sanitize against injection attacks (SQLi, XSS, command injection).
|
|
13
|
+
5. **Principle of Least Privilege**: Grant processes, API tokens, database connections, and users only the minimum permissions necessary to perform their specific function.
|
|
14
|
+
6. **Sensitive Data Protection**: Safeguard personally identifiable information (PII) and sensitive business data in transit (TLS) and at rest (encryption). Avoid leaking sensitive data in logs, error messages, or crash reports.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Simplicity Principles
|
|
2
|
+
|
|
3
|
+
Universal guidelines for keeping code and architecture simple, direct, and unbloated.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Principles
|
|
8
|
+
|
|
9
|
+
1. **Avoid Over-Engineering**: Build the simplest solution that completely and correctly solves the stated problem.
|
|
10
|
+
2. **Avoid Premature Abstractions**: Do not abstract until patterns emerge across concrete, existing use cases (rule of three).
|
|
11
|
+
3. **Avoid Speculative Extensibility**: Implement what is needed right now. Do not write code for hypothetical future requirements (YAGNI).
|
|
12
|
+
4. **Solve the Current Requirement First**: Focus directly on the immediate goal before contemplating generalizations.
|
|
13
|
+
5. **Prefer Understandable Code**: Prefer straightforward, explicit, and readable code over clever, terse, or overly complex implementations.
|
package/package.json
CHANGED
|
@@ -1,6 +1,67 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "terraproof",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "evidence-graded skills, tools, and checks for mapping and remote-sensing AI agents. By Geova.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/router/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./dist/router/index.js",
|
|
9
|
+
"./router": "./dist/router/index.js",
|
|
10
|
+
"./routing": "./routing/registry.json"
|
|
11
|
+
},
|
|
12
|
+
"bin": {
|
|
13
|
+
"terraproof": "bin/terraproof.js"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc -p tsconfig.build.json",
|
|
17
|
+
"prepack": "npm run build",
|
|
18
|
+
"route": "node router/index.ts route",
|
|
19
|
+
"validate": "node router/index.ts validate",
|
|
20
|
+
"registry:build": "node router/build-registry.ts",
|
|
21
|
+
"registry:check": "node router/build-registry.ts --check",
|
|
22
|
+
"test:router": "node tests/router/run.ts",
|
|
23
|
+
"test:validate": "python tests/validate_repo.py",
|
|
24
|
+
"test:package": "node tests/package/smoke.mjs",
|
|
25
|
+
"test": "node tests/router/run.ts",
|
|
26
|
+
"typecheck": "tsc --noEmit"
|
|
27
|
+
},
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/esmailhussien/terraproof.git"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/esmailhussien/terraproof#readme",
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/esmailhussien/terraproof/issues"
|
|
35
|
+
},
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=20"
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"bin",
|
|
41
|
+
"dist",
|
|
42
|
+
"routing",
|
|
43
|
+
"skills",
|
|
44
|
+
"instructions",
|
|
45
|
+
"third_party",
|
|
46
|
+
"sources",
|
|
47
|
+
"README.md",
|
|
48
|
+
"LICENSE"
|
|
49
|
+
],
|
|
50
|
+
"keywords": [
|
|
51
|
+
"ai",
|
|
52
|
+
"agent",
|
|
53
|
+
"skills",
|
|
54
|
+
"router",
|
|
55
|
+
"geospatial",
|
|
56
|
+
"gis",
|
|
57
|
+
"remote-sensing",
|
|
58
|
+
"earth-observation",
|
|
59
|
+
"mapping"
|
|
60
|
+
],
|
|
61
|
+
"author": "Terraproof Contributors",
|
|
62
|
+
"license": "MIT",
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"typescript": "^5.7.0",
|
|
65
|
+
"@types/node": "^22.0.0"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# Terraproof Domain Routing Map
|
|
2
|
+
|
|
3
|
+
> **Status:** Static architectural routing guide for Terraproof skills.
|
|
4
|
+
|
|
5
|
+
This document describes the recommended skill composition and execution pipelines for complex user tasks spanning GIS, remote sensing, spatial data analysis, and process work.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Routing Principles
|
|
10
|
+
|
|
11
|
+
1. **Instructions First:** Universal engineering rules (`instructions/`) are always loaded and persistent.
|
|
12
|
+
2. **Process & Planning:** Non-trivial tasks begin with `brainstorming` or `writing-plans`.
|
|
13
|
+
3. **Domain Wayfinding:** High-level domain skills (e.g. `geomaster`) provide conceptual grounding.
|
|
14
|
+
4. **Focused Execution:** Dedicated tool skills (e.g. `gdal`, `geopandas`, `design-postgis-tables`) provide precise implementation rules.
|
|
15
|
+
5. **Quality & Verification:** Every task concludes with `verification`.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Canonical Task Compositions
|
|
20
|
+
|
|
21
|
+
### 1. Statistical Inference & Publication Figures
|
|
22
|
+
```text
|
|
23
|
+
User Task: "Test whether two patient cohorts differ significantly and publish the comparison figure"
|
|
24
|
+
|
|
25
|
+
1. instructions/engineering.md
|
|
26
|
+
2. skills/statistical-analysis
|
|
27
|
+
→ Hypothesis selection, assumption verification, effect size calculation
|
|
28
|
+
3. skills/scientific-visualization
|
|
29
|
+
→ Generate publication-quality figures with colorblind-safe palettes
|
|
30
|
+
4. skills/verification
|
|
31
|
+
→ Review findings against raw data and truthfulness standards
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### 2. Vector GIS Analysis & Proximity Queries
|
|
35
|
+
```text
|
|
36
|
+
User Task: "Find all schools located within 1 km of primary highways"
|
|
37
|
+
|
|
38
|
+
1. skills/geospatial-data-discovery (if datasets need sourcing)
|
|
39
|
+
2. skills/geomaster (spatial reasoning, CRS selection)
|
|
40
|
+
3. skills/geopandas (GeoDataFrame loading, buffer, spatial join, geometry intersection)
|
|
41
|
+
4. skills/verification (confirm metric CRS was used for distance calculations)
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 3. Raster Processing & Cloud-Optimized GeoTIFF Conversion
|
|
45
|
+
```text
|
|
46
|
+
User Task: "Convert satellite tiles to Cloud-Optimized GeoTIFFs (COG) and reproject to Web Mercator"
|
|
47
|
+
|
|
48
|
+
1. skills/gdal
|
|
49
|
+
→ `gdalwarp` for reprojection, `gdal_translate` with `-co TILED=YES -co COPY_SRC_OVERVIEWS=YES`
|
|
50
|
+
2. skills/verification
|
|
51
|
+
→ Verify headers with `gdalinfo -json`
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 4. Spatial Database Design
|
|
55
|
+
```text
|
|
56
|
+
User Task: "Design a multi-tenant location tracking schema in PostgreSQL"
|
|
57
|
+
|
|
58
|
+
1. skills/brainstorming
|
|
59
|
+
→ Clarify scale, write throughput, and geographic scope
|
|
60
|
+
2. skills/design-postgis-tables
|
|
61
|
+
→ Geometry vs Geography selection, GiST indexing, bounding-box operators
|
|
62
|
+
3. skills/verification
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 5. Geospatial Web Map Application
|
|
66
|
+
```text
|
|
67
|
+
User Task: "Build an interactive map dashboard displaying live delivery fleets"
|
|
68
|
+
|
|
69
|
+
1. skills/brainstorming & skills/writing-plans
|
|
70
|
+
2. skills/geospatial-frontend
|
|
71
|
+
→ MapLibre GL map instance, layer styling, deck.gl data overlay
|
|
72
|
+
3. skills/verification
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 6. Spatial Network Analysis
|
|
76
|
+
```text
|
|
77
|
+
User Task: "Compute shortest emergency evacuation routes across a city road network"
|
|
78
|
+
|
|
79
|
+
1. skills/geomaster
|
|
80
|
+
→ Network topology extraction and edge weight assignment
|
|
81
|
+
2. skills/networkx
|
|
82
|
+
→ Graph construction, Dijkstra/A* path algorithms, centrality metrics
|
|
83
|
+
3. skills/geopandas
|
|
84
|
+
→ Re-project route geometries and export GeoJSON/GeoPackage
|
|
85
|
+
4. skills/verification
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Phase 4 Remote-Sensing Compositions
|
|
91
|
+
|
|
92
|
+
These four domain skills (Phase 4) cover multi-date work, SAR, map accuracy, and cloud-native data access. They compose rather than overlap: each owns one decision, and the companions supply the inputs.
|
|
93
|
+
|
|
94
|
+
### 7. Multi-Date Compositing & Change Detection
|
|
95
|
+
```text
|
|
96
|
+
User Task: "Build a monthly composite from Sentinel-2 and map forest loss 2020–2024"
|
|
97
|
+
|
|
98
|
+
1. skills/time-series-and-change
|
|
99
|
+
→ per-observation decode/mask, composite method, valid-observation counts,
|
|
100
|
+
temporal alignment, change definition, thresholded differences or BFAST/CCDC/
|
|
101
|
+
LandTrendr, and reference-validated change area
|
|
102
|
+
2. skills/satellite-preprocessing (when decoding/QA signals are also present in the prompt)
|
|
103
|
+
3. skills/accuracy-assessment (when change area or accuracy will be reported)
|
|
104
|
+
4. skills/verification
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### 8. Sentinel-1 SAR Analysis
|
|
108
|
+
```text
|
|
109
|
+
User Task: "Map flood extent from a Sentinel-1 GRD scene"
|
|
110
|
+
|
|
111
|
+
1. skills/sar-basics
|
|
112
|
+
→ GRD vs SLC, calibration LUTs to σ⁰/γ⁰/β⁰, linear power vs dB, speckle filtering,
|
|
113
|
+
terrain correction and geocoding, polarisation and incidence angle
|
|
114
|
+
2. skills/raster-processing (for grids and resampling of the corrected product)
|
|
115
|
+
3. skills/verification
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### 9. Map Accuracy & Area Estimation
|
|
119
|
+
```text
|
|
120
|
+
User Task: "Report the accuracy and forest area of my land-cover map"
|
|
121
|
+
|
|
122
|
+
1. skills/accuracy-assessment
|
|
123
|
+
→ stratified probability sampling by map class, response design, area-proportion
|
|
124
|
+
confusion matrix, overall/user's/producer's accuracy with CIs, area-adjusted areas
|
|
125
|
+
2. skills/statistical-analysis (for general inference on the sample)
|
|
126
|
+
3. skills/crs-and-units (stratum areas need true metric areas first)
|
|
127
|
+
4. skills/verification
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### 10. STAC Search & Cloud-Native Access
|
|
131
|
+
```text
|
|
132
|
+
User Task: "Search a STAC catalog and read only the window of a COG I need"
|
|
133
|
+
|
|
134
|
+
1. skills/stac-and-cloud-access
|
|
135
|
+
→ reproducible search parameters, pinned item ids, signed URLs / requester-pays,
|
|
136
|
+
/vsicurl/ windowed reads, loader scale/offset behaviour, run manifest
|
|
137
|
+
2. skills/satellite-preprocessing (decode the DN the loader did not decode)
|
|
138
|
+
3. skills/verification
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Recommended and Required Links
|
|
144
|
+
|
|
145
|
+
AGENTS.md rule 15 requires a documented reason for every `recommended` and `requires` link in a skill manifest. The resolver applies them differently. A `requires` skill is always selected. A `recommended` skill is added only if it also scores at or above the selection threshold (4), or if it is `verification`, which is always selected. A recommendation therefore never adds a skill on its own; the prompt must also contain a direct signal for that skill. No skill declares `requires` or `conflicts`. A recommended companion (for example, `satellite-preprocessing` alongside `spectral-indices`) is acceptable in any scenario and must not be listed in `mustExclude`.
|
|
146
|
+
|
|
147
|
+
| From | Type | To | Rationale |
|
|
148
|
+
|---|---|---|---|
|
|
149
|
+
| `spectral-indices` | recommended | `satellite-preprocessing` | Indices are defined on decoded, masked, calibrated surface reflectance, with scale and offset applied exactly once. `satellite-preprocessing` produces that input. |
|
|
150
|
+
| `satellite-preprocessing` | recommended | `raster-processing` | Mask application, grid harmonization, and COG delivery use the rules in `raster-processing`. |
|
|
151
|
+
| `vector-quality` | recommended | `crs-and-units` | Snapping tolerances, precision grids, and area checks are in coordinate units, so they need a reviewed metric CRS first. |
|
|
152
|
+
| `gdal`, `geomaster`, `geopandas`, `geoparquet-validation`, `geospatial-data-discovery`, `geozarr`, `networkx`, `scientific-visualization`, `statistical-analysis`, `systematic-debugging`, `writing-plans` | recommended | `verification` | Pre-existing link. `verification` is the completion audit for the skill's output, and it is always selected, so this link adds no skill. |
|
|
153
|
+
| `brainstorming` | recommended | `writing-plans` | Pre-existing link. Design options that are chosen become an execution plan. |
|
|
154
|
+
| `time-series-and-change` | recommended | `satellite-preprocessing` | A series is only analysis-ready once each observation is decoded (scale/offset exactly once) and QA-masked; `satellite-preprocessing` defines both, and the compositing rules assume them. |
|
|
155
|
+
| `time-series-and-change` | recommended | `accuracy-assessment` | Change is rare, so reported change area and accuracy need a probability sample stratified by the change classes with area-adjusted estimates; `accuracy-assessment` defines that design and estimator. |
|
|
156
|
+
| `sar-basics` | recommended | `raster-processing` | Terrain correction and geocoding produce a new grid, and multi-date stacks must share one CRS, pixel size and origin; the grid and resampling rules are in `raster-processing`. |
|
|
157
|
+
| `sar-basics` | recommended | `accuracy-assessment` | Water, flood and change thresholds derived from SAR are validated against reference data, so the same sample design and area-adjusted estimator apply. |
|
|
158
|
+
| `accuracy-assessment` | recommended | `statistical-analysis` | Confidence intervals for accuracy and area come from stratified variance estimation on the sample; general inference and effect-size tooling is in `statistical-analysis`. |
|
|
159
|
+
| `accuracy-assessment` | recommended | `crs-and-units` | Stratum areas `A_m,i` must be true areas, and `--operation area` fails on geographic/geocentric CRSs, so a reviewed metric CRS is a precondition for every area number. |
|
|
160
|
+
| `stac-and-cloud-access` | recommended | `satellite-preprocessing` | Loaders disagree on decoding: `odc.stac` returns raw DN while `stackstac` rescale-applies `raster:bands` scale/offset, so the decode-exactly-once rules must be applied after loading. |
|
|
161
|
+
| `stac-and-cloud-access` | recommended | `geospatial-data-discovery` | Catalog search answers "what imagery exists and may I use it"; `stac-and-cloud-access` then covers reproducible retrieval and provenance of the chosen items. |
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# Terraproof Smart Router — Architectural Design
|
|
2
|
+
|
|
3
|
+
The **Terraproof Smart Skill Router** is a deterministic, fast, offline, and inspectable resolution engine that maps natural language task descriptions into minimal, high-precision compositions of Terraproof skills.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Core Principles
|
|
8
|
+
|
|
9
|
+
1. **Deterministic & Fast**: Zero runtime network calls, zero LLM dependencies, zero vector database dependencies.
|
|
10
|
+
2. **Minimalist (Smallest Useful Set)**: Recommends the exact skills necessary to complete the task (typically 2–7 skills) without over-selecting entire domains.
|
|
11
|
+
3. **Layered Architecture**: Every skill is organized into a primary layer ensuring structured engineering workflows.
|
|
12
|
+
4. **Transparent & Explainable**: Every selected skill has a human-readable reason explaining its relevance to the prompt.
|
|
13
|
+
5. **Inspectable & Testable**: Backed by a deterministic scoring formula, strict schema validation, and 100% passing scenario suites.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 2. System Architecture
|
|
18
|
+
|
|
19
|
+
```text
|
|
20
|
+
Natural Language Task
|
|
21
|
+
│
|
|
22
|
+
▼
|
|
23
|
+
┌─────────────────────────────────┐
|
|
24
|
+
│ router/classify.ts │ -> Extract Intent, Domains, Tech, Capabilities, Risk Boundaries, Testing Needs
|
|
25
|
+
└────────────────┬────────────────┘
|
|
26
|
+
│
|
|
27
|
+
▼
|
|
28
|
+
┌─────────────────────────────────┐
|
|
29
|
+
│ router/score.ts │ -> Score against routing/registry.json (Tech +5, Cap +4, Domain +3, Triggers +3/+1)
|
|
30
|
+
└────────────────┬────────────────┘
|
|
31
|
+
│
|
|
32
|
+
▼
|
|
33
|
+
┌─────────────────────────────────┐
|
|
34
|
+
│ router/resolve.ts │ -> Apply Layer Policies, Intent Rules, Hard Requires, Recommendations, Exclusions
|
|
35
|
+
└────────────────┬────────────────┘
|
|
36
|
+
│
|
|
37
|
+
▼
|
|
38
|
+
┌─────────────────────────────────┐
|
|
39
|
+
│ router/explain.ts │ -> Attach Human-Readable Rationale for every selected tool
|
|
40
|
+
└────────────────┬────────────────┘
|
|
41
|
+
│
|
|
42
|
+
▼
|
|
43
|
+
┌─────────────────────────────────┐
|
|
44
|
+
│ Selected Skill Set │ -> Grouped into Process, Domain, Implementation, Risk, Verification
|
|
45
|
+
└─────────────────────────────────┘
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## 3. The 5 Routing Layers
|
|
51
|
+
|
|
52
|
+
Every production skill has exactly one primary layer:
|
|
53
|
+
|
|
54
|
+
| Layer | Purpose | Core Skills |
|
|
55
|
+
|---|---|---|
|
|
56
|
+
| **1. Process** | Engineering discipline, exploration, and structured breakdown | `brainstorming`, `writing-plans`, `systematic-debugging` |
|
|
57
|
+
| **2. Domain** | Geospatial, remote-sensing, and data domain knowledge | `gdal`, `geopandas`, `geomaster`, `geozarr`, `geoparquet-validation`, `geospatial-data-discovery`, `statistical-analysis`, `scientific-visualization`, `networkx`, `crs-and-units`, `vector-quality`, `raster-processing`, `satellite-preprocessing`, `spectral-indices`, `time-series-and-change`, `sar-basics`, `accuracy-assessment`, `stac-and-cloud-access` |
|
|
58
|
+
| **3. Implementation** | Mapping frameworks and spatial database design | `geospatial-frontend`, `design-postgis-tables` |
|
|
59
|
+
| **4. Risk** | Security, vulnerability detection, and authorization audits | *(no skills in v0.2.0)* |
|
|
60
|
+
| **5. Verification** | Truthfulness and completion validation | `verification` |
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## 4. Scoring Heuristics
|
|
65
|
+
|
|
66
|
+
Candidate skills are scored deterministically based on rule weights:
|
|
67
|
+
|
|
68
|
+
- **Technology Exact Match (+5)**: Prompt explicitly names technology (e.g. `postgis`, `gdal`, `networkx`).
|
|
69
|
+
- **Capability Match (+4)**: Prompt matches a specific engineering capability (e.g. `web-map`, `cog-conversion`, `spatial-join`, `hypothesis-testing`).
|
|
70
|
+
- **Domain Relevance (+3)**: Broad domain category alignment (e.g. `geospatial`, `data`, `frontend`, `database`, `api`).
|
|
71
|
+
- **Strong Trigger (+3)**: Exact multi-word or distinct trigger phrase match.
|
|
72
|
+
- **Weak Trigger (+1)**: Single keyword match.
|
|
73
|
+
- **Recommended Bonus (+2)**: Associated skill recommendation from a high-confidence selected skill.
|
|
74
|
+
- **Hard Dependency (+10)**: Explicit `requires` declaration.
|
|
75
|
+
- **Manual Include (+20)**: User `--include <skill>` override.
|
|
76
|
+
- **Manual Exclude (-50)**: User `--exclude <skill>` override.
|
|
77
|
+
- **Conflict Penalty (-50)**: Mutual exclusion between opposing skills.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## 5. Intent & Contextual Selection Rules
|
|
82
|
+
|
|
83
|
+
1. **New Feature Creation (`build`, `create app`, `scaffold`)**:
|
|
84
|
+
- Injects `brainstorming` and `writing-plans`.
|
|
85
|
+
2. **Bug Fixing & Diagnostics (`fix`, `bug`, `error`, `401`, `500`)**:
|
|
86
|
+
- Injects `systematic-debugging`. Suppresses heavy speculative planning.
|
|
87
|
+
3. **Trivial Edits (`button label`, `typo`, `color change`)**:
|
|
88
|
+
- Suppresses process layers. Retains only necessary minimal verification.
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## 6. CLI Usage & Overrides
|
|
93
|
+
|
|
94
|
+
### Basic Route
|
|
95
|
+
```bash
|
|
96
|
+
npx terraproof route "Build a React dashboard displaying live weather data on a map"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Dry Run (Inspect without modifying project)
|
|
100
|
+
```bash
|
|
101
|
+
npx terraproof route "Fix intermittent 401 error when loading map tiles" --dry-run
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Manual Inclusions and Exclusions
|
|
105
|
+
```bash
|
|
106
|
+
npx terraproof route "Process GeoTIFF into COG" --include gdal --exclude geomaster
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Seeding from Preset Collections
|
|
110
|
+
```bash
|
|
111
|
+
npx terraproof route "Custom GIS workflow" --collection gis
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### JSON Output
|
|
115
|
+
```bash
|
|
116
|
+
npx terraproof route "Design PostGIS schema" --format json
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## 7. Relationship to Existing Files
|
|
122
|
+
|
|
123
|
+
- **`routing/DOMAIN_ROUTING.md`**: Human-readable composition guidance and canonical architectural patterns.
|
|
124
|
+
- **`skills/<name>/skill.json`**: Routing metadata for each skill, the source of truth. To add or change a skill, add or edit its manifest, run `npm run registry:build`, and add scenarios to `tests/router/scenarios.json`. Field reference: [`routing/SKILL_MANIFEST.md`](SKILL_MANIFEST.md).
|
|
125
|
+
- **`routing/registry.json`**: Generated from the manifests by `npm run registry:build`. Do not edit it by hand; `npm run registry:check` verifies that it matches. The generated registry currently holds 24 skills: the 20 pre-Phase-4 skills plus the Phase 4 additions `time-series-and-change`, `sar-basics`, `accuracy-assessment` and `stac-and-cloud-access`.
|
|
126
|
+
- **`routing/checks.json`**: Check catalog listing the check ids that manifests may reference. It also carries the Phase 4 `provenance.reproducible` id and the `preflight.*` family; `tests/python/test_check_catalog.py` fails if the catalog and the emitting source disagree.
|
|
127
|
+
- **`routing/collections.json`**: Preset skill bundles (`gis`, `data-analysis`, `production`, `remote-sensing`).
|
|
128
|
+
- **`routing/rules.json`**: Scoring weights, intent heuristics, risk boundaries, and layer prioritization.
|
|
129
|
+
- **`router/`**: High-performance, deterministic TypeScript resolution engine and CLI runner.
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## 8. Python candidate and optional semantic retrieval
|
|
134
|
+
|
|
135
|
+
The Python router keeps ranked mode's existing default cap of five and thresholds. `mode="candidates"` uses a deterministic default cap of eight, preserves the ranked choices, and fills remaining slots by relevance for optional host-side selection. Candidate output includes one-line skill explanations; it does not call a host model itself.
|
|
136
|
+
|
|
137
|
+
Before Python retrieval, a deterministic bilingual clause pass scopes BM25, exact triggers, wording signals and optional semantics to requested work. Editorial clauses (translation, email/copy drafting, button-label edits) do not make their quoted technology names executable tasks. Negative operation directives end at punctuation or contrast/sequence boundaries; later affirmative work survives. A `no Python` constraint removes the runtime preference, not a legitimate database, infrastructure or map task. Descriptive negatives such as raw values being “not reflectance” remain diagnostic evidence. Quotes outside editorial clauses may be actual operands and are retained. The public query text, normalized text and Arabic expansion metadata still describe the original input; dataset profiles retain their independent evidence.
|
|
138
|
+
|
|
139
|
+
Phase 4 guards distinguish SAR preparation from optical cloud/reflectance preprocessing, map-accuracy assessment from arbitrary sampling/numerical precision, temporal analysis from application edits, and cloud asset access from generic REST CRUD. Generic index wording requires a spectral/raster context; Arabic professional vocabulary uses curated whole-word forms and existing clitic normalization, not substring matches. Paired English/Arabic dev cases and `tests/python/test_router_intent.py` exercise these intent boundaries in both ranked and candidate modes. Every routing rule also requires a matching public scenario in the `pythonScenarios` section of `tests/router/scenarios.json` before freeze. The frozen 20-skill compatibility fixture is not regenerated for these changes. No held-out corpus or protocol informs the rules.
|
|
140
|
+
|
|
141
|
+
Semantic retrieval is optional and offline-only (`pip install -e ".[semantic]"`). It uses the pinned local dependency/model when available, and missing dependencies, models, or inference errors fall back to lexical retrieval with a warning. No model download occurs during ordinary routing or tests.
|
|
142
|
+
|
|
143
|
+
## 9. Future Optional LLM Fallback (Design Only)
|
|
144
|
+
|
|
145
|
+
The Python router now rejects text-only software/copy homonyms (for example an
|
|
146
|
+
API route, a fictional plot or a logo palette) unless the affirmative request
|
|
147
|
+
also names a domain capability. Inspected datasets remain positive evidence for
|
|
148
|
+
mixed software/geospatial work. Named GDAL commands, additional web-map engines,
|
|
149
|
+
explicit temporal/accuracy/cloud capabilities and curated Arabic workflow nouns
|
|
150
|
+
have registered regressions. The 160 exposed internal-audit cases are development
|
|
151
|
+
coverage; they are not reused as fresh acceptance. The subsequent
|
|
152
|
+
[release audit](../evals/routing/RELEASE_20261023_PROTOCOL.md) records both its
|
|
153
|
+
passing numeric thresholds and same-agent/sample-size limitations.
|
|
154
|
+
|
|
155
|
+
In future iterations, if a task prompt has very low classification confidence (< 50%) or ambiguous natural language:
|
|
156
|
+
|
|
157
|
+
```text
|
|
158
|
+
Ambiguous Task
|
|
159
|
+
│
|
|
160
|
+
▼
|
|
161
|
+
Deterministic Router (Confidence < 0.50)
|
|
162
|
+
│
|
|
163
|
+
▼
|
|
164
|
+
Optional LLM Classifier (Constrained JSON schema output)
|
|
165
|
+
│
|
|
166
|
+
▼
|
|
167
|
+
Strict Registry Validator (Discard any hallucinated skill names)
|
|
168
|
+
│
|
|
169
|
+
▼
|
|
170
|
+
Final Validated Recommendation
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
*Note: LLM fallback is strictly prohibited from inventing non-existent skills, modifying production weights, or bypassing the registry schema.*
|