diff --git a/compass/__init__.py b/compass/__init__.py index 8ccb7a77a..f67a8189b 100644 --- a/compass/__init__.py +++ b/compass/__init__.py @@ -11,12 +11,16 @@ COMPASSDataCentersExtractor, COMPASSGeoHeatPumpExtractor, COMPASSGeoElectricityExtractor, + COMPASSNaturalGasExtractor, COMPASSNaturalGasPipelinesExtractor, COMPASSOilGasWellsExtractor, COMPASSGeoRMPExtractor, COMPASSSmallWindExtractor, COMPASSSolarExtractor, + COMPASSSolarOneShotExtractor, + COMPASSTransmissionExtractor, COMPASSWindExtractor, + COMPASSWindOneShotExtractor, TexasWaterRightsExtractor, ) diff --git a/compass/extraction/__init__.py b/compass/extraction/__init__.py index fb0607b17..389b38ea6 100644 --- a/compass/extraction/__init__.py +++ b/compass/extraction/__init__.py @@ -19,6 +19,8 @@ from .rmp import COMPASSGeoRMPExtractor from .small_wind import COMPASSSmallWindExtractor from .solar import COMPASSSolarExtractor +from .solar_os import COMPASSSolarOneShotExtractor from .transmission import COMPASSTransmissionExtractor from .water import TexasWaterRightsExtractor from .wind import COMPASSWindExtractor +from .wind_os import COMPASSWindOneShotExtractor diff --git a/compass/extraction/geothermal_electricity/geothermal_schema.json b/compass/extraction/geothermal_electricity/geothermal_schema.json index 75a0a8fa5..70f1be0cf 100644 --- a/compass/extraction/geothermal_electricity/geothermal_schema.json +++ b/compass/extraction/geothermal_electricity/geothermal_schema.json @@ -99,10 +99,8 @@ } } }, + "$scope": "Any legally enacted requirements/restrictions that apply to utility-scale geothermal electricity generation and directly associated geothermal electricity infrastructure, including exploration or drilling operations, production or injection wells, geothermal power plants, associated substations, and gen-tie lines only when the ordinance text explicitly governs them. State statutes and regulations are in scope when they impose enforceable siting, zoning, drilling, permitting, monitoring, bonding, setback, or decommissioning requirements on geothermal electricity projects in the jurisdiction. This schema must work across nationwide ordinance styles, including county, municipal, township, parish, borough, tribal, and state-level regulatory text. **OUT OF SCOPE**: Geothermal heat pumps, HVAC, direct-use geothermal, district heating, greenhouse heating, residential geothermal, and other non-generation systems unless the ordinance explicitly governs utility-scale electricity generation as well. Proposed, future, draft, or contingent requirements that are not currently effective as written are also out of scope.", "$core_principles": { - "scope_context": { - "description": "Only extract requirements that apply to utility-scale geothermal electricity generation and directly associated geothermal electricity infrastructure, including exploration or drilling operations, production or injection wells, geothermal power plants, associated substations, and gen-tie lines only when the ordinance text explicitly governs them. Exclude geothermal heat pumps, HVAC, direct-use geothermal, district heating, greenhouse heating, residential geothermal, and other non-generation systems unless the ordinance explicitly governs utility-scale electricity generation as well. State statutes and regulations are in scope when they impose enforceable siting, zoning, drilling, permitting, monitoring, bonding, setback, or decommissioning requirements on geothermal electricity projects in the jurisdiction. This schema must work across nationwide ordinance styles, including county, municipal, township, parish, borough, tribal, and state-level regulatory text." - }, "technology_applicability_gate": { "description": "Extract a row only when the cited evidence clearly applies to geothermal electricity. If the excerpt does not explicitly mention geothermal, the summary may establish applicability through ordinance context that is explicitly tied to geothermal in the same governing structure (for example a geothermal-specific chapter heading, a geothermal-defined use class, a table of uses listing geothermal, or table notes/standards that apply to that listed geothermal use). If applicability remains ambiguous or technology-neutral without a clear geothermal linkage, omit the feature." }, diff --git a/compass/extraction/geothermal_electricity/plugin_config.yaml b/compass/extraction/geothermal_electricity/plugin_config.yaml index dd13aebb4..6dfad765c 100644 --- a/compass/extraction/geothermal_electricity/plugin_config.yaml +++ b/compass/extraction/geothermal_electricity/plugin_config.yaml @@ -140,14 +140,14 @@ collection_prompts: 2) "explanation" (string) Set "{key}" = true when the chunk contains substantive regulatory text - that is likely usable for geothermal electricity extraction, including - any of the following: + usable for geothermal electricity extraction, including any of the + following: - explicit geothermal electricity language; OR - geothermal exploration/drilling/wells/injection/production terms; OR - operative zoning or development standards, use-table notes, permit requirements, siting constraints, hazard/site-condition requirements, decommissioning, bonding, lighting, fencing, color, or visual-impact - requirements that can govern listed geothermal or utility facility uses + requirements that can govern any explicitly-listed geothermal uses within the same ordinance structure. Treat enforceable table notes and standards as relevant even when the @@ -158,3 +158,11 @@ collection_prompts: (e.g., table of contents, navigation text, or content focused on unrelated technologies such as solar, wind, battery storage, cannabis, or geothermal heat pumps/HVAC/direct-use only). + +extraction_system_prompt: |- + You are a legal scholar extracting structured data specifically about **utility-scale geothermal electricity facilities** from ordinance documents. + Be focused and literal: extract only enacted, explicit, in-scope requirements: {scope}. + Be thorough and complete: review all relevant sections, including tables and lists, so no explicitly stated feature is missed. + Before finalizing, perform a feature-coverage check against the schema enum and ensure each explicitly supported utility-scale geothermal electricity feature is captured exactly once. + If there is no data to extract for geothermal utility-scale geothermal electricity facilities, return an empty array for the "outputs" array. Do not fabricate or infer any data. If a feature is not explicitly stated in the ordinance, leave it out of the output. + Pay extra attention to any descriptions, instructions, examples, and definitions in the schema, and be sure to follow all schema instructions carefully. diff --git a/compass/extraction/oil_gas_wells/oil_and_gas_wells_schema.json b/compass/extraction/oil_gas_wells/oil_and_gas_wells_schema.json index 0d092eb71..3f1c28e93 100644 --- a/compass/extraction/oil_gas_wells/oil_and_gas_wells_schema.json +++ b/compass/extraction/oil_gas_wells/oil_and_gas_wells_schema.json @@ -17,6 +17,7 @@ "units", "section", "summary", + "ordinance_text", "explanation" ], "additionalProperties": false, @@ -57,21 +58,10 @@ "value": { "description": "The extracted ordinance value. For numerical distance thresholds and limits, use a number. For permit or district lists, use an array of strings. For drilling start and end time features, use a string in 24-hour HH:MM format. For date language or other categorical outcomes, use a string. Use null only for qualitative features, and only when an enacted, explicit, enforceable ordinance requirement for that feature is present. Null must never be used to indicate absence. If a feature has no enacted, explicit requirement in the ordinance text, omit that feature from outputs.", "anyOf": [ - { - "type": "number" - }, - { - "type": "string" - }, - { - "type": "array", - "items": { - "type": "string" - } - }, - { - "type": "null" - } + {"type": "number"}, + {"type": "string"}, + {"type": "array", "items": {"type": "string"}}, + {"type": "null"} ] }, "units": { @@ -86,6 +76,10 @@ "type": "string", "description": "A short summary with direct ordinance excerpts or quotes whenever possible. For qualitative features such as permitting, fencing, lighting, seismic monitoring, decommissioning, and prohibitions, this is the primary output field and should contain direct ordinance language. For numeric features, summary must support the same requirement used to extract value and units. Must be a non-null, non-empty string. Do not output absence placeholders such as 'No explicit requirement found'; omit the feature instead when no requirement is present." }, + "ordinance_text": { + "type": "string", + "description": "The complete relevant text excerpt containing the ordinance information, copy-pasted verbatim from the source document. The first sentence must be the one that corresponds to the extracted value and summary, reproduced in full without elision. After that first sentence, gather any other passages in the document that bear on this same requirement, whether they appear before or after it, and join them with an ellipsis ('...') in the order they appear in the document. Use the ellipsis to skip over text that is not relevant so the excerpt stays focused while still carrying every passage that supports the extracted value, units, or qualitative requirement. Every character outside of the ellipses must appear exactly as written in the source: no paraphrasing, summarizing, normalization, added context, or commentary. Must be a non-null, non-empty string." + }, "explanation": { "type": "string", "description": "Brief rationale explaining why this row matches the selected feature under this schema. Reference the specific evidence in summary and how it supports the extracted value and units or, for qualitative features, the inclusion criteria. Must be a non-null, non-empty string and must not use absence placeholders." @@ -94,10 +88,8 @@ } } }, + "$scope": "Any legally enacted requirements/restrictions, permissions, district allowances, or prohibitions that apply to oil and gas exploration, drilling, well development, hydraulic fracturing, production, enhanced recovery, or injection and disposal wells, including both conventional and unconventional oil and gas wells and directly associated well sites and equipment such as well pads, wellheads, tanks, separators, and gathering equipment when explicitly governed by the source text. Local ordinances are in scope when they impose enforceable requirements on oil or gas wells in the jurisdiction. If the text uses generic terms like 'well', 'mineral extraction', or 'energy development', treat it as in scope only when the same governing context explicitly ties the provision to oil or gas wells or their directly associated well-site infrastructure. **OUT OF SCOPE**: water wells, geothermal wells, mining unrelated to oil or gas, pipelines, refineries, bulk storage terminals, and retail fuel facilities unless the text **explicitly** also applies the cited requirement to oil or gas wells or their directly associated well-site infrastructure. Proposed, future, draft, or contingent requirements that are not currently effective as written are also out of scope.", "$core_principles": { - "scope_context": { - "description": "Only extract requirements that apply to oil and gas exploration, drilling, well development, production, enhanced recovery, or injection and disposal wells, plus directly associated well sites and equipment such as well pads, wellheads, tanks, separators, and gathering equipment when the ordinance explicitly governs them. Both conventional and unconventional oil and gas wells are in scope. Exclude water wells, geothermal wells, mining unrelated to oil or gas, pipelines, refineries, bulk storage terminals, and retail fuel facilities unless the ordinance explicitly applies the cited requirement to oil or gas wells or their directly associated well-site infrastructure. State statutes and regulations are in scope when they impose enforceable siting, zoning, drilling, permitting, monitoring, bonding, setback, plugging, abandonment, or reclamation requirements on oil and gas wells in the jurisdiction. This schema must work across nationwide ordinance styles, including county, municipal, township, parish, borough, tribal, and state-level regulatory text." - }, "technology_applicability_gate": { "description": "Extract a row only when the cited evidence clearly applies to oil or gas wells. If the excerpt does not explicitly mention oil, gas, petroleum, natural gas, hydrocarbons, or wells used for those resources, the summary may establish applicability through ordinance context that is explicitly tied to oil and gas in the same governing structure (for example an oil-and-gas-specific chapter heading, a defined oil and gas extraction use class, a table of uses listing oil or gas wells, or table notes and standards that apply to that listed use). If applicability remains ambiguous or technology-neutral without a clear oil-and-gas-well linkage, omit the feature." }, @@ -241,7 +233,8 @@ "value": 500, "units": "feet", "section": "Section 8.4 - Setbacks", - "summary": "'Oil and gas production wells and associated well-site facilities shall be set back at least 500 feet from all property lines.'", + "summary": "Production wells and their associated well-site facilities must remain at least 500 feet from every property line. The setback applies to both the wells and the facilities, not just the wellheads.", + "ordinance_text": "Oil and gas production wells and associated well-site facilities shall be set back at least 500 feet from all property lines. ... The setback shall be measured from the nearest edge of the well or associated well-site facility to the property line.", "explanation": "The excerpt states an explicit numeric minimum separation from property lines, so it maps directly to 'property lines distance' with value 500 feet." }, { @@ -252,7 +245,8 @@ ], "units": null, "section": "Table 4 - Allowed Uses", - "summary": "'Oil and gas wells may be approved as conditional uses in the Industrial and Agricultural districts subject to county review.'", + "summary": "Oil and gas wells are eligible for conditional-use approval in the Industrial and Agricultural districts, subject to county review. They are not allowed by right under this provision.", + "ordinance_text": "Oil and gas wells may be approved as conditional uses in the Industrial and Agricultural districts subject to county review.", "explanation": "The ordinance explicitly lists two districts where oil and gas wells are allowed only through conditional-use approval, so this belongs under 'special use districts' with the district names preserved as an array." }, { @@ -263,7 +257,8 @@ ], "units": null, "section": "Section 5.2 - Approval Process", - "summary": "'A conditional use permit and county drilling permit shall be obtained prior to construction of any exploratory or production oil or gas well.'", + "summary": "Both a conditional use permit and a county drilling permit are required before well construction begins. This applies to exploratory wells as well as production wells for either oil or gas.", + "ordinance_text": "A conditional use permit and county drilling permit shall be obtained prior to construction of any exploratory or production oil or gas well.", "explanation": "The clause explicitly requires two project approvals before oil or gas well development can start, so it belongs under 'required permits' with both permit names preserved as an array." }, { @@ -271,7 +266,8 @@ "value": "07:00", "units": "HH:MM (24-hour)", "section": "Section 6.7 - Drilling Operations", - "summary": "'Routine oil and gas well drilling activities may occur only between 7:00 a.m. and 7:00 p.m., Monday through Saturday, and shall not occur on Sundays or legal holidays except in an emergency.'", + "summary": "Routine drilling may start at 7:00 a.m. on Monday through Saturday and must stay within the daily window ending at 7:00 p.m. Drilling on Sundays or legal holidays is prohibited unless there is an emergency.", + "ordinance_text": "Routine oil and gas well drilling activities may occur only between 7:00 a.m. and 7:00 p.m., Monday through Saturday, and shall not occur on Sundays or legal holidays except in an emergency.", "explanation": "The ordinance gives an explicit drilling window beginning at 7:00 a.m., normalized to 24-hour time as 07:00." }, { @@ -279,7 +275,8 @@ "value": "19:00", "units": "HH:MM (24-hour)", "section": "Section 6.7 - Drilling Operations", - "summary": "'Routine oil and gas well drilling activities may occur only between 7:00 a.m. and 7:00 p.m., Monday through Saturday, and shall not occur on Sundays or legal holidays except in an emergency.'", + "summary": "Routine drilling must end by 7:00 p.m. on Monday through Saturday; the daily window opens at 7:00 a.m. Sundays and legal holidays are excluded except for emergency drilling.", + "ordinance_text": "Routine oil and gas well drilling activities may occur only between 7:00 a.m. and 7:00 p.m., Monday through Saturday, and shall not occur on Sundays or legal holidays except in an emergency.", "explanation": "The ordinance gives an explicit drilling window ending at 7:00 p.m., normalized to 24-hour time as 19:00." }, { @@ -287,7 +284,8 @@ "value": null, "units": null, "section": "Section 9.3 - Financial Assurance", - "summary": "'Prior to permit issuance, the operator shall provide financial assurance in a form acceptable to the state oil and gas agency in an amount sufficient to cover plugging, abandonment, reclamation, and decommissioning costs as determined by the agency engineer.'", + "summary": "Before a permit can be issued, the operator must provide financial assurance acceptable to the state oil and gas agency. It must cover plugging, abandonment, reclamation, and decommissioning, but no fixed amount is stated; the agency engineer determines the required amount.", + "ordinance_text": "Prior to permit issuance, the operator shall provide financial assurance in a form acceptable to the state oil and gas agency in an amount sufficient to cover plugging, abandonment, reclamation, and decommissioning costs as determined by the agency engineer.", "explanation": "The clause imposes an enforceable financial assurance requirement but leaves the amount to an agency-determined formula, so it fits 'bond requirement' with value and units set to null." } ] @@ -301,6 +299,7 @@ "For any numeric feature, the summary must support the same requirement that produced value and units for that row. Never pair a numeric value from one clause with qualitative-only language from another clause that has no numeric threshold.", "Standardize units in the units field using this schema's canonical vocabulary, while preserving ordinance-specific wording in summary.", "Summary is the primary data carrier for all features in this schema; every row must have a non-null, non-empty string for summary.", + "Every row must include an ordinance_text holding the complete relevant excerpt for the ordinance being extracted, copy-pasted verbatim from the source document. Its first sentence must be the start of the ordinance text for this extraction, reproduced in full; after that first sentence an ellipsis ('...') may be used to drop irrelevant passages. ordinance_text is never paraphrased or normalized — every character outside the ellipses appears exactly as written in the source.", "Every row must include an explanation that briefly justifies why the cited summary evidence matches the selected feature under this schema's rules.", "Emit only positively matched features. Never emit a row to explain why a feature does not apply.", "The outputs array is a sparse long-form extraction table and does not need to contain every enumerated feature.", diff --git a/compass/extraction/oil_gas_wells/plugin_config.yaml b/compass/extraction/oil_gas_wells/plugin_config.yaml index ff8ddf063..b9c3512f9 100644 --- a/compass/extraction/oil_gas_wells/plugin_config.yaml +++ b/compass/extraction/oil_gas_wells/plugin_config.yaml @@ -116,17 +116,16 @@ collection_prompts: 2) "explanation" (string) Set "{key}" = true when the chunk contains substantive regulatory text - that is likely usable for oil and gas well extraction, including - any of the following: + usable for oil and gas well extraction, including any of the following: - explicit oil well, gas well, petroleum, or hydrocarbon language; OR - oil and gas exploration, drilling, production, injection, disposal, hydraulic fracturing, plugging, abandonment, or reclamation terms; OR - operative zoning or development standards, use-table notes, permit requirements, siting constraints, hazard/site-condition requirements, decommissioning, bonding, lighting, fencing, color, or visual-impact - requirements that can govern listed oil and gas wells, extraction uses, - or directly associated well-site equipment within the same ordinance - structure. + requirements that can govern any explicitly-listed oil and gas wells, + extraction uses, or directly associated well-site equipment within + the same ordinance structure. Treat enforceable table notes and standards as relevant even when the same chunk does not repeat "oil and gas", as long as the text is @@ -137,3 +136,12 @@ collection_prompts: (e.g., table of contents, navigation text, or content focused on unrelated activities such as water wells, geothermal development, pipelines, refineries, bulk storage, or retail fuel sales only). + +extraction_system_prompt: |- + You are a legal scholar extracting structured data specifically about **oil and gas wells and directly associated well-site infrastructure** from ordinance documents. + Be focused and literal: extract only enacted, explicit, in-scope requirements: {scope}. + Be thorough and complete: review all relevant sections, including tables and lists, so no explicitly stated feature is missed. + Before finalizing, perform a feature-coverage check against the schema enum and ensure each explicitly supported oil and gas well feature is captured exactly once. + If there is no data to extract for oil and gas wells or directly associated well-site infrastructure, return an empty array for the "outputs" array. Do not fabricate or infer any data. If a feature is not explicitly stated in the ordinance, leave it out of the output. + Pay extra attention to any descriptions, instructions, examples, and definitions in the schema, and be sure to follow all schema instructions carefully. + diff --git a/compass/extraction/solar_os/__init__.py b/compass/extraction/solar_os/__init__.py new file mode 100644 index 000000000..4d7d65869 --- /dev/null +++ b/compass/extraction/solar_os/__init__.py @@ -0,0 +1,12 @@ +"""COMPASS Solar one-shot plugin""" + +import importlib.resources + +from compass.plugin import create_schema_based_one_shot_extraction_plugin + + +COMPASSSolarOneShotExtractor = create_schema_based_one_shot_extraction_plugin( + importlib.resources.files("compass.extraction.solar_os") + / "plugin_config.yaml", + tech="solar-os", +) diff --git a/compass/extraction/solar_os/plugin_config.yaml b/compass/extraction/solar_os/plugin_config.yaml new file mode 100644 index 000000000..a12033382 --- /dev/null +++ b/compass/extraction/solar_os/plugin_config.yaml @@ -0,0 +1,180 @@ +schema: ./solar_schema.json5 + +data_type_short_desc: utility-scale ground-mounted photovoltaic solar ordinance + +cache_llm_generated_content: true + +query_templates: + - "filetype:pdf {jurisdiction} solar energy conversion system ordinances" + - "filetype:pdf site:{jurisdiction_website} solar zoning ordinance regulations" + - "{jurisdiction} zoning regulation utility-scale solar" + - "commercial solar energy facility siting requirements {jurisdiction}" + - "{jurisdiction} solar SECS ordinance" + +website_keywords: + - "pdf" + - ["secs", "sef"] + - "solar" + - ["zoning", "ordinance", "regulation"] + - "dsireusa" + - ["codelibrary", "amlegal", "municode", "codepublishing", "ecode360"] + - "renewable energy" + - ["plan", "planning", "permit"] + - "government" + - ["setback", "glare", "screening"] + - ["code", "district"] + - ["land development", "land use"] + - ["land", "environment", "energy", "renewable"] + - ["municipal", "department", "development", "board"] + +heuristic_keywords: + GOOD_TECH_KEYWORDS: + - "solar" + - "photovoltaic" + GOOD_TECH_ACRONYMS: + - "secs" + - "sef" + - "ses" + - "cses" + - "gses" + - "pv" + GOOD_TECH_PHRASES: + - "commercial solar energy system" + - "solar energy conversion" + - "solar energy facility" + - "solar energy facilities" + - "solar energy system" + - "solar panel" + - "solar farm" + - "solar energy farm" + - "utility-scale solar" + - "utility solar energy system" + - "ground-mounted solar" + NOT_TECH_WORDS: + - "concentrated solar" + - "csp" + - "micro secs" + - "small secs" + - "mini secs" + - "private secs" + - "personal secs" + - "psecs" + - "small solar" + - "micro solar" + - "mini solar" + - "private solar" + - "personal solar" + - "solar break" + - "solar damage" + - "solar data" + - "solar resource" + - "solaris" + - "solar plexus" + - "solar eclipse" + - "solar flare" + +# Heuristic exclusions strip phrases, not whole mixed-technology documents. +collection_prompts: + - key: contains_ord_info + label: contains ordinance info + prompt: |- + You extract structured data from text. Return your answer in JSON format + (not markdown). Your JSON file must include exactly two keys. The first + key is 'solar_reqs', which is a string that summarizes all + zoning, siting, setback, system design, and operational + requirements/restrictions that are explicitly enacted in the legal text for solar + energy systems for a given jurisdiction. Note that solar energy bans are an + important restriction to track. Include any **closely related provisions** + if they clearly pertain to the **development, operation, modification, or + removal** of solar energy systems (or solar panels). All restrictions should + be enforceable - ignore any text that only provides a legal definition of + the regulation. If the text does not specify any concrete zoning, siting, + setback, system design, or operational requirements/restrictions + for a solar energy system, set this key to `null`. The last key is + '{key}', which is a boolean that is set to True if the text excerpt + explicitly details zoning, siting, setback, system design, or operational + requirements/restrictions for a solar energy system and False + otherwise. + + - key: x + label: for utility-scale SEF + prompt: |- + You are a legal scholar that reads ordinance text and determines whether it + applies to zoning, siting, setback, system design, or operational + requirements/restrictions for **large solar energy systems**. Large + solar energy systems (SES) may also be referred to as + solar panels, solar energy conversion systems (SECS), solar energy + facilities (SEF), solar energy farms (SEF), solar farms (SF), + utility-scale solar energy systems (USES), commercial solar energy + systems (CSES), ground-mounted solar energy systems (GSES), + alternate energy systems (AES), commercial energy production + systems (CEPCS), or similar. Your client is a commercial solar developer that does + not care about ordinances related to CSP, private, residential, roof-mounted, + micro, small, or medium sized solar energy systems. + Ignore any text related to such systems. Return your answer as a dictionary + in JSON format (not markdown). Your JSON file must include exactly two keys. + The first key is 'summary' which contains a string that summarizes the types + of solar energy systems the text applies to (if any). The second key is + '{key}', which is a boolean that is set to True if any part of the text + excerpt details zoning, siting, setback, system design, or operational + requirements/restrictions for the **large solar energy conversion + systems** (or similar) that the client is interested in and False otherwise. + +text_extraction_prompts: + - key: cleaned_text_for_extraction + out_fn: "{jurisdiction} Utility Scale Solar Ordinance.txt" + prompt: |- + # CONTEXT # + The next step extracts structured requirements from the passages you + retain. Copy the solar provisions and the text needed to read them + correctly, verbatim and in source order. + + # OBJECTIVE # + Extract all text **pertaining to solar energy systems** from the provided + excerpt. + + # RESPONSE # + Follow these guidelines carefully: + + 1. ## Scope of Extraction ##: + - Include **all** text that pertains to **solar energy systems**, even if + they are referred to by different names such as: + Solar panels, solar energy conversion systems (secs), solar energy + facilities (sef), solar energy farms (sef), solar farms (sf), + utility-scale solar energy systems (uses), commercial solar energy + systems (cses), ground-mounted solar energy systems (gses), + alternate energy systems (aes), commercial energy production + systems (cepcs), or similar + - Explicitly include any text related to **bans or prohibitions** on solar + energy systems. + - Explicitly include any text related to the adoption or enactment date of + the ordinance (if any). + - Supporting text need not repeat the word "solar". If a solar provision + uses a defined term, incorporates a district schedule, or is qualified by + an exception, retain the applicable definition, schedule, or exception + when it is present in the excerpt. Keep the section identifiers and the + wording that links the provisions. + - Copy a table containing a solar use or governing a solar provision in + full, with its caption, column headers, row labels, units, blank cells, + legend and footnotes as supplied. Keep a separately printed key or note + with the table it explains; do not shift cells or decode symbols. + + 2. ## Exclusions ##: + - Exclude unrelated prose, definitions and schedules. Proximity to a + solar provision is not enough. If a cited passage or table is missing, + copy the reference as written; do not reconstruct the missing content. + + 3. {FORMATTING_PROMPT} + + 4. {OUTPUT_PROMPT} + +extraction_system_prompt: |- + You are a legal scholar extracting structured data specifically about **large, commercial, utility-scale ground-mounted photovoltaic solar energy systems** from ordinance documents. + Be focused and literal: extract only enacted, explicit, in-scope requirements: {scope}. + Be thorough and complete: review all relevant sections, including tables and lists, so no explicitly stated feature is missed. + Before finalizing, perform a feature-coverage check against the schema enum and ensure each explicitly supported large, commercial, utility-scale ground-mounted photovoltaic solar energy system feature is captured exactly once. + If there is no data to extract for large, commercial, utility-scale ground-mounted photovoltaic solar energy systems, return an empty array for the "outputs" array. Do not fabricate or infer any data. If a feature is not explicitly stated in the ordinance, leave it out of the output. + Pay extra attention to any descriptions, instructions, examples, definitions, and solar-specific decision tree logic in the schema, and be sure to follow all schema instructions carefully. + + SCHEMA AND EXTRACTION GUIDANCE: + {schema} diff --git a/compass/extraction/solar_os/solar_schema.json5 b/compass/extraction/solar_os/solar_schema.json5 new file mode 100644 index 000000000..dddd81ae9 --- /dev/null +++ b/compass/extraction/solar_os/solar_schema.json5 @@ -0,0 +1,427 @@ +{ + "title": "Solar Ordinance Extraction Schema", + "description": "One-shot extraction of utility-scale ground-mounted photovoltaic solar ordinances. The decision sequence and feature definitions translate COMPASS's solar farm classification, setback, restriction, and permitted-use decision trees into instructions for a single structured extraction call.", + "version": "1.0.0", + "type": "object", + "required": ["outputs"], + "additionalProperties": false, + "properties": { + "outputs": { + "type": "array", + "description": "Sparse long-form extraction table. Return one row per explicitly supported feature and omit unsupported features. Return an empty array when there are no enacted in-scope provisions.", + "items": { + "type": "object", + "required": [ + "feature", + "value", + "units", + "section", + "summary", + "ordinance_text", + "explanation" + ], + "additionalProperties": false, + "properties": { + "feature": { + "type": "string", + "enum": [ + "structures (participating)", + "structures (non-participating)", + "property line (participating)", + "property line (non-participating)", + "roads", + "railroads", + "transmission", + "water", + "public conservation lands", + "other secs", + "noise", + "maximum height", + "maximum project size", + "minimum lot size", + "maximum lot size", + "panel spacing", + "land density", + "coverage", + "prohibitions", + "decommissioning", + "glare", + "visual impact", + "repowering", + "fencing", + "signage", + "screening", + "soil", + "site management", + "agrivoltaics", + "primary use districts", + "special use districts", + "accessory use districts", + "prohibited use districts" + ] + }, + "value": { + "description": "A numeric threshold, a complete formula string for a compound setback, an array of district names, or null for an explicit qualitative obligation or participating-owner waiver. Use the literal string 'ENR' only for an explicit statement that the jurisdiction does not regulate an extra restriction. Missing requirements are omitted, never represented by null placeholder rows.", + "anyOf": [ + {"type": "number"}, + {"type": "string"}, + {"type": "array", "items": {"type": "string"}}, + {"type": "null"} + ] + }, + "units": { + "type": ["string", "null"], + "description": "The selected value's units using the feature rules below. Normalize unit names without converting magnitudes: ft to feet, m to meters, and so on. A pure solar structure-height multiplier uses 'structure-height-multiplier'. A compound formula embeds its original units in value and uses null units. Qualitative requirements, explicit waivers, ENR, and district lists use null units." + }, + "section": { + "type": ["string", "null"], + "description": "The section title/number, table identifier, or footnote supporting the selected requirement. Include identifiers for applicable alternatives when relevant. Use null when no identifier is available." + }, + "summary": { + "type": "string", + "description": "A nonempty summary using direct excerpts and quotations as much as possible. Preserve applicability, measurement origin, ownership, exceptions, formula adders, minimum/maximum bounds, and condition-specific alternatives. Support the same requirement as value and units. For qualitative requirements this is the substantive output. For an explicit waiver or ENR, quote the operative clause. Do not output absence placeholders; omit unsupported features." + }, + "ordinance_text": { + "type": "string", + "description": "The complete relevant ordinance excerpt, copied verbatim. Begin with the complete sentence supporting the selected value or qualitative obligation without elision. Then gather other passages bearing on that same requirement in source order, joining discontiguous passages with '...'. For tables retain the relevant headers, cells, legends, and footnotes that establish applicability. Every character outside ellipses must come from the source without paraphrasing, normalization, or added commentary. Must be a non-null, nonempty string." + }, + "explanation": { + "type": "string", + "description": "Brief evidence-based rationale tying summary and ordinance_text to this feature, its selected value and units, and applicability to the selected solar farm class. Explain relevant owner distinctions, formula terms, numerical dimensional checks, district classifications, explicit waivers, or ENR without inventing missing facts. Must be a non-null, nonempty string; never use absence placeholders." + } + } + } + } + }, + "$scope": "Currently enacted provisions governing large, commercial, utility-scale ground-mounted photovoltaic solar energy farms and their associated components. Aliases include solar panels, solar farms (SF), solar energy conversion systems (SECS), solar energy facilities/farms (SEF), solar energy systems (SES), utility-scale solar energy systems (USES), commercial solar energy systems (CSES), ground-mounted solar energy systems (GSES), alternate energy systems (AES), and commercial energy production systems (CEPCS), where definitions or context explicitly establish solar applicability. Determine scope from the ordinance's own definitions, size classes, rated capacity (often 1MW+), land area, offsite generation/sale criteria, and/or section context. Exclude provisions applying only to small, private, residential, onsite-only, rooftop/building-mounted, solar thermal, or concentrated solar power (CSP) systems and unrelated technologies. Generic solar provisions applying to all sizes are in scope when they also govern the selected utility-scale class.", + "$core_principles": { + "strict_evidence_gate": { + "description": "Extract a feature only when the supplied ordinance text explicitly states a requirement, operative definition, or prohibition for that same feature, or an explicit waiver or statement of nonregulation where the feature allows one. If a definition, table key, or incorporated schedule establishes how the operative clause applies, quote both passages. Do not infer a rule from a heading, alias, navigation entry, purpose statement, or nearby provision, or import a value from a source not supplied. Advice and thresholds that only trigger a study or review are not binding numerical limits." + }, + "data_omission": { + "description": "Emit only positively matched features. If a feature is not explicitly present, omit it entirely rather than returning placeholder text. For qualitative features, follow the feature-specific evidence and value rules, including the mention-based agrivoltaics exception. Numeric features require an explicit threshold or complete formula under their feature-specific rules, except for explicit participating-owner waivers or unspecified reductions (value=null, units=null) and expressly permitted nonregulation statements (value='ENR', units=null). Never emit absence placeholders such as 'not found', 'no explicit requirement', 'none', or similar text in any field." + }, + "numeric_prioritization": { + "description": "When multiple numeric values apply to the same feature, keep one row and select the controlling most restrictive value for that feature. Restrictiveness rules: setbacks, including inter-farm separation under 'other secs' -> choose the largest minimum separation distance; noise -> choose the lowest maximum allowable solar-facility noise level; maximum height -> choose the lowest maximum allowable solar panel or structure height, preserving the measurement origin and panel-angle condition; maximum project size -> choose the lowest maximum allowable capacity when comparing capacity limits, or the lowest maximum system or panel count when comparing limits counting the same kind of installation or component; minimum lot size -> choose the largest minimum required area; maximum lot size -> choose the smallest maximum allowable area; panel spacing -> choose the largest minimum required spacing between individual solar panels; land density -> choose the lowest maximum allowable solar capacity per unit land area; coverage -> choose the lowest maximum allowable land coverage percentage or fraction. Compare only requirements applicable to the selected in-scope solar farm class and the same feature, preserving participating versus non-participating distinctions. Compare values only on equivalent measurement bases: do not rank raw numbers across different units, panel or structure height multiplier bases, height measurement origins or panel-angle conditions, noise metrics or averaging periods, capacity versus system or panel counts, different capacity-per-area denominators, or coverage percentages versus fractions. Equivalent units may be reconciled for comparison, but report the selected value in its original units according to the feature-specific rules. For formulas, additive distances, and 'greater of' or 'lesser of' clauses, preserve the ordinance's actual controlling expression and follow the feature-specific value and units rules; do not select an isolated coefficient or threshold that changes its meaning. Do not invent solar panel or structure dimensions or other missing inputs to rank incomparable requirements. Where the ordinance explicitly identifies a controlling requirement, use it; otherwise do not claim that incomparable limits have a single most restrictive value. Keep condition-specific alternatives and independently applicable limits in summary only when the ordinance text explicitly establishes their applicability to the same feature for solar systems. Identify the conditions and units for each alternative, and ensure the selected value, units, section, and supporting excerpt refer to the same requirement. For qualitative features, including glare, and district lists, do not impose a numeric restrictiveness ranking; follow their feature-specific extraction rules." + } + }, + "$decision_tree": { + "1_system_classification": [ + "Determine whether the ordinance distinguishes multiple ground-mounted solar farm sizes. If so, list the classes internally in increasing size, including numerical qualifiers, and identify which classes the ordinance actually regulates.", + "Select the largest regulated ground-mounted farm class, not the largest class merely mentioned or explicitly excluded from regulation. Check whether it is explicitly large, commercial, utility-scale, or equivalent.", + "If that label is absent, require evidence of a commercial or utility-scale purpose, such as generation for offsite sale. Being the largest locally regulated class or producing more than is consumed onsite does not by itself establish that purpose.", + "If the largest regulated class is only small/noncommercial, return outputs=[]. If there is no size distinction, evaluate generic provisions using $scope rather than assuming they concern only small systems.", + "Apply requirements for the selected class and any general provisions explicitly covering it. Preserve class thresholds and applicability in summaries where needed; do not mix smaller-class limits into selected-class rows. An enacted ban on the in-scope class remains extractable even if no installations are allowed." + ], + "2_feature_evidence_gate": [ + "For 'agrivoltaics' only, any explicit mention of a term listed in its feature definition in enacted, in-scope ordinance text is sufficient. No obligation is needed. Report what the text says without inferring a requirement.", + "For other features independently, find an explicit enacted requirement. A provision in a definitions section counts if it imposes the requirement; a label or descriptive class boundary such as a heading, intent statement, reference, nearby requirement, etc. alone does not.", + "Extract only setbacks that apply to solar collectors (panels). Treat a general solar facility setback as applying to the panels when no component is specified; never infer a panel setback from a rule limited to power inverters or other non-panel equipment.", + "A clause naming several receptors with a shared setback supports each explicitly named receptor, but never cross-apply an unmentioned receptor. Distinguish buildings from parcel boundaries and wetlands from conservation lands.", + "For roads, require a facility setback from a road or road right-of-way. Ensure it is **NOT** inferred from a property-line setback. A rule covering all rights-of-way qualifies if the supplied definition expressly includes streets; quote it and preserve the broader scope. Neither an unspecified easement nor a highway used only to delineate an ineligible geographic area establishes a facility setback. Keep the measurement origin in summary.", + "If no requirement is found, check whether the text directly states that this particular feature is not regulated. Only an explicit, verified nonregulation statement for an extra restriction may produce value='ENR', units=null, with nonempty summary, ordinance_text, and explanation. Silence is never ENR. Otherwise omit the feature." + ], + "3_owner_split": [ + "For structures and property lines only, check whether participating and non-participating owners are explicitly distinguished.", + "Without a distinction, put the general setback in the non-participating row and omit the participating feature. Do not copy a general rule into both rows.", + "With a distinction, first check whether participating owners may waive the setback completely or reduce it by an unspecified amount. If so, keep participating value and units null and quote the waiver and conditions in summary.", + "Otherwise, if the ordinance expressly makes participating setbacks equal to non-participating setbacks, use the same supported requirement for both rows.", + "Otherwise extract each owner's explicit numeric setback independently. Never invent a participating value or borrow a non-participating value without explicit applicability." + ], + "4_setback_value": [ + "Check first for an explicit multiplier of solar structure height. For a pure multiplier use its numeric coefficient and units='structure-height-multiplier'. A fall-zone rule is 1 times structure height only when the ordinance explicitly equates the fall zone with that height.", + "If no multiplier is specified, check for a fixed setback distance. Use its numeric value and conventional distance unit; if neither is stated, omit the feature rather than inferring a threshold, except for an explicit participating-owner waiver under step 3.", + "For a multiplier, check for an additive distance and verify the expression really is multiplier * structure height + distance. A 'greater of', 'lesser of', 'no less than', or 'no greater than' distance is a bound, not an adder.", + "The output has no adder/min_dist/max_dist columns. Preserve a compound expression as a complete formula string in value, for example 'max(2 * structure height + 10 feet, 50 feet)', with units=null. Quote its full source clause in ordinance_text, summarize its terms in summary, and justify the expression in explanation. Never report an isolated coefficient that discards a controlling adder or bound.", + "If several applicable limits are comparable, choose the largest minimum setback or multiplier on the same basis. Do not compare raw numbers across feet, meters, height multipliers, or different receptors. If conditions or missing dimensions prevent a unique ranking, retain all applicable limits as a condition-labeled expression in value and explain them with source quotes in summary." + ], + "5_extra_restrictions": [ + "Separate numerical restrictions from qualitative obligations. Numerical restrictions require an explicit threshold and the feature-specific dimensional check; qualitative features retain operative text with null value and units.", + "For other secs, verify that separation is between full existing/planned solar farms, not panels or components within one farm. For coverage reject absolute area values; require a percentage or fraction. For land density require capacity per unit area, not coverage or an area-only restriction.", + "For lot size, check both ends of a binding parcel-area range for the selected class, including a range imposed in a definition. Emit each stated bound under its own feature; preserve the class and whether each endpoint is included in summary. Exclude descriptive size tiers, acreage that merely triggers review, and illustrative coverage calculations.", + "For maximum project size require a capacity or installation-count cap, not area or a definition/classification threshold. Reject a purported cap that can be bypassed by applying for a permit.", + "For panel spacing require an explicit minimum between individual panels; do not derive it from perimeter or property-line setbacks. Do not infer land density from setbacks or coverage.", + "Choose the largest minimum for other secs, minimum lot size, and panel spacing. Choose the smallest maximum for noise, maximum height, maximum project size, maximum lot size, land density, and coverage. Compare only equivalent measurement bases and applicability; retain conditional or incomparable alternatives in summary without pretending they are one comparable number.", + "For prohibitions verify that the restriction is enacted, currently effective, and unconditional jurisdiction-wide. An effective temporary moratorium qualifies while active; a proposed, future, expired, district-only, distance-dependent, or approval-dependent restriction does not. District-specific unconditional bans belong in prohibited use districts instead. Where any approval route remains, do not label that scope as unconditionally banned." + ], + "6_districts": [ + "Read use tables, headers, legends, district names/codes, and footnotes together. Match the selected solar class and explicit permission type; never infer a ban from omission in a permitted-use list.", + "Primary use means solar can be the primary land use. Categorize explicitly applicable solar overlay districts as primary use districts, not special or accessory use districts; preserve overlay approval conditions in summary.", + "Special use includes conditional use, special exceptions, and approvals by a board or special permitting process. Accessory use must explicitly allow the selected utility-scale class as secondary to another use, not merely residential rooftop solar.", + "Prohibited use districts must prohibit the selected class unconditionally. Do not include a district that allows the class through conditional/special approval. Return exact names/codes as one deduplicated array per use type, with units=null." + ] + }, + "$definitions": { + "setback_features": { + "description": "All setbacks follow steps 2 through 4, including owner-specific applicability and compound-expression preservation. Extract only receptors expressly covered by the clause or its applicable definition in the supplied text.", + "properties": { + "structures (participating)": { + "description": "Minimum solar setback from participating owners' occupied dwellings, buildings, structures, or residences. VALUE: numeric distance or height coefficient, complete compound formula string, or null for an explicit unrestricted waiver/reduction. Require an explicit ownership distinction. UNITS: original distance unit (feet, meters, miles, etc.), 'structure-height-multiplier' for a pure coefficient, or null for a compound formula or waiver. IGNORE: property/lot boundaries, roads, railroads, transmission, water, and conservation land setbacks. A dwelling is not a property line." + }, + "structures (non-participating)": { + "description": "Minimum solar setback from non-participating owners' occupied dwellings/buildings/structures/residences, or the general structure setback when ownership is not distinguished. VALUE: numeric distance, pure height coefficient, or complete compound formula under step 4. UNITS: original distance unit, 'structure-height-multiplier', or null for compound formulas. IGNORE: participating-only values and all non-structure receptors; do not equate dwellings with property lines." + }, + "property line (participating)": { + "description": "Minimum solar setback from participating owners' property/lot lines, facility perimeters, parcels, or subdivisions. VALUE: numeric distance or height coefficient, compound formula string, or null for an explicit unrestricted waiver/reduction; require explicit participating applicability. UNITS: original distance unit, 'structure-height-multiplier', or null for formulas/waivers. IGNORE: buildings, roads, railroads, transmission, water, and conservation lands unless explicitly included in the same operative clause." + }, + "property line (non-participating)": { + "description": "Minimum solar setback from non-participating property/lot lines, facility perimeters, parcels, or subdivisions, or the general boundary setback when ownership is not distinguished. VALUE: numeric distance, pure height coefficient, or complete compound formula. UNITS: original distance unit, 'structure-height-multiplier', or null for compound formulas. IGNORE: participating-only rules and building/road/other receptor setbacks; do not infer a road setback from a parcel boundary." + }, + "roads": { + "description": "Minimum solar setback explicitly measured from roads or road rights-of-way. VALUE: numeric distance, pure height coefficient, or complete compound formula. UNITS: original distance unit, 'structure-height-multiplier', or null for compound formulas. IGNORE: generic property-line rules, internal panel spacing, and unrelated rights-of-way; verify the rule is not better classified as a property-line setback." + }, + "railroads": { + "description": "Minimum solar setback from railroads or railroad rights-of-way. VALUE: numeric distance, pure height coefficient, or complete compound formula. UNITS: original distance unit, 'structure-height-multiplier', or null for compound formulas. IGNORE: roads, transmission easements, and generic parcel boundaries unless railroads are explicitly named." + }, + "transmission": { + "description": "Minimum solar setback from overhead electrical transmission/utility lines, power lines, or utility easements. VALUE: numeric distance, pure height coefficient, or complete compound formula. UNITS: original distance unit, 'structure-height-multiplier', or null for compound formulas. IGNORE: road/rail rights-of-way and onsite electrical design or interconnection requirements without an explicit separation distance." + }, + "water": { + "description": "Minimum solar setback from lakes, reservoirs, streams, rivers, or wetlands. VALUE: numeric distance, pure height coefficient, or complete compound formula. UNITS: original distance unit, 'structure-height-multiplier', or null for compound formulas. IGNORE: conservation lands unless explicitly linked to the water receptor, and soil/stormwater requirements without a setback." + }, + "public conservation lands": { + "description": "Minimum solar setback from public conservation lands, natural resource protection areas, or preservation areas. VALUE: numeric distance, pure height coefficient, or complete compound formula. UNITS: original distance unit, 'structure-height-multiplier', or null for compound formulas. IGNORE: wetlands/water bodies unless explicitly linked, private parcel setbacks, and general environmental aspirations." + } + } + }, + "numerical_restrictions": { + "description": "Require explicit numerical thresholds and pass the dimensional/applicability checks in step 5. Omit missing or rejected thresholds. An explicit nonregulation statement may instead produce 'ENR' with null units and supporting evidence.", + "properties": { + "other secs": { + "description": "Minimum separation between full existing or planned solar energy farms/installations. VALUE: numeric minimum separation, choosing the largest comparable minimum. UNITS: original distance unit such as feet, meters, or miles. IGNORE: spacing between individual panels, arrays, or components within a farm, and property-line setbacks not explicitly stated as inter-farm separation." + }, + "noise": { + "description": "Maximum permitted solar-facility noise level. VALUE: numeric ceiling, selecting the lowest comparable maximum. UNITS: the explicit sound metric such as dBA or dBC; use dBA for an unweighted 'decibels' limit only when no other weighting is stated, and disclose this assumption in summary. IGNORE: unrelated noise sources and measurement-distance numbers; do not compare different weightings, averaging periods, or day/night conditions as equivalent." + }, + "maximum height": { + "description": "Maximum permitted solar panel/structure height. VALUE: numeric ceiling; preserve any panel-angle condition and measurement origin. UNITS: original length unit such as feet or meters; feet-and-inches notation may be expressed as decimal feet (22 feet 6 inches = 22.5 feet). IGNORE: minimum ground clearance, fencing heights, rooftop-only limits, and system-class definition thresholds." + }, + "maximum project size": { + "description": "Maximum solar capacity or installation count allowed without an approval route to exceed the limit. VALUE: numeric capacity or maximum number of systems/panels, choosing the lowest comparable maximum. UNITS: original capacity unit (MW, kW, etc.), 'systems', or 'panels'. IGNORE: area-only limits, coverage, lot size, lower bounds defining a large class, upper bounds defining smaller classes, and thresholds that merely trigger a permit allowing larger projects. Preserve independent capacity/count limits in summary without ranking their raw numbers." + }, + "minimum lot size": { + "description": "Minimum lot, parcel, or tract area required for the selected solar class. VALUE: numeric lower endpoint, choosing the largest comparable minimum; retain 'more than' versus 'at least' in summary. UNITS: stated area unit, e.g. acres, hectares, square feet, or square meters. IGNORE: linear dimensions, capacity, and coverage; report a binding upper endpoint separately as maximum lot size." + }, + "maximum lot size": { + "description": "Maximum lot, parcel, or tract area allowed for the selected solar class. VALUE: numeric upper endpoint, choosing the smallest comparable maximum; retain 'less than' versus 'at most' in summary. UNITS: stated area unit, e.g. acres, hectares, square feet, or square meters. IGNORE: linear dimensions, capacity/count limits, and coverage; report a binding lower endpoint separately as minimum lot size." + }, + "panel spacing": { + "description": "Minimum spacing explicitly required between individual solar panels. VALUE: numeric minimum distance or panel-height multiplier, choosing the largest comparable minimum. UNITS: feet, meters, another explicit distance unit, or 'height-multiplier' for a pure panel-height coefficient; a compound formula follows step 4 with null units. IGNORE: inter-farm separation and property-line/perimeter setbacks. Do not derive spacing from land density or coverage." + }, + "land density": { + "description": "Maximum solar system capacity per unit land area. VALUE: numeric capacity numerator of the stated per-area limit. UNITS: explicit compound capacity/area unit such as MW/acre, kW/acre, or MW/hectare; retain a non-unit denominator in units (for example value=1 and units='MW/2 acres' for '1 MW per 2 acres') rather than converting it. IGNORE: acres per MW (inverse density), absolute capacity, absolute area, coverage fractions, and density inferred from setbacks." + }, + "coverage": { + "description": "Maximum fraction or percentage of land that solar may cover. VALUE: numeric percent or fraction exactly as stated, choosing the lowest comparable maximum. UNITS: 'percent' for percentages or 'fraction' for a unitless fractional limit. IGNORE: absolute area values, capacity-per-area density, and minimum/maximum lot area; do not calculate a percentage from them." + } + } + }, + "qualitative_restrictions": { + "description": "For an explicit obligation, retain the full relevant provisions in ordinance_text, summarize them in summary, and justify applicability in explanation, with value=null and units=null. Omit missing requirements. Explicit nonregulation follows step 2.", + "properties": { + "prohibitions": { + "description": "Currently effective unconditional jurisdiction-wide solar bans or moratoria. VALUE: null; summarize enactment/effective dates, duration, and operative terms. UNITS: null. IGNORE: draft/future/expired bans, district-only or distance-dependent restrictions, and restrictions permitting solar through approval; follow step 5. District-specific unconditional bans belong in prohibited use districts, not this feature." + }, + "decommissioning": { + "description": "Mandatory solar removal, restoration, abandonment timelines, decommissioning plans, or financial assurance. VALUE: null; retain deadlines, bond amounts, and triggers in summary. UNITS: null. IGNORE: definitions of abandonment with no operative removal obligation and unrelated construction bonding." + }, + "glare": { + "description": "Explicit solar glare/reflection controls, studies, mitigation, or receptor protections. VALUE: null; retain any quantitative glare criteria in summary. UNITS: null. IGNORE: generic visual-impact assessments or screening provisions that do not explicitly govern glare." + }, + "visual impact": { + "description": "Explicit requirement to assess a solar facility's visual impact. VALUE: null; quote the assessment requirement and conditions in summary. UNITS: null. IGNORE: aesthetic goals and mitigation measures (such as blending materials with surroundings, following natural contours, glare control, or screening) unless the ordinance also requires an assessment of visual impact." + }, + "repowering": { + "description": "Requirements specifically governing solar repowering or qualifying equipment replacement/upgrades. VALUE: null; preserve approval triggers and exceptions in summary. UNITS: null. IGNORE: routine maintenance, initial construction, or decommissioning unless explicitly applied to repowering." + }, + "fencing": { + "description": "Mandatory solar perimeter/security fencing specifications or access controls expressly tied to fencing. VALUE: null; retain heights, materials, gates, and exceptions in summary. UNITS: null. IGNORE: vegetative screening alone, generic property boundaries, and panel-height limits." + }, + "signage": { + "description": "Required or restricted solar-facility signs, including safety warnings and identification. VALUE: null; retain sign dimensions, wording, and placement in summary. UNITS: null. IGNORE: general sign-code provisions without explicit applicability to the selected solar class." + }, + "screening": { + "description": "Required solar vegetative buffers or other visual screening. VALUE: null; retain buffer widths, planting specifications, maintenance, and exceptions in summary. UNITS: null. IGNORE: generic setbacks, fencing with no screening purpose, and glare rules not requiring screening." + }, + "soil": { + "description": "Explicit soil protection, erosion, sediment control, or associated stabilization obligations during solar panel installation or operation. VALUE: null; retain applicable plans and standards in summary. UNITS: null. IGNORE: obligations that apply only during decommissioning or post-removal restoration, unrelated environmental rules, and water setbacks without a soil/erosion/sediment obligation." + }, + "site management": { + "description": "Requirements for managing the land at a solar facility during construction or operation. Include required vegetation management plans and their contents, vegetation preservation, establishing or maintaining groundcover, limits on impervious surfaces, grading and use of existing contours, and other practices required to manage the site or minimize disturbance. VALUE: null; summarize the required actions, application materials, thresholds, conditions, and exceptions in one row. UNITS: null, even when a standard includes a number. IGNORE: headings, goals, or generic site-plan approvals without a specific land management requirement. Visual screening, erosion control, or a solar lot-coverage cap alone does not establish this feature; retain those features separately when their own criteria are met." + }, + "agrivoltaics": { + "description": "Any explicit mention of agrivoltaics, ecovoltaics, or conservation solar, including singular and adjectival forms such as 'Agrivoltaic System' and 'ecovoltaic systems'. Definitions, classifications, and passing references count. VALUE: null; in one summary, name the terms actually used and quote what the ordinance says about them, preserving any conditions or exclusions. UNITS: null. IGNORE: agriculture, grazing, pollinator habitat, apiaries, soil protection, or conservation lands alone when none of the target terms is used." + } + } + }, + "use_districts": { + "description": "Apply step 6. Use arrays of exact district names/codes, not inferred district types. Omit unsupported use types instead of returning null or empty district lists.", + "properties": { + "primary use districts": { + "description": "Districts expressly allowing the selected solar class as a primary use or similar (e.g., permitted by right, without special conditions or approval beyond standard permitting), plus solar overlays that expressly authorize it under step 6. VALUE: array of supported district names/codes. UNITS: null. IGNORE: the word 'principal' alone, accessory-only or conditional-only base districts, and overlays that only impose extra review." + }, + "special use districts": { + "description": "Districts expressly allowing the selected solar class as special use or similar (e.g., requires approval by zoning appeals board, planning commission, special use permit, conditional use permit, or meeting certain conditions like completing a specific permitting process). VALUE: array of supported district names/codes; retain the permit type in summary. UNITS: null. IGNORE: ancillary reviews that do not grant land-use permission, solar overlays classified as primary, by-right permissions, and permits for small systems only." + }, + "accessory use districts": { + "description": "Districts expressly allowing the selected utility-scale solar class as secondary/accessory use or similar (e.g., when integrated with an existing structure, secondary to another primary use, or as an accessory to a principal use). VALUE: array of supported district names/codes. UNITS: null. IGNORE: residential/rooftop-only accessory systems, primary use permissions, and solar overlays classified as primary." + }, + "prohibited use districts": { + "description": "Districts **expressly and unconditionally** prohibiting the selected solar class. VALUE: array of supported district names/codes. UNITS: null. IGNORE: districts with any applicable special/conditional approval route, proposals/expired bans, and mere absence from permitted-use tables unless that absence is explicitly stated as a prohibition." + } + } + } + }, + "$examples": [ + { + "source_text": "Section 4. Commercial solar farms shall be at least 100 feet from residences. Participating residence owners may waive this setback by written agreement.", + "outputs": [ + {"feature": "structures (participating)", "value": null, "units": null, "section": "Section 4", "summary": "\"Participating residence owners may waive this setback by written agreement.\"", "ordinance_text": "Participating residence owners may waive this setback by written agreement. ... Commercial solar farms shall be at least 100 feet from residences.", "explanation": "The explicit participating-owner waiver requires a written agreement. It does not state a reduced numeric setback, so value and units remain null rather than zero."}, + {"feature": "structures (non-participating)", "value": 100, "units": "feet", "section": "Section 4", "summary": "\"Commercial solar farms shall be at least 100 feet from residences.\"", "ordinance_text": "Commercial solar farms shall be at least 100 feet from residences. Participating residence owners may waive this setback by written agreement.", "explanation": "The general 100-foot residence setback controls for owners who do not participate in the stated waiver; it is not a property-line setback."} + ] + }, + { + "source_text": "Section 5. Utility-scale solar panels shall be set back from roads by the greater of twice the structure height plus 10 feet or 50 feet.", + "outputs": [ + {"feature": "roads", "value": "max(2 * structure height + 10 feet, 50 feet)", "units": null, "section": "Section 5", "summary": "\"Utility-scale solar panels shall be set back from roads by the greater of twice the structure height plus 10 feet or 50 feet.\" The 10-foot adder and 50-foot floor are distinct.", "ordinance_text": "Utility-scale solar panels shall be set back from roads by the greater of twice the structure height plus 10 feet or 50 feet.", "explanation": "Roads are the explicit receptor. The full expression retains the structure-height multiplier, additive distance, and minimum bound without inventing a panel height."} + ] + }, + { + "source_text": "Section 6. Utility-scale solar farms shall not exceed 40 percent lot coverage or 0.5 MW per acre. Individual panels shall be spaced at least 12 feet apart.", + "outputs": [ + {"feature": "coverage", "value": 40, "units": "percent", "section": "Section 6", "summary": "\"Utility-scale solar farms shall not exceed 40 percent lot coverage or 0.5 MW per acre.\"", "ordinance_text": "Utility-scale solar farms shall not exceed 40 percent lot coverage or 0.5 MW per acre.", "explanation": "The 40-percent ceiling regulates the fraction of land covered, separately from capacity per acre."}, + {"feature": "land density", "value": 0.5, "units": "MW/acre", "section": "Section 6", "summary": "\"Utility-scale solar farms shall not exceed 40 percent lot coverage or 0.5 MW per acre.\"", "ordinance_text": "Utility-scale solar farms shall not exceed 40 percent lot coverage or 0.5 MW per acre.", "explanation": "The explicit 0.5 MW per acre ceiling is capacity per unit area, not a coverage percentage or absolute project-size cap."}, + {"feature": "panel spacing", "value": 12, "units": "feet", "section": "Section 6", "summary": "\"Individual panels shall be spaced at least 12 feet apart.\"", "ordinance_text": "Individual panels shall be spaced at least 12 feet apart. ... Utility-scale solar farms shall not exceed 40 percent lot coverage or 0.5 MW per acre.", "explanation": "The minimum distance is explicitly between individual panels within the utility-scale solar context, not between separate solar farms."} + ] + }, + { + "source_text": "Section 7. Commercial solar farms larger than 10 MW require a conditional use permit in Agricultural A-1. No maximum project capacity is imposed.", + "outputs": [ + {"feature": "maximum project size", "value": "ENR", "units": null, "section": "Section 7", "summary": "\"No maximum project capacity is imposed.\" The 10 MW threshold triggers approval and is not a capacity cap.", "ordinance_text": "No maximum project capacity is imposed. ... Commercial solar farms larger than 10 MW require a conditional use permit in Agricultural A-1.", "explanation": "An explicit nonregulation statement supports ENR. The 10 MW permit trigger is not a maximum allowed capacity."}, + {"feature": "special use districts", "value": ["Agricultural A-1"], "units": null, "section": "Section 7", "summary": "\"Commercial solar farms larger than 10 MW require a conditional use permit in Agricultural A-1.\"", "ordinance_text": "Commercial solar farms larger than 10 MW require a conditional use permit in Agricultural A-1.", "explanation": "Agricultural A-1 expressly allows commercial farms larger than 10 MW through conditional approval, placing it in special use districts rather than prohibited districts."} + ] + }, + { + "source_text": "Section 8. Commercial solar farms shall provide a decommissioning plan.", + "outputs": [ + {"feature": "decommissioning", "value": null, "units": null, "section": "Section 8", "summary": "\"Commercial solar farms shall provide a decommissioning plan.\"", "ordinance_text": "Commercial solar farms shall provide a decommissioning plan.", "explanation": "The mandatory commercial-solar decommissioning plan is an explicit qualitative obligation, with null value and units."} + ] + }, + { + "source_text": "Section 9. Commercial solar farms require a conditional use permit when capacity exceeds 10 MW.", + "outputs": [] + }, + { + "source_text": "Section 10. Only residential rooftop solar systems are regulated by this ordinance. Such systems shall not exceed 10 kW.", + "outputs": [] + }, + { + "source_text": "Section 11. Utility-scale solar farms shall be set back from all property lines and roads by twice the structure height.", + "outputs": [ + {"feature": "property line (non-participating)", "value": 2, "units": "structure-height-multiplier", "section": "Section 11", "summary": "\"Utility-scale solar farms shall be set back from all property lines and roads by twice the structure height.\"", "ordinance_text": "Utility-scale solar farms shall be set back from all property lines and roads by twice the structure height.", "explanation": "The shared clause explicitly names property lines and gives a pure structure-height coefficient of 2. No owner distinction is stated, so only the non-participating boundary feature is emitted."}, + {"feature": "roads", "value": 2, "units": "structure-height-multiplier", "section": "Section 11", "summary": "\"Utility-scale solar farms shall be set back from all property lines and roads by twice the structure height.\"", "ordinance_text": "Utility-scale solar farms shall be set back from all property lines and roads by twice the structure height.", "explanation": "Roads are independently named in the shared clause and use the same structure-height coefficient, rather than being inferred from a property-line rule."} + ] + }, + { + "source_text": "Section 12. Utility-scale solar farms are allowed in the Solar Overlay District subject to site-plan approval.", + "outputs": [ + {"feature": "primary use districts", "value": ["Solar Overlay District"], "units": null, "section": "Section 12", "summary": "\"Utility-scale solar farms are allowed in the Solar Overlay District subject to site-plan approval.\"", "ordinance_text": "Utility-scale solar farms are allowed in the Solar Overlay District subject to site-plan approval.", "explanation": "The Solar Overlay District expressly allows utility-scale solar farms, supporting classification as a primary use district while retaining the explicit site-plan approval condition."} + ] + }, + { + "source_text": "Section 13. Commercial solar farms are allowed as a principal use in Rural Production only by special permit. Within the Heritage District a design certificate is required before applying for that permit.", + "outputs": [ + {"feature": "special use districts", "value": ["Rural Production"], "units": null, "section": "Section 13", "summary": "\"Commercial solar farms are allowed as a principal use in Rural Production only by special permit.\"", "ordinance_text": "Commercial solar farms are allowed as a principal use in Rural Production only by special permit. Within the Heritage District a design certificate is required before applying for that permit.", "explanation": "Principal describes the land use, but it is not allowed by right. The design certificate does not grant solar use in a second district."} + ] + }, + { + "source_text": "Section 15. A tract hosting a utility-scale array must exceed 8 hectares but may not exceed 32 hectares.", + "outputs": [ + {"feature": "minimum lot size", "value": 8, "units": "hectares", "section": "Section 15", "summary": "For a utility-scale array the tract must be strictly greater than 8 hectares.", "ordinance_text": "A tract hosting a utility-scale array must exceed 8 hectares but may not exceed 32 hectares.", "explanation": "The lower endpoint is exclusive; a tract of exactly 8 hectares does not qualify."}, + {"feature": "maximum lot size", "value": 32, "units": "hectares", "section": "Section 15", "summary": "For a utility-scale array the tract may be at most 32 hectares, inclusive.", "ordinance_text": "A tract hosting a utility-scale array must exceed 8 hectares but may not exceed 32 hectares.", "explanation": "The same clause sets an independent upper bound on the tract, not on array capacity or land coverage."} + ] + }, + { + "source_text": "Section 16. Applications for commercial solar facilities on parcels over 12 acres require additional review.", + "outputs": [] + }, + { + "source_text": "Section 17. Commercial ground-mounted solar collectors include agrivoltaic systems. An agrivoltaic system combines solar generation and agriculture within the array.", + "outputs": [ + {"feature": "agrivoltaics", "value": null, "units": null, "section": "Section 17", "summary": "Agrivoltaic systems are classified as commercial ground-mounted collectors and combine \"solar generation and agriculture within the array.\"", "ordinance_text": "Commercial ground-mounted solar collectors include agrivoltaic systems. An agrivoltaic system combines solar generation and agriculture within the array.", "explanation": "The collector classification and definition explicitly name agrivoltaic systems; neither requires a project to use them."} + ] + }, + { + "source_text": "Section 3.2.5. Utility-scale solar applications shall include a vegetation management plan for maintaining groundcover beneath the panels. The layout shall follow existing contours to the extent practical, but grading is permitted for transformer pads, access roads, and grid connections.", + "outputs": [ + {"feature": "site management", "value": null, "units": null, "section": "Section 3.2.5", "summary": "Applications must include a plan for \"maintaining groundcover beneath the panels.\" The layout must follow existing contours \"to the extent practical,\" with grading permitted for transformer pads, access roads, and grid connections.", "ordinance_text": "Utility-scale solar applications shall include a vegetation management plan for maintaining groundcover beneath the panels. The layout shall follow existing contours to the extent practical, but grading is permitted for transformer pads, access roads, and grid connections.", "explanation": "The plan and grading provisions govern how the land is managed; the listed exceptions qualify the grading restriction."} + ] + }, + ], + "$instructions": { + "general": [ + "Extract ordinance requirements ONLY for large, commercial, or utility-scale solar energy systems (typically intended for offsite electricity generation or sale, often 1MW+ or above specified thresholds). Do NOT extract requirements that apply only to small, micro, private, personal, onsite, or residential systems, or to meteorological towers.", + "Use direct text excerpts and quotes in the summary field as much as possible. If multiple options exist and you make a selection, list all other options and their conditions in the summary.", + "Extract only from enacted text. Except for the mention-based feature in step 2, do not extract definitions unless they also constitute requirements.", + "Pay careful attention to clarifying text in parentheses, footnotes, and cross-references.", + "When multiple values are mentioned for the same feature, select the most restrictive value (largest minimum, lowest maximum, etc.) and note the other options in the summary.", + "Ensure units are expressed using standard, conventional names (e.g., 'feet', 'meters', 'dBA', 'hr/year', 'tip-height-multiplier').", + "Every row must include an ordinance_text holding the complete relevant excerpt for the ordinance being extracted, copy-pasted verbatim from the source document. Its first sentence must be the start of the ordinance text for this extraction, reproduced in full; after that first sentence an ellipsis ('...') may be used to drop irrelevant passages. ordinance_text is never paraphrased or normalized — every character outside the ellipses appears exactly as written in the source.", + "Every row must include an explanation that briefly justifies why the cited summary evidence matches the selected feature under this schema's rules.", + "Emit only positively matched features. Never emit a row to explain why a feature does not apply.", + "The outputs array is a sparse long-form extraction table and does not need to contain every enumerated feature.", + "Tables, table footnotes, and labeled graphics count as valid ordinance evidence when they state the controlling requirement; preserve the relevant table cell or footnote context in summary.", + "If ordinance text shows an amended or superseding requirement, extract the current operative requirement as written rather than a superseded historical value unless the ordinance text clearly keeps both rules active.", + "If text is suggestive but not explicit for the target feature, omit the feature." + ], + "setback_specific": [ + "For distance-based setbacks, extract the numerical value and units (feet/meters).", + "If text includes an adder (e.g., 'multiplier × height + X feet'), note this in the summary. Adder values should be converted to feet.", + "If text includes conditional minimums ('the greater of', 'no less than'), note minimum threshold in summary.", + "If text includes conditional maximums ('the lesser of', 'no more than'), note maximum limit in summary.", + "For structures and property lines: Check if ordinance distinguishes between participating and non-participating owners. If yes, extract separate values for each. If no distinction, use the non-participating feature for the general setback.", + "For roads: Verify the requirement is truly for roads and not better classified as a property line setback.", + "When one setback clause explicitly names multiple target features and provides one shared numeric threshold, emit one row per explicitly named feature using the same threshold and units." + ], + "restriction_specific": [ + "For numerical solar restrictions: Extract the numerical value and units specified by the feature definition. If multiple comparable values exist, select the most restrictive and retain other values and their conditions in summary.", + "For maximum height: Extract the maximum solar panel or structure height, preserving the measurement origin and any panel-angle condition. Exclude minimum ground clearance, fencing heights, rooftop-only limits, and system-class definition thresholds.", + "For maximum project size: Specify in summary whether the limit is capacity-based (MW, kW, etc.) or count-based (systems or panels). Exclude area-only limits and thresholds that merely trigger approval for larger projects; retain independent capacity and count limits without comparing their raw numbers.", + "For minimum/maximum lot size: Apply step 5 to both ends of a binding lot, parcel, or tract area range, not linear dimensions, coverage percentages, or capacity limits.", + "For panel spacing: Only extract explicit minimum spacing between individual solar panels. Do not infer spacing from setbacks, land density, or coverage, and do not classify it as separation between solar farms.", + "For land density: Only extract explicit maximum solar capacity per unit land area, preserving the stated capacity/area units. Exclude inverse density (area per capacity), absolute capacity or area limits, and density inferred from setbacks.", + "For coverage: Extract the maximum land coverage percentage or fraction as stated. Do not infer coverage from lot area, capacity, or land density.", + "For qualitative solar restrictions: Retain the full relevant provisions in ordinance_text and use direct excerpts and quotes in summary, with value and units null. Explicit nonregulation follows the feature rules for ENR.", + "For prohibitions: Only extract enacted, currently effective, unconditional jurisdiction-wide solar bans or moratoria. If solar is allowed through an approval route, this is not a prohibition. Classify district-only bans under prohibited use districts." + ], + "district_specific": [ + "For primary and special use districts: Apply step 6 to the permission route for the selected class. Only an expressly authorizing solar overlay qualifies for the primary-use exception.", + "For accessory use districts: Include districts where solar is only allowed as accessory/secondary to another use.", + "For prohibited use districts: Only include districts with unconditional prohibitions currently in effect.", + "Use the exact district names/codes as they appear in the ordinance text." + ] + }, + "$qa_checklist": [ + "Examples are sparse response fragments. Do not pad them with null rows. Review every enum feature for coverage and emit each explicitly supported feature at most once.", + "Feature IDs are unique and no row explains mere absence. For documents with no extractable in-scope features outputs is empty.", + "Every row has non-null, nonempty summary, ordinance_text, and explanation supporting the same explicit enacted provision for the selected solar class and feature.", + "Numeric values have matching units. Formula strings preserve every adder, bound, and condition with units embedded and units=null. ENR has an explicit supporting nonregulation quote and units=null.", + "No waiver is converted to zero, no permit threshold is mistaken for a capacity cap, and no panel spacing is classified as inter-farm separation.", + "Coverage is percent/fraction, lot size is area, and land density is capacity per area. Do not infer one from another.", + "Qualitative obligations have null value/units and source evidence. The only null-valued numerical-feature rows describe explicit participating waivers; other numerical rows require a threshold, a complete formula, or explicitly supported ENR. Omit unsupported features.", + "District lists reflect exact names, table legends, and conditions." + ], + "$qualitative_features": [ + "prohibitions", + "decommissioning", + "glare", + "visual impact", + "repowering", + "fencing", + "signage", + "screening", + "soil", + "site management", + "agrivoltaics" + ] +} diff --git a/compass/extraction/wind/plugin.py b/compass/extraction/wind/plugin.py index 89b7dd327..774008e75 100644 --- a/compass/extraction/wind/plugin.py +++ b/compass/extraction/wind/plugin.py @@ -25,17 +25,13 @@ WIND_QUERY_TEMPLATES = [ "filetype:pdf {jurisdiction} wind energy conversion system ordinances", - "wind energy conversion system ordinances {jurisdiction}", - "{jurisdiction} wind WECS ordinance", - ( - "Where can I find the legal text for commercial wind energy " - "conversion system zoning ordinances in {jurisdiction}?" - ), ( - "What is the specific legal information regarding zoning " - "ordinances for commercial wind energy conversion systems in " - "{jurisdiction}?" + "filetype:pdf site:{jurisdiction_website} wind zoning " + "ordinance regulations" ), + "{jurisdiction} zoning regulation wind", + "wind energy conversion system ordinances {jurisdiction}", + "{jurisdiction} wind WECS ordinance", ] BEST_WIND_ORDINANCE_WEBSITE_URL_KEYWORDS = [ diff --git a/compass/extraction/wind_os/__init__.py b/compass/extraction/wind_os/__init__.py new file mode 100644 index 000000000..022b6bd81 --- /dev/null +++ b/compass/extraction/wind_os/__init__.py @@ -0,0 +1,12 @@ +"""COMPASS Wind one-shot plugin""" + +import importlib.resources + +from compass.plugin import create_schema_based_one_shot_extraction_plugin + + +COMPASSWindOneShotExtractor = create_schema_based_one_shot_extraction_plugin( + importlib.resources.files("compass.extraction.wind_os") + / "plugin_config.yaml", + tech="wind-os", +) diff --git a/compass/extraction/wind_os/plugin_config.yaml b/compass/extraction/wind_os/plugin_config.yaml new file mode 100644 index 000000000..ce7adb022 --- /dev/null +++ b/compass/extraction/wind_os/plugin_config.yaml @@ -0,0 +1,224 @@ +schema: ./wind_schema.json5 + +data_type_short_desc: wind energy ordinance + +cache_llm_generated_content: true + +query_templates: + - "filetype:pdf {jurisdiction} wind energy conversion system ordinances" + - "filetype:pdf site:{jurisdiction_website} wind zoning ordinance regulations" + - "{jurisdiction} zoning regulation utility-scale wind" + - "commercial wind energy facility siting requirements {jurisdiction}" + - "{jurisdiction} wind WECS ordinance" + +website_keywords: + - "pdf" + - ["wecs", "wef"] + - "wind" + - ["zoning", "ordinance", "regulation"] + - ["dsireusa", "windaction"] + - ["codelibrary", "amlegal", "municode", "codepublishing", "ecode360"] + - "renewable energy" + - ["plan", "planning", "permit"] + - "government" + - ["setback", "noise"] + - ["code", "area"] + - ["land development", "land use"] + - ["land", "environment", "energy", "renewable"] + - ["municipal", "department", "development", "board"] + +heuristic_keywords: + good_tech_keywords: + - "wind" + - "setback" + good_tech_acronyms: + - "wecs" + - "wes" + - "lwet" + - "uwet" + - "wef" + good_tech_phrases: + - "wind energy conversion" + - "wind turbine" + - "wind tower" + - "wind farm" + - "wind energy system" + - "wind energy farm" + - "utility wind energy system" + not_tech_words: + - "micro wecs" + - "small wecs" + - "mini wecs" + - "private wecs" + - "personal wecs" + - "pwecs" + - "rewind" + - "small wind" + - "micro wind" + - "mini wind" + - "private wind" + - "personal wind" + - "swecs" + - "windbreak" + - "windiest" + - "winds" + - "windshield" + - "window" + - "windy" + - "wind attribute" + - "wind blow" + - "wind break" + - "wind current" + - "wind damage" + - "wind data" + - "wind direction" + - "wind draft" + - "wind erosion" + - "wind energy resource atlas" + - "wind load" + - "wind movement" + - "wind orient" + - "wind resource" + - "wind runway" + - "prevailing wind" + - "downwind" + +collection_prompts: + - key: contains_ord_info + label: contains ordinance info + prompt: |- + You extract structured data from text. Return your answer in JSON + format (not markdown). Your JSON file must include exactly two keys. + The first key is 'wind_reqs', which is a string that summarizes all + zoning, siting, setback, system design, and operational + requirements/restrictions that are explicitly enacted in the text + for a wind energy system (or wind turbine/tower) for a given + jurisdiction. Note that wind energy bans are an important restriction + to track. Include any **closely related provisions** if they clearly + pertain to the **development, operation, modification, or removal** of + wind energy systems (or wind turbines/towers). All restrictions should + be enforceable - ignore any text that only provides a legal definition + of the regulation. If the text does not specify any concrete zoning, + siting, setback, system design, or operational requirements/restrictions + for a wind energy system, set this key to `null`. The last key is '{key}', + which is a boolean that is set to True if the text excerpt explicitly + details zoning, siting, setback, system design, or operational + requirements/restrictions for a wind energy system (or wind turbine/tower) + and False otherwise. + + - key: x + label: for utility-scale WECS + prompt: |- + You are a legal scholar that reads ordinance text and determines whether + any of it applies to zoning, siting, setback, system design, or operational + requirements/restrictions for **large wind energy systems**. + Large wind energy systems (WES) may also be referred to as wind turbines, + wind energy conversion systems (WECS), wind energy facilities (WEF), + wind energy turbines (WET), large wind energy turbines (LWET), + utility-scale wind energy turbines (UWET), + commercial wind energy conversion systems (CWECS), + alternate energy systems (AES), commercial energy production systems (CEPCS), + or similar. Your client is a commercial wind developer that does not care + about ordinances related to private, residential, micro, small, + or medium sized wind energy systems. Ignore any text related to such systems. + Return your answer as a dictionary in JSON format (not markdown). + Your JSON file must include exactly two keys. The first key is 'summary' + which contains a string that lists all of the types of wind energy systems + the text applies to (if any). The second key is '{key}', which is a boolean + that is set to True if any part of the text excerpt details zoning, siting, + setback, system design, or operational requirements/restrictions for the + **large wind energy conversion systems** (or similar) that the client is + interested in and False otherwise. + +text_extraction_prompts: + - key: wind_energy_systems_text + out_fn: "{jurisdiction} Wind Ordinance.txt" + prompt: |- + # CONTEXT # + We want to reduce the provided excerpt to only contain information about + **wind energy systems**. The extracted text will be used for structured + data extraction, so it must be both **comprehensive** (retaining all relevant + details) and **focused** (excluding unrelated content), with **zero rewriting + or paraphrasing**. Ensure that all retained information is **directly applicable + to wind energy systems** while preserving full context and accuracy. + + # OBJECTIVE # + Extract all text **pertaining to wind energy systems** from the provided excerpt. + + # RESPONSE # + Follow these guidelines carefully: + + 1. ## Scope of Extraction ##: + - Include all text that pertains to **wind energy systems**. + - Explicitly include any text related to **bans or prohibitions** on wind energy systems. + - Explicitly include any text related to the adoption or enactment date of the ordinance (if any). + + 2. ## Exclusions ##: + - Do **not** include text that does not pertain to wind energy systems. + + 3. ## Formatting & Structure ##: + - **Preserve _all_ section titles, headers, and numberings** for reference. + - **Maintain the original wording, formatting, and structure** to ensure accuracy. + + 4. ## Output Handling ##: + - This is a strict extraction task — act like a text filter, **not** a summarizer or writer. + - Do not add, explain, reword, or summarize anything. + - The output must be a **copy-paste** of the original excerpt. **Absolutely no paraphrasing or rewriting.** + - The output must consist **only** of contiguous or discontiguous verbatim blocks copied from the input. + - If **no relevant text** is found, return the response: 'No relevant text.' + + - key: cleaned_text_for_extraction + out_fn: "{jurisdiction} Utility Scale Wind Ordinance.txt" + prompt: |- + # CONTEXT # + We want to reduce the provided excerpt to only contain information about + **large wind energy systems**. The extracted text will be used for + structured data extraction, so it must be both **comprehensive** + (retaining all relevant details) and **focused** (excluding unrelated + content), with **zero rewriting or paraphrasing**. Ensure that all + retained information is **directly applicable** to large wind energy + systems while preserving full context and accuracy. + + # OBJECTIVE # + Extract all text **pertaining to large wind energy systems** from the provided excerpt. + + # RESPONSE # + Follow these guidelines carefully: + + 1. ## Scope of Extraction ##: + - Include all text that pertains to **large wind energy systems**, even if they are referred to by different names such as: Wind turbines, wind energy conversion systems (wecs), wind energy facilities (wef), wind energy turbines (wet), large wind energy turbines (lwet), utility-scale wind energy turbines (uwet), commercial wind energy conversion systems (cwecs), alternate energy systems (aes), commercial energy production systems (cepcs), or similar + - Explicitly include any text related to **bans or prohibitions** on large wind energy systems. + - Explicitly include any text related to the adoption or enactment date of the ordinance (if any). + - **Retain all relevant technical, design, operational, safety, environmental, and infrastructure-related provisions** that apply to the topic, such as (but not limited to): + - Compliance with legal or regulatory standards. + - Site, structural, or design specifications. + - Environmental impact considerations. + - Safety and risk mitigation measures. + - Infrastructure, implementation, operation, and maintenance details. + - All other **closely related provisions**. + + 2. ## Exclusions ##: + - Do **not** include text that explicitly applies **only** to private, residential, micro, small, or medium sized wind energy systems. + - Do **not** include text that does not pertain at all to wind energy systems. + + 3. ## Formatting & Structure ##: + - **Preserve _all_ section titles, headers, and numberings** for reference. + - **Maintain the original wording, formatting, and structure** to ensure accuracy. + + 4. ## Output Handling ##: + - This is a strict extraction task — act like a text filter, **not** a summarizer or writer. + - Do not add, explain, reword, or summarize anything. + - The output must be a **copy-paste** of the original excerpt. **Absolutely no paraphrasing or rewriting.** + - The output must consist **only** of contiguous or discontiguous verbatim blocks copied from the input. + - If **no relevant text** is found, return the response: 'No relevant text.' + +extraction_system_prompt: |- + You are a legal scholar extracting structured data specifically about **large, commercial, utility-scale wind energy systems** from ordinance documents. + Be focused and literal: extract only enacted, explicit, in-scope requirements: {scope}. + Be thorough and complete: review all relevant sections, including tables and lists, so no explicitly stated feature is missed. + Before finalizing, perform a feature-coverage check against the schema enum and ensure each explicitly supported large, commercial, utility-scale wind energy system feature is captured exactly once. + If there is no data to extract for large, commercial, utility-scale wind energy systems or their definitions, return an empty array for the "outputs" array. Do not fabricate or infer any data. If a feature is not explicitly stated in the ordinance, leave it out of the output. + Pay extra attention to any descriptions, instructions, examples, and definitions in the schema, and be sure to follow all schema instructions carefully. + + SCHEMA AND EXTRACTION GUIDANCE: + {schema} diff --git a/compass/extraction/wind_os/wind_schema.json5 b/compass/extraction/wind_os/wind_schema.json5 new file mode 100644 index 000000000..7aa71881e --- /dev/null +++ b/compass/extraction/wind_os/wind_schema.json5 @@ -0,0 +1,347 @@ +{ + "title": "Wind Ordinance Extraction Schema", + "description": "Single-shot structured extraction schema for wind energy ordinances. This schema encodes the complete multi-step decision tree logic from COMPASS into comprehensive field descriptions that guide LLMs to extract all ordinance features in one call. The output is structured as a flat array of extraction objects, where each object represents one row in the final CSV/DataFrame output.", + "version": "1.0.0", + "type": "object", + "required": ["outputs"], + "additionalProperties": false, + "properties": { + "outputs": { + "type": "array", + "items": { + "type": "object", + "required": [ + "feature", + "value", + "units", + "section", + "summary", + "ordinance_text", + "explanation" + ], + "additionalProperties": false, + "properties": { + "feature": { + "type": "string", + "description": "The ordinance feature being extracted. Must be one of the enumerated feature IDs.", + "enum": [ + "structures (participating)", + "structures (non-participating)", + "property line (participating)", + "property line (non-participating)", + "roads", + "railroads", + "transmission", + "water", + "public conservation lands", + "other wecs", + "noise", + "maximum turbine height", + "maximum project size", + "minimum lot size", + "maximum lot size", + "shadow flicker", + "tower density", + "blade clearance", + "color", + "decommissioning", + "lighting", + "prohibitions", + "visual impact", + "repowering", + "climbing prevention", + "signage", + "soil", + "primary use districts", + "special use districts", + "accessory use districts", + "prohibited use districts" + ] + }, + "value": { + "description": "The extracted ordinance value. Type and format depend on the feature type. For setbacks and numerical restrictions: either a numerical distance value OR a multiplier value. For qualitative restrictions: typically null (summary contains the text). For districts: an array of district names. Can be null if no value found.", + "anyOf": [ + {"type": "number"}, + {"type": "string"}, + {"type": "array", "items": {"type": "string"}}, + {"type": "null"} + ] + }, + "units": { + "type": ["string", "null"], + "description": "Units for the extracted value. For distance setbacks: 'feet' or 'meters'. For multiplier-based setbacks: one of 'tip-height-multiplier', 'hub-height-multiplier', or 'rotor-diameter-multiplier'. For noise: typically 'dBA'. For shadow flicker: typically 'hr/year'. For lot sizes: area units like 'acres' or 'square feet'. Can be null if no value or if value is qualitative text." + }, + "section": { + "type": ["string", "null"], + "description": "The section title or number from the ordinance where this requirement is found (e.g., 'SECTION 1308 – Performance / Construction Standards'). Include numerical labels if provided. Null if no section identifier is available." + }, + "summary": { + "type": "string", + "description": "A short summary of the relevant ordinance requirement using direct text excerpts and quotes as much as possible. If multiple options exist and a selection was made, list all other options and their conditions in the summary. For qualitative features (color, decommissioning, lighting, prohibitions, visual impact, repowering, climbing prevention, signage, soil), this is the primary output field and should contain a direct ordinance excerpt. For numeric features, summary must support the same requirement used to extract value and units. Must be a non-null, non-empty string. Do not output absence placeholders (for example, 'No explicit ... found'); omit the feature instead when no requirement is present." + }, + "ordinance_text": { + "type": "string", + "description": "The complete relevant text excerpt containing the ordinance information, copy-pasted verbatim from the source document. The first sentence must be the one that corresponds to the extracted value and summary, reproduced in full without elision. After that first sentence, gather any other passages in the document that bear on this same requirement, whether they appear before or after it, and join them with an ellipsis ('...') in the order they appear in the document. Use the ellipsis to skip over text that is not relevant so the excerpt stays focused while still carrying every passage that supports the extracted value, units, or qualitative requirement. Every character outside of the ellipses must appear exactly as written in the source: no paraphrasing, summarizing, normalization, added context, or commentary. Must be a non-null, non-empty string." + }, + "explanation": { + "type": "string", + "description": "Brief rationale explaining why this row matches the selected feature under this schema. Reference the specific evidence in summary and how it supports the extracted value and units or, for qualitative features, the inclusion criteria. Must be a non-null, non-empty string and must not use absence placeholders." + } + } + } + } + }, + "$scope": "Legally enacted requirements/restrictions that apply to large, commercial, or utility-scale wind energy systems, wind energy conversion systems (WECS), wind turbines, wind farms, or similar electricity generation facilities, including their associated components where relevant. Use ordinance definitions, system classifications, and section context to determine applicability, including stated height, rotor diameter, rated capacity (often 1MW+), and/or offsite electricity generation/sale criteria. If the text uses generic terms like 'wind energy system', 'WECS', or 'wind turbine', treat it as in scope only when definitions or section context clearly establish that the provision governs utility-scale systems, including provisions that explicitly apply to all wind system sizes. **OUT OF SCOPE**: rules/regulations that apply only to small, micro, private, personal, onsite, residential, or other clearly non-commercial wind systems; meteorological or wind resource assessment towers; and unrelated energy technologies or structures unless the text **explicitly** also governs utility-scale wind systems or their associated components. Proposed, future, draft, or contingent requirements that are not currently effective as written are also out of scope.", + "$core_principles": { + "strict_evidence_gate": { + "description": "Extract a feature only when the ordinance text explicitly states a requirement, definition, or prohibition for that same feature. Never infer, assume, extrapolate, or guess from related context, implications, headings, or nearby provisions. Chapter titles, section titles, captions, parenthetical aliases, tables of contents, navigation lists, cross-reference lists, and purpose/intent/applicability statements are not valid evidence by themselves unless they also quote or restate the operative requirement, definition, or prohibition. If the ordinance points to an outside document or standard without restating the controlling requirement in the ordinance text itself, do not import missing values from that outside source." + }, + "data_omission": { + "description": "Emit only positively matched features. If a feature is not explicitly present, omit it entirely rather than returning placeholder text. For qualitative features, use value=null and units=null only when an enacted, explicit requirement or definition for that same feature is present. For numeric features, extract only when an explicit numeric threshold is stated in the ordinance text; otherwise omit the feature instead of returning null, empty, or qualitative-only values. Never emit absence placeholders such as 'not found', 'no explicit requirement', 'none', or similar text in any field." + }, + "numeric_prioritization": { + "description": "When multiple numeric values apply to the same feature, keep one row and select the controlling most restrictive value for that feature. Restrictiveness rules: setbacks, including 'other wecs' -> choose the largest minimum separation distance; noise -> choose the lowest maximum allowable noise level; maximum turbine height -> choose the lowest maximum allowable height measured from ground level; maximum project size -> choose the lowest maximum allowable capacity when comparing capacity limits, or the lowest maximum turbine count when comparing turbine-count limits; minimum lot size -> choose the largest minimum required area; maximum lot size -> choose the smallest maximum allowable area; shadow flicker -> choose the lowest maximum allowable exposure, treating an explicit total prohibition as 0 hours per year; tower density -> choose the largest minimum required spacing between turbines within the same project; blade clearance -> choose the largest minimum required distance between the lowest blade tip and ground level. Compare only requirements applicable to in-scope large-scale wind systems and the same feature, preserving participating versus non-participating distinctions. Compare values only on equivalent measurement bases: do not rank raw numbers across different units, height or diameter multiplier bases, noise metrics or averaging periods, shadow-flicker reporting periods, or capacity versus turbine-count limits. Equivalent units may be reconciled for comparison, but report the selected value in its original units according to the feature-specific rules. For formulas, additive distances, and 'greater of' or 'lesser of' clauses, preserve the ordinance's actual controlling expression and follow the feature-specific value and units rules; do not select an isolated coefficient or threshold that changes its meaning. Do not invent turbine dimensions or other missing inputs to rank incomparable requirements. Where the ordinance explicitly identifies a controlling requirement, use it; otherwise do not claim that incomparable limits have a single most restrictive value. Keep condition-specific alternatives and independently applicable limits in summary only when the ordinance text explicitly establishes their applicability to the same feature for wind systems. Identify the conditions and units for each alternative, and ensure the selected value, units, section, and supporting excerpt refer to the same requirement. For qualitative features and district lists, do not impose a numeric restrictiveness ranking; follow their feature-specific extraction rules." + } + }, + "$definitions": { + "system_size_context": { + "description": "CRITICAL CONTEXT: Only extract ordinances for systems that would typically be defined as large, commercial, or utility-scale wind energy systems based on the text itself — for example, systems intended for offsite electricity generation or sale, or those above thresholds such as height, rotor diameter, or rated capacity (often 1MW+). Do NOT consider any text that applies **only** to smaller or clearly non-commercial systems (e.g., 'small', 'micro', 'private', 'personal', 'onsite', residential systems) or to meteorological towers." + }, + "setback_features": { + "description": "Setback features for utility-scale wind-related components. Treat each setback feature independently; do NOT cross-apply a setback unless the ordinance text **explicitly** states that it applies to multiple feature types. When a single clause explicitly lists multiple target types and one shared numeric setback, emit one row per explicitly listed feature using the same numeric value/units and cite the same clause in summary. Never infer a road or right-of-way setback from a property-line setback unless the ordinance text explicitly equates the property line with a road right-of-way or other right-of-way/easement boundary for that same requirement. Apply the shared numeric prioritization rules in $core_principles when multiple numeric values explicitly apply to the same feature for wind systems.", + "properties": { + "structures (participating)": { + "description": "Setback requirements from occupied dwellings, buildings, structures, or residences where the property owner is a **participating** owner. Require an explicit ownership distinction and either a stated setback for participating owners or a clause allowing them to waive the setback completely or reduce it by an unspecified amount. For such a waiver or reduction, set value and units to null and quote the clause in summary. If the ordinance specifies that participating owners must abide by the same setbacks as non-participating owners, use the same value for both. VALUE: For distance-based setbacks, provide numerical distance. For multiplier-based setbacks (e.g., '1.5 times the total height'), treat fall zone as 1x height multiplier. If multiple multiplier values exist, select the largest. UNITS: Use 'feet' or 'meters' for distance, or 'tip-height-multiplier', 'hub-height-multiplier', or 'rotor-diameter-multiplier' for multiplier-based. Default to 'tip-height-multiplier' unless text explicitly states hub height or rotor diameter. If text includes an adder value (e.g., 'multiplier * height + 100 feet'), convert adder to feet and note in summary. If text includes 'the greater of' or minimum threshold clauses, note the minimum distance in summary. If text includes 'the lesser of' or maximum limit clauses, note the maximum distance in summary. IGNORE: Do not respond based on setbacks from property lines, lot lines, facility perimeters, parcels, subdivisions, roads, railroads, transmission lines, wetlands, or public conservation lands. CLARIFICATION: Dwelling units and occupied buildings **are not equivalent** to property lines unless the text **explicitly** makes that connection. Only focus on large-scale systems as defined in system_size_context." + }, + "structures (non-participating)": { + "description": "Setback requirements from occupied dwellings, buildings, structures, or residences where the property owner is a **non-participating** owner (i.e., has not signed a waiver or agreement). ONLY extract if the ordinance explicitly distinguishes between participating and non-participating owners AND specifies a numerical value for non-participating owners. If no distinction is made, use this feature for the general structure setback. VALUE & UNITS: Same rules as 'structures (participating)'. IGNORE & CLARIFICATIONS: Same as 'structures (participating)'." + }, + "property line (participating)": { + "description": "Setback requirements from property lines, lot lines, facility perimeters, parcels, or subdivisions where the property owner is a **participating** owner. Participating owners may be able to sign a waiver or enter an agreement to reduce or completely eliminate the setback requirement. ONLY extract if the ordinance explicitly distinguishes between participating and non-participating owners AND specifies a numerical value for participating property owners. If participating property owners can completely waive the setback, leave value as null. VALUE & UNITS: Same rules as 'structures (participating)'. IGNORE: Do not respond based on setbacks from structures, roads, railroads, transmission lines, wetlands, or public conservation lands. CLARIFICATION: Dwelling units, structures, occupied buildings, and residences **are not equivalent** to property lines or parcel boundaries unless the text **explicitly** makes that connection. Only focus on large-scale systems." + }, + "property line (non-participating)": { + "description": "Setback requirements from property lines, lot lines, facility perimeters, parcels, or subdivisions where the property owner is a **non-participating** owner. ONLY extract if the ordinance explicitly distinguishes between participating and non-participating owners. If no distinction is made, use this feature for the general property line setback. VALUE & UNITS: Same rules as 'property line (participating)'. IGNORE & CLARIFICATIONS: Same as 'property line (participating)'." + }, + "roads": { + "description": "Setback requirements from roads. Roads may also be labeled as rights-of-way. Before extracting, verify this is truly a road setback and not better classified as a property line setback. VALUE & UNITS: Same rules as 'structures (participating)'. IGNORE: Do not respond based on setbacks from structures, property lines, railroads, transmission lines, wetlands, or public conservation lands. Only focus on large-scale systems." + }, + "railroads": { + "description": "Setback requirements from railroads. VALUE & UNITS: Same rules as 'structures (participating)'. IGNORE: Do not respond based on setbacks from structures, property lines, roads, transmission lines, wetlands, or public conservation lands. Only focus on large-scale systems." + }, + "transmission": { + "description": "Setback requirements from overhead electrical transmission lines, overhead utility lines, utility easements, utility lines, power lines, electrical lines, or transmission lines. VALUE & UNITS: Same rules as 'structures (participating)'. IGNORE: Do not respond based on setbacks from structures, property lines, roads, railroads, wetlands, or public conservation lands. Only focus on large-scale systems." + }, + "water": { + "description": "Setback requirements from lakes, reservoirs, streams, rivers, or wetlands. VALUE & UNITS: Same rules as 'structures (participating)'. IGNORE: Do not respond based on setbacks from structures, property lines, roads, railroads, transmission lines, or public conservation lands. CLARIFICATION: Public conservation lands (or similar) **are not equivalent** to wetlands (or similar) unless the text **explicitly** makes that connection. Only focus on large-scale systems." + }, + "public conservation lands": { + "description": "Setback requirements from public conservation lands, natural resource protection areas, or preservation areas. VALUE & UNITS: Same rules as 'structures (participating)'. IGNORE: Do not respond based on setbacks from structures, property lines, roads, railroads, transmission lines, or wetlands. CLARIFICATION: Wetlands, public parks, public places, other public land **are not equivalent** to public conservation lands unless the text **explicitly** makes that connection. Only focus on large-scale systems." + } + } + }, + "numerical_restrictions": { + "description": "Non-setback numerical restriction features. Only extract if numerical values are explicitly given in the text.", + "properties": { + "other wecs": { + "description": "Extract the **minimum** required separation distance between the wind energy conversion system being installed and other existing or planned wind energy conversion systems (i.e., spacing between turbines in different projects or installations). VALUE: Numerical value representing the minimum separation distance. If multiple values are mentioned, select the most restrictive (largest minimum) value. UNITS: Typically 'feet' or 'meters', but may also be a multiplier ('tip-height-multiplier', 'hub-height-multiplier', 'rotor-diameter-multiplier'). VERIFICATION: Ensure this is a requirement that has been explicitly enacted in the ordinance, not just a definition. Only extract if the text contains explicit numerical restrictions, and only focus on large-scale systems." + }, + "noise": { + "description": "Extract the maximum noise level allowed for wind energy conversion systems. VALUE: Numerical value representing the maximum allowable noise level. If multiple values are mentioned, select the most restrictive (lowest maximum) value. UNITS: Assume standard units for noise are 'dBA' unless explicitly stated otherwise. VERIFICATION: Ensure this is an enacted requirement, not just a definition. Only extract if explicit numerical restrictions exist. Only focus on large-scale systems." + }, + "maximum turbine height": { + "description": "Extract the maximum turbine height allowed. CRITICAL: Maximum turbine height should be given in total feet or meters from the ground and **should NOT be relative to some other feature like structure height, airspace level, etc.** VALUE: Numerical value representing the maximum allowable turbine height measured from ground level. If multiple values exist, select the most restrictive (lowest maximum). UNITS: Typically 'feet' or 'meters'. VERIFICATION: Ensure this is an absolute height limit from the ground, not a relative measurement. Only extract enacted requirements with explicit numerical restrictions. Only focus on large-scale systems." + }, + "maximum project size": { + "description": "Extract the maximum project size or total installation allowed. Maximum project size is typically specified as a maximum system size value (e.g., in MW or nameplate capacity) OR as a maximum number of turbines. It should NOT be specified as a maximum area. VALUE: Numerical value representing either maximum capacity (MW) or maximum number of turbines. If multiple limits exist, select the most restrictive. Clearly indicate in the summary whether this is a capacity limit or turbine count limit. UNITS: Typically 'MW', 'megawatts', 'kilowatts', or 'number of turbines'. VERIFICATION: Only extract enacted requirements with explicit numerical restrictions. Only focus on large-scale systems." + }, + "minimum lot size": { + "description": "Extract the **minimum** lot, parcel, or tract size allowed for wind energy system installation. Minimum lot size should **always** be specified as an area value. VALUE: Numerical value representing the minimum required lot/parcel/tract area. If multiple values exist, select the most restrictive (largest minimum). UNITS: Area units such as 'acres', 'square feet', 'square meters', 'hectares'. Ensure the units represent area, not linear distance. VERIFICATION: Only extract enacted requirements with explicit numerical restrictions. Only focus on large-scale systems." + }, + "maximum lot size": { + "description": "Extract the **maximum** lot, parcel, or tract size allowed for wind energy system installation. Maximum lot size should **always** be specified as an area value. VALUE: Numerical value representing the maximum allowed lot/parcel/tract area. If multiple values exist, select the most restrictive (smallest maximum). UNITS: Area units such as 'acres', 'square feet', 'square meters', 'hectares'. Ensure the units represent area, not linear distance. VERIFICATION: Only extract enacted requirements with explicit numerical restrictions. Only focus on large-scale systems." + }, + "shadow flicker": { + "description": "Extract the maximum shadow flicker allowed. If the text prohibits shadow flicker entirely (e.g., 'shadow flicker is prohibited'), treat this as a maximum value of 0 hours per year. VALUE: Numerical value representing the maximum allowable shadow flicker. If prohibition exists, use 0. If multiple values exist, select the most restrictive (lowest maximum). UNITS: Assume standard units for shadow flicker are 'hr/year' (hours per year) unless explicitly stated otherwise. May also be 'hours per year' or 'hr/yr'. VERIFICATION: Only extract enacted requirements. Note prohibition explicitly in summary if applicable. Only focus on large-scale systems." + }, + "tower density": { + "description": "Extract the **minimum** allowed spacing between individual turbines within the same project or facility. CRITICAL: Do **NOT** try to infer the spacing requirement based on other restrictions such as setbacks from facility perimeters, property lines, etc. Only extract if there is an explicit spacing requirement between turbines. VALUE: Numerical value representing the minimum spacing between turbines. UNITS: May be distance units ('feet', 'meters') OR multiplier units ('tip-height-multiplier', 'hub-height-multiplier', 'rotor-diameter-multiplier'). Assume standard units for spacing are one of these. VERIFICATION: Only extract if explicitly stated. Do not infer from other setback requirements. Only focus on large-scale systems." + }, + "blade clearance": { + "description": "Extract the minimum blade clearance allowed (i.e., minimum distance between blade tip at lowest point and ground level or final grade). VALUE: Numerical value representing the minimum clearance between blade tip and ground. If multiple values exist, select the most restrictive (largest minimum) value. UNITS: Typically 'feet' or 'meters'. VERIFICATION: Only extract enacted requirements with explicit numerical restrictions. Only focus on large-scale systems." + } + } + }, + "qualitative_restrictions": { + "description": "Non-numerical restriction features that require text extraction", + "properties": { + "color": { + "description": "Extract color or finish requirements for wind energy conversion systems, including turbines, support structures, accessory buildings, poles, antennas, and other external facilities. VALUE: Typically null (the summary contains all relevant information). SUMMARY: Extract the full text describing color requirements, using direct excerpts and quotes. Include requirements about paint color, finish, neutral colors, galvanization, visibility minimization, blending with surroundings, and repainting obligations. VERIFICATION: Only extract if explicitly enacted. Only focus on large-scale systems." + }, + "decommissioning": { + "description": "Extract decommissioning requirements for wind energy conversion systems. This includes requirements for removal of the facility upon abandonment, cessation of operation, or end of useful life. VALUE: Typically null. SUMMARY: Extract all text describing decommissioning requirements, using direct excerpts. Include: timeline for removal (e.g., 'within 90 days of ceasing operation for 12 months'), scope of removal (e.g., 'remove all machinery, equipment, shelters to 5 feet below grade'), site restoration requirements (e.g., 'restore to natural condition'), financial assurance requirements (e.g., 'post bond for 150% of removal cost'), and any requirements for decommissioning plans or cost estimates. VERIFICATION: Only extract if explicitly enacted. Only focus on large-scale systems." + }, + "lighting": { + "description": "Extract lighting requirements for wind energy conversion systems. This includes requirements about when lighting is required, prohibited, or restricted, as well as specifications about the type, color, or intensity of lighting. VALUE: Typically null. SUMMARY: Extract all text describing lighting requirements, prohibitions, or restrictions, using direct excerpts. Include FAA lighting requirements, security lighting restrictions, prohibition of unnecessary lighting, and any specific technical specifications. VERIFICATION: Only extract if explicitly enacted. Only focus on large-scale systems." + }, + "prohibitions": { + "description": "Extract any prohibitions, moratoria, or bans on wind energy conversion systems. VALUE: Typically null. SUMMARY: Extract all text describing prohibitions, moratoria, or bans. CRITICAL: Only extract prohibitions that are **unconditional** and **currently in effect** (not proposed or temporary). If the jurisdiction allows wind energy systems in any capacity (with permits, conditions, etc.), this is NOT a prohibition. If text describes areas where wind is not allowed, this should be extracted under 'prohibited use districts' instead. Only focus on large-scale systems." + }, + "visual impact": { + "description": "Extract visual impact **assessment** requirements for wind energy conversion systems. This refers to requirements to conduct, submit, or provide visual impact studies, analyses, or assessments as part of the permitting process. VALUE: Typically null. SUMMARY: Extract all text describing visual impact assessment requirements, using direct excerpts. Include requirements for: submission of photographs or renderings showing before/after views, superimposed images of proposed systems on current site conditions, viewshed analyses, photographic simulations, or other visual impact documentation. VERIFICATION: Focus on assessment/study requirements, not general aesthetic requirements. Only extract if explicitly enacted. Only focus on large-scale systems." + }, + "repowering": { + "description": "Extract requirements or regulations specific to **repowering** of wind energy systems (i.e., replacing or upgrading existing turbines with new equipment). This is distinct from initial installation or decommissioning. VALUE: Typically null. SUMMARY: Extract all text describing repowering-specific requirements, using direct excerpts. Include requirements about: conditions under which repowering is allowed, whether repowered systems must meet new/updated standards, permitting requirements specific to repowering, and any distinctions between repowering and new installation. VERIFICATION: Only extract requirements that are explicitly about repowering, replacement, or upgrade of existing systems. Only focus on large-scale systems." + }, + "climbing prevention": { + "description": "Extract climbing prevention requirements for wind turbine towers. This includes requirements for anti-climbing devices, access ladder positioning, tower access doors, and physical security measures to prevent unauthorized climbing. VALUE: Typically null. SUMMARY: Extract all text describing climbing prevention requirements, using direct excerpts. Include: minimum height requirements for access ladders or climbing apparatus (e.g., 'ladders must be 15 feet above ground level'), door requirements (e.g., 'solid steel doors with locking devices'), locking requirements (e.g., 'kept locked at all times'), fencing requirements related to tower access, and any other physical security measures. VERIFICATION: Only extract if explicitly enacted. Only focus on large-scale systems." + }, + "signage": { + "description": "Extract signage requirements for wind energy conversion systems. This includes requirements for identification signs, prohibition of advertising, emergency contact information, and warning signs. VALUE: Typically null. SUMMARY: Extract all text describing signage requirements, using direct excerpts. Include: prohibition of off-premise or advertising signage, requirements for identification signs with facility owner name, requirements for 24-hour emergency telephone numbers, requirements for warning signs, and any specifications about sign size, placement, or content. VERIFICATION: Only extract if explicitly enacted. Only focus on large-scale systems." + }, + "soil": { + "description": "Extract soil, erosion, and/or sediment control requirements for wind energy system installation and operation. VALUE: Typically null. SUMMARY: Extract all text describing soil, erosion control, or sediment control requirements, using direct excerpts. Include: requirements for erosion and sediment control plans, best management practices, soil conservation measures, restoration of disturbed areas, and prevention of soil degradation during construction or operation. VERIFICATION: Only extract if explicitly enacted. Only focus on large-scale systems." + } + } + }, + "permitted_use_districts": { + "description": "Zoning districts where wind energy systems are permitted under various conditions", + "properties": { + "primary use districts": { + "description": "Extract all zoning districts where large wind energy systems are permitted as primary use or similar (e.g., permitted by right, without special conditions or approval beyond standard permitting). Consider any wind energy overlay districts as primary use districts. VALUE: An array of district names/codes as strings (e.g., ['Agricultural A-1', 'Agricultural A-2', 'Industrial I-1']). If no districts allow primary use, use null. SUMMARY: Provide a brief summary with direct text excerpts describing which districts allow wind as primary use and under what general conditions. SECTION: Include the section title/number where this information is found. CLARIFICATION: Large wind energy systems (WES) may also be referred to as: wind turbines, wind energy conversion systems (WECS), wind energy facilities (WEF), wind energy turbines (WET), large wind energy systems (LWES), utility-scale wind energy turbines (UWET), commercial wind energy conversion systems (CWECS), alternate energy systems (AES), commercial energy production systems (CEPCS), or similar terminology. Only focus on large-scale systems as defined in system_size_context." + }, + "special use districts": { + "description": "Extract all zoning districts where large wind energy systems are permitted as special use or similar (e.g., requires approval by zoning appeals board, planning commission, special use permit, conditional use permit, or meeting certain conditions like completing a specific permitting process). Do NOT include wind overlay districts (those should be classified as primary use). VALUE: An array of district names/codes as strings. If no districts require special use approval, use null. SUMMARY: Provide summary with direct text excerpts. SECTION: Include section title/number. CLARIFICATION: Same alternative terminology as in 'primary use districts'. Only focus on large-scale systems." + }, + "accessory use districts": { + "description": "Extract all zoning districts where large wind energy systems are permitted as accessory use or similar (e.g., when integrated with an existing structure, secondary to another primary use, or as an accessory to a principal use). Do NOT include wind overlay districts (classify as primary use). Do NOT include districts where wind is only allowed as accessory but also separately as primary or special use. VALUE: An array of district names/codes as strings. If no districts specify accessory use, use null. SUMMARY: Provide summary with direct text excerpts explaining the accessory use conditions. SECTION: Include section title/number. CLARIFICATION: Same alternative terminology as in 'primary use districts'. Only focus on large-scale systems." + }, + "prohibited use districts": { + "description": "Extract all zoning districts where large wind energy systems are prohibited or similar (e.g., where wind energy systems are not allowed, banned, or explicitly excluded). CRITICAL: Only output specific districts where wind energy systems are prohibited **unconditionally**. Do not include districts where wind might be allowed with special approval or under certain conditions. If wind is allowed in any capacity in a district, it should not be listed here. VALUE: An array of district names/codes as strings. If no districts prohibit wind unconditionally, use null. SUMMARY: Provide summary with direct text excerpts clearly stating the prohibition. SECTION: Include section title/number. CLARIFICATION: Same alternative terminology as in 'primary use districts'. Only focus on large-scale systems." + } + } + } + }, + "$examples": [ + { + "feature": "property line (non-participating)", + "value": 1.5, + "units": "tip-height-multiplier", + "section": "SECTION 1308 – Performance / Construction Standards", + "summary": "WECS must be set back from property lines by at least 1.5 times their total height. This is a turbine-height multiplier, not a fixed distance; the separate 640-foot residence setback does not replace the property-line requirement.", + "ordinance_text": "Setback requirements for WECS: Property Lines, roads, overhead utility or transmission lines, electrical substations, communication or meteorological towers shall be 1.5 times the total height, and shall be Six Hundred Forty (640) feet from the nearest residence.", + "explanation": "The clause explicitly includes property lines in the 1.5-times-total-height setback. Because it does not distinguish participating from non-participating owners, the general property-line rule applies here; total height maps to tip-height-multiplier rather than hub height or rotor diameter." + }, + { + "feature": "roads", + "value": 1.5, + "units": "tip-height-multiplier", + "section": "SECTION 1308 – Performance / Construction Standards", + "summary": "The minimum road setback is 1.5 times the total WECS height. The 640-foot distance in the same clause applies to residences, not as an additional road setback.", + "ordinance_text": "Setback requirements for WECS: Property Lines, roads, overhead utility or transmission lines, electrical substations, communication or meteorological towers shall be 1.5 times the total height, and shall be Six Hundred Forty (640) feet from the nearest residence.", + "explanation": "Roads are explicitly named among the receptors subject to the height-based setback, supporting value 1.5 and units tip-height-multiplier. The residence distance belongs to a different receptor and is not added to the road requirement." + }, + { + "feature": "noise", + "value": 50, + "units": "dBA", + "section": "SECTION 1308 – Performance / Construction Standards", + "summary": "Noise from the WECS or facility is capped at 50 decibels, evaluated at ground level at the property lines or nearest residence. A qualified engineer must sign the measurements to confirm compliance.", + "ordinance_text": "The WECS and or Facility shall not generate noise in excess of Fifty (50) decibel levels at ground level to the property lines or at the nearest residence. Such measurements shall be signed by a qualified engineer, stating that noise levels are being met, per ordinance.", + "explanation": "The clause sets an explicit maximum sound level of 50, so it matches the noise feature rather than a setback or operating-hours restriction. The measurement locations and engineer certification qualify that same noise limit; the excerpt does not explicitly specify A-weighting." + }, + { + "feature": "blade clearance", + "value": 30, + "units": "feet", + "section": "SECTION 1308 – Performance / Construction Standards", + "summary": "The lowest blade tip must remain at least 30 feet above ground level or final grade. This regulates clearance beneath the rotor rather than the turbine's maximum height.", + "ordinance_text": "Minimum clearance between blade tip and ground level or final grade is to be Thirty (30) feet.", + "explanation": "The requirement explicitly measures the minimum gap between the blade tip and the ground, matching blade clearance with value 30 and units feet, not maximum turbine height." + }, + { + "feature": "decommissioning", + "value": null, + "units": null, + "section": "SECTION 1306 – General Requirements and SECTION 1308 – Performance / Construction Standards", + "summary": "After 12 months without operation, the company must remove the WECS and facility within the following 90 days. A signed maintenance and removal agreement also binds applicants and subsequent property owners to maintenance or removal upon abandonment.", + "ordinance_text": "At such time that a WECS ceases operation for a period of Twelve (12) months, the company shall physically remove the WECS and facility within Ninety (90) days from the Twelve (12) month period from when the operation ceased. ... a copy of the Facility Maintenance and Removal Agreement signed by all applicants that binds the applicants and all successors in interest to the property to properly maintain and or remove the facility upon abandonment in compliance with the terms of this Ordinance.", + "explanation": "Mandatory removal after prolonged non-operation and a binding removal agreement are decommissioning obligations. The timing and agreement terms belong in summary; value and units remain null because this is a qualitative feature rather than a single numeric threshold." + }, + { + "feature": "special use districts", + "value": ["Agricultural A-1", "Agricultural A-2", "Business B-1", "Business B-2", "Business B-3", "Industrial I-1", "Industrial I-2"], + "units": null, + "section": "SECTION 1304 – Permanent Special Exceptions", + "summary": "WECS placement requires permanent special-exception approval from the Decatur County Board of Zoning Appeals in seven districts: Agricultural A-1 and A-2, Business B-1 through B-3, and Industrial I-1 and I-2. These are special-use allowances, not by-right permissions.", + "ordinance_text": "The following are permitted as permanent special exceptions in the Agricultural A-1 & A-2 zoning districts; in the Business B-1, B-2 and B-3 zoning districts; and in the Industrial I-1 and I-2 zoning districts when approved by the Decatur County Board of Zoning Appeals: (C) Placement of a WECS as permitted under the zoning districts A-1, A-2, B-1, B-2, B-3, I-1 and I-2.", + "explanation": "The text explicitly links WECS placement in each listed district to special-exception approval by the zoning appeals board. All seven districts therefore belong in one special use districts array, with units null because district names are categorical." + } + ], + "$instructions": { + "general": [ + "Extract ordinance requirements ONLY for large, commercial, or utility-scale wind energy systems (typically intended for offsite electricity generation or sale, often 1MW+ or above specified thresholds). Do NOT extract requirements that apply only to small, micro, private, personal, onsite, or residential systems, or to meteorological towers.", + "Use direct text excerpts and quotes in the summary field as much as possible. If multiple options exist and you make a selection, list all other options and their conditions in the summary.", + "Only extract enacted provisions supported by the feature rules. Do not extract definitions unless they also constitute requirements.", + "Pay careful attention to clarifying text in parentheses, footnotes, and cross-references.", + "When multiple values are mentioned for the same feature, select the most restrictive value (largest minimum, lowest maximum, etc.) and note the other options in the summary.", + "Ensure units are expressed using standard, conventional names (e.g., 'feet', 'meters', 'dBA', 'hr/year', 'tip-height-multiplier').", + "Every row must include an ordinance_text holding the complete relevant excerpt for the ordinance being extracted, copy-pasted verbatim from the source document. Its first sentence must be the start of the ordinance text for this extraction, reproduced in full; after that first sentence an ellipsis ('...') may be used to drop irrelevant passages. ordinance_text is never paraphrased or normalized — every character outside the ellipses appears exactly as written in the source.", + "Every row must include an explanation that briefly justifies why the cited summary evidence matches the selected feature under this schema's rules.", + "Emit only positively matched features. Never emit a row to explain why a feature does not apply.", + "If the ordinance states no explicit requirement for a feature, omit that feature from the outputs array.", + "The outputs array is a sparse long-form extraction table and does not need to contain every enumerated feature.", + "Tables, table footnotes, and labeled graphics count as valid ordinance evidence when they state the controlling requirement; preserve the relevant table cell or footnote context in summary.", + "If ordinance text shows an amended or superseding requirement, extract the current operative requirement as written rather than a superseded historical value unless the ordinance text clearly keeps both rules active.", + "If text is suggestive but not explicit for the target feature, omit the feature." + ], + "setback_specific": [ + "For distance-based setbacks, extract the numerical value and units (feet/meters).", + "For multiplier-based setbacks, extract the multiplier value and type (tip-height-multiplier, hub-height-multiplier, rotor-diameter-multiplier). Default to tip-height-multiplier unless text explicitly specifies hub or rotor diameter.", + "Treat any mention of 'fall zone' as a tip-height-multiplier of 1.", + "If text includes an adder (e.g., 'multiplier × height + X feet'), note this in the summary. Adder values should be converted to feet.", + "If text includes conditional minimums ('the greater of', 'no less than'), note minimum threshold in summary.", + "If text includes conditional maximums ('the lesser of', 'no more than'), note maximum limit in summary.", + "For structures and property lines: Check if ordinance distinguishes between participating and non-participating owners. If yes, extract separate values for each. If no distinction, use the non-participating feature for the general setback.", + "For roads: Verify the requirement is truly for roads and not better classified as a property line setback.", + "When one setback clause explicitly names multiple target features and provides one shared numeric threshold, emit one row per explicitly named feature using the same threshold and units." + ], + "restriction_specific": [ + "For numerical limits: Extract the numeric value and standard units. If multiple values exist, select the most restrictive.", + "For shadow flicker: If prohibited, use value of 0 with units 'hr/year'.", + "For maximum turbine height: Must be absolute height from ground, not relative to other features.", + "For maximum project size: Specify in summary whether limit is capacity-based (MW) or count-based (number of turbines).", + "For minimum/maximum lot size: Must be area values, not linear distances.", + "For tower density: Do not infer from other setback requirements; only extract if explicitly stated as spacing between turbines.", + "For qualitative restrictions: Extract full relevant text in summary field using direct excerpts and quotes. Value is typically null.", + "For prohibitions: Only extract if unconditional and currently in effect. If jurisdiction allows wind with any conditions, this is not a prohibition." + ], + "district_specific": [ + "For permitted use districts: Extract array of district names/codes. Consider overlay districts as primary use.", + "For special use districts: Include districts requiring board approval, special permits, or conditional use permits.", + "For accessory use districts: Include districts where wind is only allowed as accessory/secondary to another use.", + "For prohibited use districts: Only include districts with unconditional prohibitions currently in effect.", + "Use the exact district names/codes as they appear in the ordinance text." + ] + }, + "$qa_checklist": [ + "Enforce uniqueness by feature with len(outputs) == len(unique(feature values)); if duplicates exist, merge or drop invalid rows until equality is true.", + "Every row must have non-null, non-empty strings for summary and explanation.", + "Explanation must explicitly tie summary evidence to the selected feature and must not contradict feature inclusion/exclusion criteria.", + "For every numeric feature row, require numeric value and non-null units.", + "Remove any numeric-feature row derived only from qualitative language (for example 'shall not encroach' or 'comply with standards') when no numeric threshold is quoted.", + "For qualitative features, set value and units to null.", + "If summary or explanation indicates the feature is not applicable, omit the row.", + "If a feature fails any check, omit it rather than returning a partial row." + ], + "$qualitative_features": [ + "color", + "decommissioning", + "lighting", + "prohibitions", + "visual impact", + "repowering", + "climbing prevention", + "signage", + "soil" + ] +} diff --git a/compass/plugin/one_shot/components.py b/compass/plugin/one_shot/components.py index 84162441f..7cfa61135 100644 --- a/compass/plugin/one_shot/components.py +++ b/compass/plugin/one_shot/components.py @@ -113,9 +113,6 @@ no paraphrasing or rewriting.** - The output must consist **only** of contiguous or discontiguous verbatim \ blocks copied from the input. -- The only allowed change is to remove irrelevant sections of text. You can \ -remove irrelevant text from within sections, but you cannot add any new text \ -or modify the text you keep in any way. - If **no relevant text** is found, return null. # TEXT # diff --git a/compass/plugin/ordinance.py b/compass/plugin/ordinance.py index cd14b29d1..11268a999 100644 --- a/compass/plugin/ordinance.py +++ b/compass/plugin/ordinance.py @@ -511,9 +511,6 @@ class PromptBasedTextExtractor(LLMCaller, BaseTextExtractor, ABC): **Absolutely no paraphrasing or rewriting.** - The output must consist **only** of contiguous or discontiguous verbatim blocks copied from the input. - - The only allowed change is to remove irrelevant sections of text. - You can remove irrelevant text from within sections, but you cannot - add any new text or modify the text you keep in any way. - If **no relevant text** is found, return the response: 'No relevant text.' """ diff --git a/compass/scripts/download.py b/compass/scripts/download.py index 629671d5a..0e30c1bec 100644 --- a/compass/scripts/download.py +++ b/compass/scripts/download.py @@ -1292,11 +1292,11 @@ def _ord_doc_sorting_key(doc): ) shortest_text_length = -1 * len(doc.text) return ( + latest_year or _NEG_INF, num_collection_steps_found_doc, best_step, most_confident_collection, best_docs_from_website, - latest_year or _NEG_INF, prefer_pdf_files, highest_jurisdiction_score, shortest_text_length, diff --git a/compass/services/docling.py b/compass/services/docling.py index 81a56d8d6..3f7085a70 100644 --- a/compass/services/docling.py +++ b/compass/services/docling.py @@ -137,7 +137,10 @@ def _read_docling_catch_error( pdf_pipeline_options=pdf_pipeline_options, **kwargs, ) - except Exception: # ruff:ignore[blind-except] + except Exception: + logger.exception( + "Error reading document with Docling for source: %s", file_source + ) return MDDocument(pages=[], attrs={"doc_type": "unknown"}) diff --git a/compass/validation/graphs.py b/compass/validation/graphs.py index f1bc940f7..409d284db 100644 --- a/compass/validation/graphs.py +++ b/compass/validation/graphs.py @@ -104,7 +104,8 @@ def setup_graph_correct_document_type(**kwargs): "* If the text explicitly states adoption/approval/enactment " "status, rely only on that.\n" "* If the text contains proposal-stage indicators (e.g., " - '"proposed ordinance," "notice of proposed rulemaking," "for ' + '"model ordinance," "proposed ordinance," ' + '"notice of proposed rulemaking," "for ' 'public comment," "draft for review," "public hearing scheduled," ' '"introduced," "pending adoption," etc.), treat it as **not** in ' "effect.\n" diff --git a/tests/python/unit/plugin/test_plugin_one_shot_base.py b/tests/python/unit/plugin/test_plugin_one_shot_base.py index 7255a7e28..038207d27 100644 --- a/tests/python/unit/plugin/test_plugin_one_shot_base.py +++ b/tests/python/unit/plugin/test_plugin_one_shot_base.py @@ -8,6 +8,26 @@ import pandas as pd import pyjson5 +from compass import COMPASSSolarOneShotExtractor, COMPASSWindOneShotExtractor +from compass.extraction.features import SetbackFeatures +from compass.extraction.solar.ordinance import ( + SolarOrdinanceTextCollector, + SolarOrdinanceTextExtractor, +) +from compass.extraction.solar.parse import ( + EXTRA_NUMERICAL_RESTRICTIONS, + EXTRA_QUALITATIVE_RESTRICTIONS, + StructuredSolarPermittedUseDistrictsParser, +) +from compass.extraction.wind.ordinance import ( + WindOrdinanceTextCollector, + WindOrdinanceTextExtractor, +) +from compass.extraction.wind.parse import ( + EXTRA_NUMERICAL_RESTRICTIONS as WIND_NUMERICAL_RESTRICTIONS, + EXTRA_QUALITATIVE_RESTRICTIONS as WIND_QUALITATIVE_RESTRICTIONS, + StructuredWindPermittedUseDistrictsParser, +) import compass.plugin.one_shot.base as one_shot_base from compass.plugin.one_shot.base import ( _out_cols_from_config, @@ -24,7 +44,16 @@ [ "compass/extraction/geothermal_electricity/geothermal_schema.json", "compass/extraction/ghp/geothermal_heat_pump_schema.json5", + # "compass/extraction/natural_gas/natural_gas_schema.json", + # ( + # "compass/extraction/natural_gas_pipelines/" + # "natural_gas_pipelines_schema.json" + # ), + "compass/extraction/oil_gas_wells/oil_and_gas_wells_schema.json", "compass/extraction/rmp/rmp_schema.json", + "compass/extraction/solar_os/solar_schema.json5", + # "compass/extraction/transmission/transmission_schema.json5", + "compass/extraction/wind_os/wind_schema.json5", "examples/water_rights_demo/one-shot/water_rights_schema.json5", ], ) @@ -88,6 +117,244 @@ def test_schema_summary_and_evidence_survive_export( assert saved.loc[row["feature"], field] == row[field] +def test_solar_one_shot_collection_prompts_match_legacy_solar(): + """Keep the one-shot collection filter aligned with legacy solar""" + actual = COMPASSSolarOneShotExtractor.TEXT_COLLECTORS[0].PROMPTS + expected = SolarOrdinanceTextCollector.PROMPTS + assert len(actual) == len(expected) + for actual_prompt, expected_prompt in zip(actual, expected, strict=True): + assert actual_prompt.keys() == expected_prompt.keys() + for key, value in expected_prompt.items(): + assert " ".join(actual_prompt[key].split()) == " ".join( + value.split() + ) + + +def test_solar_one_shot_text_prompt_preserves_extraction_contract(): + """Render the solar-specific prompt with the shared verbatim rules""" + (extractor,) = COMPASSSolarOneShotExtractor.TEXT_EXTRACTORS + (prompt,) = extractor.PROMPTS + (legacy,) = SolarOrdinanceTextExtractor.PROMPTS + (parser,) = COMPASSSolarOneShotExtractor.PARSERS + ((key, extract),) = extractor(None).parsers + assert key == legacy["key"] == parser.IN_LABEL + assert prompt["out_fn"] == legacy["out_fn"] + instructions = extract.keywords["instructions"] + assert extractor.FORMATTING_PROMPT in instructions + assert extractor.OUTPUT_PROMPT in instructions + + +def test_solar_one_shot_retains_legacy_features_and_evidenced_examples(): + """Cover all solar features without introducing placeholder examples""" + schema = COMPASSSolarOneShotExtractor.SCHEMA + items = schema["properties"]["outputs"]["items"] + features = items["properties"]["feature"]["enum"] + expected = set(EXTRA_NUMERICAL_RESTRICTIONS) + expected.update(EXTRA_QUALITATIVE_RESTRICTIONS) + expected.update({"agrivoltaics", "site management"}) + expected.update( + entry["feature_id"] + for entry in StructuredSolarPermittedUseDistrictsParser._USE_TYPES + ) + for entry in SetbackFeatures(): + feature = entry["feature_id"] + if feature in {"structures", "property line"}: + expected.update( + f"{feature} ({owner})" + for owner in ("participating", "non-participating") + ) + else: + expected.add(feature) + + (parser,) = COMPASSSolarOneShotExtractor.PARSERS + assert {"agrivoltaics", "site management"} <= parser.QUALITATIVE_FEATURES + assert len(features) == len(set(features)) == 33 + assert set(features) == expected + definitions = { + feature: definition + for family in schema["$definitions"].values() + for feature, definition in family["properties"].items() + } + assert set(definitions) == expected + for definition in definitions.values(): + for rule in ("VALUE:", "UNITS:", "IGNORE:"): + assert rule in definition["description"] + + for case in schema["$examples"]: + rows = case["outputs"] + assert len(rows) == len({row["feature"] for row in rows}) + for row in rows: + assert set(row) == set(items["required"]) + assert row["feature"] in expected + for field in ("summary", "ordinance_text", "explanation"): + assert isinstance(row[field], str) and row[field].strip() + for excerpt in row["ordinance_text"].split(" ... "): + assert excerpt in case["source_text"] + + +@pytest.mark.asyncio +@pytest.mark.parametrize( + "text, expected", + [ + ("Commercial solar energy systems require setbacks.", True), + ("Utility-scale photovoltaic solar farms require screening.", True), + ( + ( + "Small solar energy systems are exempt. " + "Utility-scale solar farms require setbacks." + ), + True, + ), + ("Small solar energy systems are exempt.", False), + ("Concentrated solar power (CSP) requires a permit.", False), + ("A solar eclipse or solar flare is not a land use.", False), + ("This district uses land for agriculture.", False), + ], +) +async def test_solar_one_shot_heuristic_retains_solar_scope(text, expected): + """Keep solar farm matches while stripping misleading solar phrases""" + plugin = COMPASSSolarOneShotExtractor(None, {}) + heuristic = await plugin.get_heuristic() + assert heuristic.check(text) is expected + + +@pytest.mark.parametrize( + "component, legacy_class", + [ + ("TEXT_COLLECTORS", WindOrdinanceTextCollector), + ("TEXT_EXTRACTORS", WindOrdinanceTextExtractor), + ], +) +def test_wind_one_shot_prompts_match_legacy_wind(component, legacy_class): + """Keep effective one-shot prompts aligned with legacy wind wording""" + components = getattr(COMPASSWindOneShotExtractor, component) + assert len(components) == 1 + actual = components[0].PROMPTS + expected = legacy_class.PROMPTS + assert len(actual) == len(expected) + for actual_prompt, expected_prompt in zip(actual, expected, strict=True): + assert actual_prompt.keys() == expected_prompt.keys() + for key, value in expected_prompt.items(): + expected_value = value + if component == "TEXT_EXTRACTORS" and key == "prompt": + expected_value = value.format( + FORMATTING_PROMPT=legacy_class.FORMATTING_PROMPT, + OUTPUT_PROMPT=legacy_class.OUTPUT_PROMPT, + ) + assert " ".join(actual_prompt[key].split()) == " ".join( + expected_value.split() + ) + + +def test_wind_one_shot_retains_legacy_features(): + """Cover all legacy wind features with authored extraction rules""" + schema = COMPASSWindOneShotExtractor.SCHEMA + items = schema["properties"]["outputs"]["items"] + features = items["properties"]["feature"]["enum"] + expected = set(WIND_NUMERICAL_RESTRICTIONS) + expected.update(WIND_QUALITATIVE_RESTRICTIONS) + districts = { + entry["feature_id"] + for entry in StructuredWindPermittedUseDistrictsParser._USE_TYPES + } + expected.update(districts) + for entry in SetbackFeatures(): + feature = entry["feature_id"] + if feature in {"structures", "property line"}: + expected.update( + f"{feature} ({owner})" + for owner in ("participating", "non-participating") + ) + else: + expected.add(feature) + + assert len(features) == len(set(features)) == 31 + assert set(features) == expected + definitions = { + feature: definition + for family in ( + "setback_features", + "numerical_restrictions", + "qualitative_restrictions", + "permitted_use_districts", + ) + for feature, definition in schema["$definitions"][family][ + "properties" + ].items() + } + assert set(definitions) == expected + for feature, definition in definitions.items(): + assert "VALUE" in definition["description"] + if feature in WIND_NUMERICAL_RESTRICTIONS: + assert "UNITS:" in definition["description"] + elif ( + feature not in WIND_QUALITATIVE_RESTRICTIONS + and feature not in districts + ): + for rule in ("UNITS", "IGNORE"): + assert rule in definition["description"] + + +def test_wind_one_shot_has_evidenced_examples(): + """Require complete wind examples without absence placeholders""" + schema = COMPASSWindOneShotExtractor.SCHEMA + items = schema["properties"]["outputs"]["items"] + expected = set(items["properties"]["feature"]["enum"]) + districts = { + entry["feature_id"] + for entry in StructuredWindPermittedUseDistrictsParser._USE_TYPES + } + rows = schema["$examples"] + assert rows + assert len(rows) == len({row["feature"] for row in rows}) + for row in rows: + assert set(row) == set(items["required"]) + assert row["feature"] in expected + for field in ("summary", "ordinance_text", "explanation"): + assert isinstance(row[field], str) and row[field].strip() + assert not row[field].casefold().startswith("no explicit") + if row["feature"] in WIND_QUALITATIVE_RESTRICTIONS: + assert row["value"] is None + assert row["units"] is None + elif row["feature"] in districts: + assert isinstance(row["value"], list) and row["value"] + assert all( + isinstance(district, str) and district.strip() + for district in row["value"] + ) + assert row["units"] is None + else: + assert isinstance(row["value"], (int, float)) + assert isinstance(row["units"], str) and row["units"].strip() + + +@pytest.mark.asyncio +@pytest.mark.parametrize( + "text, expected", + [ + ("Commercial wind energy systems require setbacks.", True), + ("Utility-scale wind turbines require permits.", True), + ("Large WECS require setbacks.", True), + ( + ( + "Small wind energy systems are exempt. " + "Utility-scale wind farms require setbacks." + ), + True, + ), + ("Small wind energy systems are exempt.", False), + ("Micro WECS are exempt.", False), + ("Windows and windshields must resist wind damage.", False), + ("This district uses land for agriculture.", False), + ], +) +async def test_wind_one_shot_heuristic_retains_wind_scope(text, expected): + """Keep wind farm matches while stripping misleading wind phrases""" + plugin = COMPASSWindOneShotExtractor(None, {}) + heuristic = await plugin.get_heuristic() + assert heuristic.check(text) is expected + + def test_out_cols_from_config_uses_schema_output_properties(): """Test schema output fields become output columns"""