feat(schemas): enforce LinkML-generated types from cradle to grave#359
Merged
feat(schemas): enforce LinkML-generated types from cradle to grave#359
Conversation
…rFilterSlice, DebriefFeature union Phase 1 of 173-cradle-to-grave-typing: - Add PlotSummary and StacItemSummary to stac-extension.yaml (T001-T002) - Add ResultsSlice and BrowserFilterSlice to session-state.yaml (T003) - Reconcile DatasetEntry with runtime DatasetEnvelope shape (T004) - Regenerate Pydantic models (T005) - Add DebriefFeature Python union type in unions.py (T006) https://claude.ai/code/session_01NVvcfZz3YgcdEm855v2UKB
Phase 2 of 173-cradle-to-grave-typing: - Add session-state and tool-result imports to debrief.yaml (T008-T009) - Regenerate TypeScript types with all domain types (T010) - Fix index.ts to re-export unions.ts (T011) - Verify provenance types present in TS output (T012) - TypeScript typecheck + tests pass (T013) https://claude.ai/code/session_01NVvcfZz3YgcdEm855v2UKB
… schemas Phases 3-4 of 173-cradle-to-grave-typing: Phase 3 (TypeScript): - Delete TrackFeature, LocationFeature, PlotFeatureCollection from plot.ts (T014) - Delete LineString, Point geometry types from plot.ts (T015) - Delete PositionStyle, PositionStyleOverride from plot.ts and shared/utils (T016, T020) - Delete TimestampedPosition from plot.ts (T017) - Rename Track -> TrackViewModel in plot.ts (T018) - Update consumers in outlineProvider.ts, sessionManager tests (T019, T021) - Delete ParameterValue, InputFeatureState from LogPanel/types.ts (T022) - Keep TimelineEntry as UI type with comment (T023) - Delete LogEntry from web-shell toolService.ts (T024) - Fix .js extensions in schemas index.ts for NodeNext compat Phase 4 (Python): - Delete provenance model duplicates from calc/models.py (T026) - Update internal calc imports to use debrief_schemas (T027) - Delete snapshot/branch duplicates from calc/models.py (T028) - Fix pyright errors in test_models.py for stricter generated types https://claude.ai/code/session_01NVvcfZz3YgcdEm855v2UKB
Phases 5-6 of 173-cradle-to-grave-typing:
Phase 5 (Python - T032-T059):
- Replace Feature = dict[str, Any] with DebriefFeature union (T032)
- Retype 13 calc tool functions with Pydantic model annotations (T035-T047)
- Replace feature.get("properties") with typed access in validation/provenance/executor (T048-T050)
- Retype result_builder.py to accept typed features (T051)
- Add Pydantic validation on STAC feature read (T053)
- Retype MCP/CLI handlers with type annotations (T054-T058)
Phase 6 (TypeScript - T060-T085):
- Eliminate propsRecord escape hatch in 10 consumer files (T060-T069)
- Delete featureProps.ts (T070)
- Retype tool functions with specific feature types (T071-T074)
- Add type guard validation after JSON.parse in services (T075-T077)
- Remove as-unknown-as casts on domain data (T078-T082)
https://claude.ai/code/session_01NVvcfZz3YgcdEm855v2UKB
Phase 7 of 173-cradle-to-grave-typing: - Migrate session-state TS types to @debrief/schemas imports (T086) - Migrate ChartRenderer DatasetEnvelope to generated DatasetEntry (T087) - Replace CatalogOverviewItem with StacItemSummary in filter-engine (T088) - Replace StacItemSummary in VS Code stac types (T089) https://claude.ai/code/session_01NVvcfZz3YgcdEm855v2UKB
Phase 8 of 173-cradle-to-grave-typing: - Fix lint errors: ruff (import ordering, ANN401, E402) and eslint (unnecessary assertion) - Fix re-exports: debrief_calc.models and debrief_session.types now properly re-export from debrief_schemas - Capture evidence: test-summary.md, usage-example.md, prohibited-patterns.txt - Create shipped media: shipped-post.md, linkedin-shipped.md https://claude.ai/code/session_01NVvcfZz3YgcdEm855v2UKB
🚀 Preview DeploymentsCode Server (Full VS Code Extension)Browser-based VS Code with the Debrief extension and sample data pre-installed. Web Shell (Standalone App)Use this for Playwright testing and demos - runs outside Storybook. Storybook (Component Library)Browse all components, stories, and documentation. All Links
|
The Phase 6 agent removed null-safety logic when replacing propsRecord with isTrackFeature, causing 13 test failures. Features may have incomplete style objects (missing style.point, default_position_style), so tools must create defaults when absent. Also fixes tsc error: TrackProperties -> Record<string, unknown> cast needs intermediate unknown step. https://claude.ai/code/session_01NVvcfZz3YgcdEm855v2UKB
Fixes 3 CI failures: 1. Ruff format: auto-formatted 6 Python files that passed ruff check but failed ruff format --check (CI runs both) 2. Schema gen-json-schema: adding session-state to debrief.yaml broke gen-json-schema (Coordinate as multivalued class range triggers a LinkML bug). Fix: use debrief-jsonschema.yaml (excludes session-state) for JSON Schema generation. Also change uri/datetime ranges to string in session-state.yaml for broader compatibility. 3. VS Code tsc --noEmit: TrackProperties -> Record<string,unknown> cast in executeTool.ts needs intermediate unknown step. https://claude.ai/code/session_01NVvcfZz3YgcdEm855v2UKB
Replace the Constitution XV.7 violating cast f.properties as unknown as Record<string, unknown> with JSON.parse round-trip + delete propsCopy.provenance, which avoids casting typed properties to unknown entirely. https://claude.ai/code/session_01NVvcfZz3YgcdEm855v2UKB
…vice Replace Constitution XV.7 violations introduced in Phase 6: - 4 track styling tools: use typed PositionStyle/TrackStyle with ?? defaults and Object.assign for runtime-extended fields (label_interval, symbol_interval) - calcService: use JSON.parse round-trip for serialization boundary spread - Fix style fallback to not pre-populate sub-objects (caused ?? to not trigger) All 335 vscode unit tests pass. Zero new as-unknown-as casts. https://claude.ai/code/session_01NVvcfZz3YgcdEm855v2UKB
Replace JSON.parse/stringify round-trips with structuredClone to avoid as-unknown and as-Record casts that violate Constitution XV.7. - executeTool.ts: structuredClone for geometry/properties deep copy - calcService.ts: structuredClone + spread for feature serialization https://claude.ai/code/session_01NVvcfZz3YgcdEm855v2UKB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
dict[str, Any]andRecord<string, unknown>from domain data throughout the monorepo — every function that touches features, provenance, or session-state now uses LinkML-generated typespropsRecordescape hatch (featureProps.ts) and migrate all 10 consumers toisTrackFeature()/isReferenceLocation()type guardsDebriefFeatureunion type in both languages as the canonical type for feature collectionsChanges
Phase 1: Schema Completeness
PlotSummary,StacItemSummarytostac-extension.yamlResultsSlice,BrowserFilterSlicetosession-state.yamlDatasetEntrywith runtimeDatasetEnvelopeshapeDebriefFeaturePython union type (unions.py)Phase 2: TypeScript Generator Extension
session-stateandtool-resultimports to masterdebrief.yaml@debrief/schemas.jsextensions inindex.tsforNodeNextmodule resolutionPhase 3: Delete TypeScript Duplicates
TrackFeature,LocationFeature,PositionStyle,TimestampedPositionfromplot.tsPositionStyle,PositionStyleOverridefromshared/utils/types.tsParameterValue,InputFeatureStatefromLogPanel/types.tsLogEntryfromweb-shell/toolService.tsTrack→TrackViewModel(UI projection)Phase 4: Delete Python Duplicates
ParameterValue,LogEntry,WasGeneratedBy, etc.) fromcalc/models.pySnapshotRef,BranchRecord, etc.) fromcalc/models.pydebrief_schemasfor backward compatibilityPhase 5: Strongly Type Python Internal Logic
Feature = dict[str, Any]withDebriefFeatureunion indebrief_io/types.pyfeature.get("properties")with typed access in validation/provenance/executorPhase 6: Strongly Type TypeScript Internal Logic
propsRecordin 10 consumer files, deletefeatureProps.tsJSON.parsein calcService, stacServiceas unknown ascasts on domain data in mapPanel, stacService, logServicePhase 7: Remaining Migrations
@debrief/schemasimportsDatasetEnvelopewith generatedDatasetEntryin ChartRendererCatalogOverviewItemwithStacItemSummaryin filter-engineEvidence
Test Results
Prohibited Pattern Check
Feature = dict[str, Any]propsRecordusagefeatureProps.tsas unknown as DebriefFeatureTest Plan
Related
specs/173-cradle-to-grave-typing/spec.mdspecs/173-cradle-to-grave-typing/plan.mdspecs/173-cradle-to-grave-typing/tasks.mdspecs/173-cradle-to-grave-typing/evidence/https://claude.ai/code/session_01NVvcfZz3YgcdEm855v2UKB