configuration/constants/grammar.constants.ts

configuration/constants/grammar.constants.ts is a file in Bane's Lab Site. 120 lines of code and 6 definitions.

import {
    AMBIGUITY_CONCEPT,
    CONSTRAINT_CONCEPT,
    DECLARATION_CONCEPT,
    DIRECTIVE_CONCEPT,
    GATE_SHAPE_CONCEPT,
    INSTRUCTION_CONTRACT_CONCEPT,
    INSTRUMENT_CONCEPT,
    LIMIT_CONCEPT,
    LOOP_CONCEPT,
    OPERATION_CONCEPT,
    PHASE_CONCEPT,
    UNKNOWN_CONCEPT,
    WELLFORMED_CONCEPT,
} from "#core/ids/concept.ids";
import {
    BNF_SECTION_ID,
    DEFINITION_SECTION_ID,
    INVOCATION_SECTION_ID,
    KEYWORD_SECTION_ID,
    LIMITATION_SECTION_ID,
    METHOD_SECTION_ID,
    PHASE_SECTION_ID,
    RATIONALE_SECTION_ID,
    START_SECTION_ID,
    STRUCTURE_SECTION_ID,
    VALIDATION_SECTION_ID,
    WELLFORMED_SECTION_ID,
    WRITING_SECTION_ID,
} from "#core/ids/grammar.ids";
import type { ContentGraph, GraphSection } from "#types/methodology.types";
import {
    ORCHESTRATION_GRAPH_SECTIONS,
    PAG_SEED,
    PATTERN_GRAPH_SECTIONS,
    TEMPLATE_GRAPH_SECTIONS,
} from "#configuration/constants/grammar.fragment.constants";
import { GRAMMAR_PAGE } from "#core/ids/page.ids";

const NARRATIVE: GraphSection = { narrative: true, requires: [], teaches: [], traces: [] };

const INTRODUCTION_GRAPH_SECTIONS: Readonly<Record<string, GraphSection>> = {
    [DEFINITION_SECTION_ID]: {
        requires: [LOOP_CONCEPT],
        teaches: [INSTRUCTION_CONTRACT_CONCEPT],
        traces: [PAG_SEED, "descriptive_is_not_full_shaped"],
    },
    [RATIONALE_SECTION_ID]: {
        requires: [INSTRUCTION_CONTRACT_CONCEPT],
        teaches: [AMBIGUITY_CONCEPT],
        traces: [PAG_SEED, "uncertainty_is_stated"],
    },
    [METHOD_SECTION_ID]: {
        requires: [AMBIGUITY_CONCEPT],
        teaches: [INSTRUMENT_CONCEPT],
        traces: ["claims_need_evidence", "one_entry_point_staged_pipeline", "report_is_the_state"],
    },
};

const GUIDE_GRAPH_SECTIONS: Readonly<Record<string, GraphSection>> = {
    [START_SECTION_ID]: {
        requires: [INSTRUCTION_CONTRACT_CONCEPT],
        teaches: [DIRECTIVE_CONCEPT],
        traces: [PAG_SEED, "schema_declared_structure"],
    },
    [STRUCTURE_SECTION_ID]: {
        requires: [DIRECTIVE_CONCEPT],
        teaches: [DECLARATION_CONCEPT],
        traces: [PAG_SEED, "type_assignment_is_spine"],
    },
    [INVOCATION_SECTION_ID]: {
        requires: [DIRECTIVE_CONCEPT],
        teaches: [OPERATION_CONCEPT],
        traces: [
            "slots_resolve_through_the_adapter",
            "slot_absence_is_honored",
            "mechanism_transfers_catalogs_rederive",
        ],
    },
    [PHASE_SECTION_ID]: {
        requires: [DECLARATION_CONCEPT],
        teaches: [PHASE_CONCEPT],
        traces: [PAG_SEED, "severity_routes_never_orders"],
    },
    [WRITING_SECTION_ID]: {
        requires: [PHASE_CONCEPT],
        teaches: [CONSTRAINT_CONCEPT],
        traces: [PAG_SEED, "gate_constructs_not_literals"],
    },
    [WELLFORMED_SECTION_ID]: {
        requires: [CONSTRAINT_CONCEPT],
        teaches: [WELLFORMED_CONCEPT],
        traces: [PAG_SEED, "no_regex", "derived_not_heuristic"],
    },
};

const REFERENCE_GRAPH_SECTIONS: Readonly<Record<string, GraphSection>> = {
    [KEYWORD_SECTION_ID]: NARRATIVE,
    [BNF_SECTION_ID]: NARRATIVE,
};

const VALIDATION_GRAPH_SECTIONS: Readonly<Record<string, GraphSection>> = {
    [VALIDATION_SECTION_ID]: {
        requires: [PHASE_CONCEPT, UNKNOWN_CONCEPT],
        teaches: [GATE_SHAPE_CONCEPT],
        traces: [PAG_SEED, "findings_are_machine_actionable", "no_silent"],
    },
    [LIMITATION_SECTION_ID]: {
        requires: [OPERATION_CONCEPT],
        teaches: [LIMIT_CONCEPT],
        traces: ["slot_absence_is_honored", "no_fallback", "no_hidden_nondeterminism"],
    },
};

export const GRAMMAR_GRAPH: ContentGraph = {
    page: GRAMMAR_PAGE,
    sections: {
        ...INTRODUCTION_GRAPH_SECTIONS,
        ...GUIDE_GRAPH_SECTIONS,
        ...ORCHESTRATION_GRAPH_SECTIONS,
        ...PATTERN_GRAPH_SECTIONS,
        ...REFERENCE_GRAPH_SECTIONS,
        ...VALIDATION_GRAPH_SECTIONS,
        ...TEMPLATE_GRAPH_SECTIONS,
    },
};