Repository navigation
Reports #756
Description
Compliance documents and standards from mining exploration and agriculture that typically involve or require GIS (Geographic Information Systems), spatial data, maps with coordinates, geospatial layers, or digital mapping:
These emphasize location data (coordinates, boundaries, datums/projections), GIS-compatible formats (e.g., shapefiles, KML/KMZ), farm/field maps, tenure boundaries, disturbance/reclamation areas, resource modeling, and traceability.
Mining Exploration
- Digital mineral exploration data submissions / exploration reports — Australian national guidelines (and many state/territory equivalents) require geospatial data (drill holes, samples, geology, models, maps) labeled for GIS display, including datum, projection, coordinates, and accuracy. GIS data formats are specified by agencies.
- Program for Environment Protection and Rehabilitation (PEPR) / equivalent exploration or mining plans — Spatial mapping of activities, disturbance, and rehabilitation; often includes GIS layers.
- Annual Reclamation / Compliance Reports — Explicit geospatial file submissions (e.g., shapefiles of disturbance and revegetated areas in BC, Canada, with specific coordinate systems and attributes matching reported tables/maps).
- Technical Report Summaries / CRIRSCO-aligned resource reports (JORC, NI 43-101, S-K 1300, PERC, etc.) — Maps of tenements, geology, drill collars, resource models, and infrastructure; spatial data underpins estimates and public disclosure. GIS is standard for visualization and modeling.
- Environmental Impact Assessments (EIA) / Environmental Assessment documents — Spatial analysis of impacts, baselines, and mitigation (land use, hydrology, sensitive areas).
- Reclamation/rehabilitation plans + financial assurance filings — Mapped disturbance, progressive reclamation areas, and post-mining land use.
- Notices of Intent / Plans of Operations (e.g., BLM 43 CFR 3809) and mining claim/tenement filings — Location maps, boundaries, and spatial validation of claims or permits.
- Related ISO/management systems — ISO 14001 (environmental aspects often mapped spatially); supporting data under ISO 9001/17025 for sample locations and QA/QC.
GIS is routinely used for tenure management, prospectivity mapping, environmental monitoring, and compliance dashboards in modern mining.
Agriculture
- Organic certification documents (USDA NOP, EU Regulation 2018/848, and equivalents) — Required farm/field maps showing boundaries, organic/in-conversion/conventional areas, buffer zones, field sizes/names, neighboring land use, landmarks, and (increasingly) geo-location or GPS coordinates. Digital/GIS maps (aerial, cadastral, or GIS-derived) are accepted and often preferred; some certifiers use KML/KMZ or GIS for verification and Internal Control Systems. Field history is linked to mapped parcels.
- FSMA Food Traceability Rule (US) Traceability Plan — Explicit requirement for a farm map of growing areas for listed foods, including the location and name of each field (or aquaculture container) plus geographic coordinates and any other identifying information.
- GLOBALG.A.P. Integrated Farm Assurance (IFA) and related checklists — Farm/field maps and location data for risk assessments, traceability, and audits; spatial elements support sustainability add-ons and compliance verification.
- Conservation compliance (e.g., USDA HELC/WC, Form AD-1026) — Relies on GIS layers for Highly Erodible Land and wetland determinations; maps and spatial data support certifications.
- Related records — Precision agriculture logs, input application maps, and audit trails often generated or stored in GIS-enabled farm management systems.
GIS/digital mapping is increasingly required or strongly encouraged for organic integrity, traceability (lot-to-field linking), and regulatory verification. Tools like GPS-enabled mobile apps and platforms that produce KML/shapefiles are common.
Notes
- Exact GIS requirements (formats, coordinate systems, metadata) are jurisdiction- and agency-specific and evolve with digital submission rules.
- Many other documents (e.g., general EIAs, safety plans) can incorporate GIS but do not always mandate it.
- In both sectors, spatial data supports audits, mass-balance checks, environmental monitoring, and supply-chain transparency.
For the most current details, check the relevant regulatory body or certification scheme in your jurisdiction, as digital/GIS standards are being strengthened.
Activity
ngoiyaeric commentedon Jul 25, 2026
@coderabbitai plan
coderabbitai commentedon Jul 25, 2026
Coding Plan
Summary
submit()intogenerateReportContext.generalreports remain unchanged, and jurisdiction-specific GIS nuances are surfaced as flagged assumptions rather than hard regulatory assertions.Design Choices
Design Choice 1: How should mining/agriculture compliance domain knowledge be injected into report generation?
Options Considered:
users.systemPrompt).Chosen Option: 2
Rationale: The codebase offers two hooks: the per-user
users.systemPromptoverride (a full replacement of the researcher prompt) or the report-agent pipeline. The system-prompt override is global-per-user, wholesale (loses tool-routing rules), and free-text (cannot produce structured, standard-aligned output), making it unsuitable for deterministic compliance sections. A dedicated agent keyed by report domain produces structured, standard-aligned compliance content without sacrificing the researcher's tool-routing behavior, and slots cleanly into the existing report pipeline and template.Design Choice 2: What GIS-compatible export format should accompany the compliance report?
Options Considered:
Chosen Option: 2
Rationale: The ticket stresses GIS-compatible formats (shapefiles, KML/KMZ). Shapefiles are binary multi-file archives requiring heavier libraries; drawn features are already WGS84 GeoJSON. KML and GeoJSON are text-based, generated client-side from existing
drawnFeatures, satisfy the "GIS-compatible format" requirement, and are the formats certifiers/agencies most commonly accept for verification.💡 User Tips
Regenerate the plan with different choices with
@coderabbitai <feedback>.Implementation Steps
Phase 1: Introduce a report domain/type model and selection workflow
Establish the concept of a "report domain" (general / mining exploration / agriculture) with optional document-type subtypes (e.g., JORC/NI 43-101 technical report, reclamation/disturbance report; organic certification farm map, FSMA traceability plan). The goal is to let the user choose what kind of compliance document they are producing and thread that choice end-to-end through the report pipeline, while keeping the current generic report as the default so existing behavior is unchanged.
Task 1: Define the report domain taxonomy and shared types
Create a single source of truth describing the supported report domains, their document subtypes, and the standards each references.
lib/schema/orlib/config/) defining aReportDomainunion ('general' | 'mining' | 'agriculture') and, per domain, a list of document subtypes with human-readable labels and the associated standards (JORC, NI 43-101, S-K 1300, PERC; USDA NOP, EU 2018/848, FSMA, GLOBALG.A.P., HELC/WC).reportType/domainparameter, following the existinglib/schema/*pattern.Task 2: Add report-type selection to the report trigger UI
Give the user a way to pick a domain/subtype before generating the report.
components/download-report-button.tsxto present a lightweight selector (dropdown/menu) driven by the taxonomy from Task 1.1; default selection isgeneralto preserve current behavior.reportType(and optional subtype) to theFormDatasent toactions.submit(), alongside the existingactionandmessages.<ReportTemplate>as a new prop so the template can conditionally render domain-specific sections.Task 3: Thread the report domain through the server action and context builder
Propagate the selected domain from the request into the report-generation logic.
generate_report_contextbranch ofsubmit()inapp/actions.tsxto read and validate the newreportTypefield and forward it togenerateReportContext.generateReportContextinlib/actions/chat.tsto accept an optionalreportType/domain argument and, when it is a compliance domain, invoke the new compliance agent (Phase 2) in addition to the existing executive-summary/strategic-synthesis agents, extending the returned object with a newcomplianceOutputfield (keptundefinedforgeneral).🤖 Prompt for AI agents
Phase 2: Add a domain-aware compliance synthesis agent
Introduce structured, standards-aligned compliance content generation. The agent consumes the same conversation transcript, sensor-fusion findings, and drawn AOI geometries already available to the report pipeline, but produces a compliance-oriented, structured assessment framed around the selected domain's regulatory expectations and spatial-data requirements (coordinates, boundaries, datum/projection, disturbance/field areas, traceability).
Task 1: Implement the compliance report agent
Create a new report agent parallel to the existing two, selecting a domain-specific prompt and output structure.
lib/agents/report/(e.g.,compliance-synthesis.ts) exposing an agent function that accepts the domain, subtype, active messages, sensor-fusion findings, and drawn-feature/spatial context.generateText(matching the existing report-agent pattern) with a domain-specialized system prompt: for mining, frame output around tenure boundaries, drill/sample/disturbance/reclamation spatial data, and CRIRSCO-aligned disclosure expectations; for agriculture, frame around field/parcel boundaries, buffer zones, geo-coordinates, and traceability (lot-to-field) expectations.complianceOutput(parsed JSON) with clearly named subsections (e.g., regulatory framework references, spatial-data summary/metadata, key compliance observations, gaps/recommended actions), following the JSON-parsing-with-fallback approach already used byexecutive-summary.ts/strategic-synthesis.ts.Task 2: Derive spatial-metadata context for the agent and template
Assemble the coordinate/boundary/measurement details the compliance domains require, from data already present in the app.
lib/actions/chat.ts) that transformsdrawnFeatures(GeoJSON geometries + measurements frommap-data-context) into a normalized spatial summary: feature identity, geometry type, area/length, bounding coordinates, and datum/projection labeling (WGS84 / EPSG:4326, matching Mapbox GL output).🤖 Prompt for AI agents
Phase 3: Render compliance sections and enable GIS-compatible export
Extend the report document to display the compliance assessment and a GIS-oriented spatial appendix, and give the user GIS-compatible file exports of the mapped AOIs so the report package matches what mining/agriculture submissions expect.
Task 1: Add compliance sections to the report template
Render the new domain-specific content when a compliance domain is selected.
components/report-template.tsxReportTemplatePropsto accept the selectedreportType/domain,complianceOutput, and the spatial summary from Task 2.2.complianceOutputis present), following the existing "render only if prop truthy" anddata-pdf-nosplitconventions; render its structured subsections (framework references, observations, gaps/recommended actions) via the existing ReactMarkdown pattern.Task 2: Add KML/GeoJSON export of drawn AOIs
Provide GIS-compatible spatial file outputs alongside the PDF.
lib/utils/report-generator.ts) that convertsdrawnFeaturesGeoJSON into KML and standalone GeoJSON files (WGS84), with feature names/labels derived from the compliance context.components/download-report-button.tsx(available for compliance domains) that triggers download of the KML/GeoJSON in addition to the generated PDF.🤖 Prompt for AI agents
Research
QCX-Terra is a Next.js + Vercel AI SDK conversational geospatial assistant. Chat orchestration runs through the
submit()server action inapp/actions.tsx, which branches on aFormDataactionstring. Report export is an on-demand, two-agent pipeline:download-report-button.tsxcaptures a Mapbox snapshot and chat history, callssubmit(action='generate_report_context'), which invokesgenerateReportContext(messages)inlib/actions/chat.ts. That function runsexecutiveSummaryAgentandstrategicSynthesisAgent(lib/agents/report/*) and returns{ title, summary, strategicOutput }, which are rendered bycomponents/report-template.tsx(fixed, hardcoded sections00–03) and rasterized to PDF vialib/utils/report-generator.ts. Map-drawn AOIs/geometries flow fromcomponents/map/map-data-context.tsxasdrawnFeatures(GeoJSON + measurement). There is no existing report-type/domain concept, and no mining/agriculture/compliance logic anywhere in the codebase — this is greenfield domain work that extends the existing report pipeline rather than replacing it.🚀 Next Steps
🤖 All AI agent prompts combined
💡 Iterate on the plan with:
`@coderabbitai` <feedback>💬 Have feedback or questions? Drop into our discord!