feat: insert direct edit constraint solver stage
Adds resolveDirectEditConstraints between compileRoadModel and compileGeometry, per the parent design's data flow. The stage is an identity transform until the individual constraint kinds land: it returns empty road profiles, junction plans and handle manifest, so compileGeometry's geometry code is untouched and output stays byte-identical. Constraint planning is separated from solving up front. Only `exact` and `recheck` constraints may reach the solver; `disabled`, `pending`, `conflicted` and `stale` are reported as unapplied with a reason. SOLVED_KINDS starts empty and grows one entry per kind, so a partially delivered solver reports what it skipped instead of publishing half-solved geometry. diagnostic() moves to src/compile/diagnostics.js so the solver can share the compiler's diagnostic shape without depending on fs, which would break the pure-function boundary that lets preview, the full compile and the CLI export share one implementation. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
c5e762e1a9
commit
3297d0c97a
9 files changed
+274
-14
No files matched your search
@@ -13,6 +13,8 @@ const {
|
||||
const { LAYER_REGISTRY, manifestForArea, validatePublishedLayers } = require('./layer-manifest');
|
||||
const { loadOrGenerate, runtime } = require('../native-traffic-signals');
|
||||
const { readAreaConfigSnapshot } = require('./road-revisions');
|
||||
const { loadEditDocument } = require('./native-road-edits');
|
||||
const { resolveDirectEditConstraints } = require('./direct-edit-solver');
|
||||
|
||||
function compileInput(input) {
|
||||
validateInput(input);
|
||||
@@ -40,10 +42,17 @@ function compileInput(input) {
|
||||
for (const item of validated.stale)
|
||||
console.warn(`[warning] 忽略失效的 override(目标已不存在):${item.id} -> ${item.target}`);
|
||||
fs.mkdirSync(area.outputs.pipelineDir, { recursive: true });
|
||||
// Direct edits resolve against the model *after* v1 overrides, then feed
|
||||
// compileGeometry. An area with no v2 document resolves to an empty result,
|
||||
// which leaves the geometry byte-identical to a compile without this stage.
|
||||
const directEdits = input.editsFile ? loadEditDocument(input.editsFile) : null;
|
||||
const directEdit = resolveDirectEditConstraints(model, directEdits);
|
||||
const compiled = compileGeometry(model, overrides, {
|
||||
edgeLines: area.nativeRoad.edgeLines,
|
||||
junctionTemplates: area.nativeRoad.junctionTemplates,
|
||||
directEdit,
|
||||
});
|
||||
compiled.diagnostics.push(...directEdit.diagnostics);
|
||||
compiled.diagnostics.push(
|
||||
...validated.stale.map((item) => ({
|
||||
id: `diagnostic:stale-override:${item.id}`,
|
||||
@@ -169,6 +178,8 @@ function validateInput(input) {
|
||||
(typeof input.areaConfigSnapshotFile !== 'string' || !input.areaConfigSnapshotFile)
|
||||
)
|
||||
throw new Error('RoadCompilerInput.areaConfigSnapshotFile must be a non-empty string when present');
|
||||
if (input.editsFile !== undefined && (typeof input.editsFile !== 'string' || !input.editsFile))
|
||||
throw new Error('RoadCompilerInput.editsFile must be a non-empty string when present');
|
||||
}
|
||||
|
||||
function validateOptions(options) {
|
||||
|
||||
Reference in new issue
Block a user