workflows update
This commit is contained in:
@@ -94,28 +94,35 @@ OUTPUT_COMPRESSED_MD = ".ai/PROJECT_MAP.md"
|
||||
OUTPUT_MODULE_MAP_MD = ".ai/MODULE_MAP.md"
|
||||
REPORTS_DIR = "semantics/reports"
|
||||
|
||||
# Tier-based mandatory tags
|
||||
# Tier-based mandatory tags aligned with .ai/standards/semantics.md
|
||||
TIER_MANDATORY_TAGS = {
|
||||
Tier.CRITICAL: {
|
||||
"Module": ["PURPOSE", "LAYER", "SEMANTICS", "TIER", "INVARIANT"],
|
||||
"Component": ["PURPOSE", "LAYER", "SEMANTICS", "TIER", "INVARIANT"],
|
||||
"Function": ["PURPOSE", "PRE", "POST"],
|
||||
"Class": ["PURPOSE", "TIER"]
|
||||
"Component": ["PURPOSE", "LAYER", "SEMANTICS", "TIER", "INVARIANT", "UX_STATE", "UX_FEEDBACK", "UX_RECOVERY", "UX_REATIVITY"],
|
||||
"Function": ["PURPOSE", "PRE", "POST", "TEST_CONTRACT", "TEST_FIXTURE", "TEST_EDGE", "TEST_INVARIANT"],
|
||||
"Class": ["PURPOSE", "TIER", "INVARIANT"],
|
||||
"Store": ["PURPOSE", "TIER", "INVARIANT"]
|
||||
},
|
||||
Tier.STANDARD: {
|
||||
"Module": ["PURPOSE", "LAYER", "SEMANTICS", "TIER"],
|
||||
"Component": ["PURPOSE", "LAYER", "SEMANTICS", "TIER"],
|
||||
"Component": ["PURPOSE", "LAYER", "SEMANTICS", "TIER", "UX_STATE"],
|
||||
"Function": ["PURPOSE", "PRE", "POST"],
|
||||
"Class": ["PURPOSE", "TIER"]
|
||||
"Class": ["PURPOSE", "TIER"],
|
||||
"Store": ["PURPOSE", "TIER"]
|
||||
},
|
||||
Tier.TRIVIAL: {
|
||||
"Module": ["PURPOSE", "TIER"],
|
||||
"Component": ["PURPOSE", "TIER"],
|
||||
"Module": ["PURPOSE"],
|
||||
"Component": ["PURPOSE"],
|
||||
"Function": ["PURPOSE"],
|
||||
"Class": ["PURPOSE", "TIER"]
|
||||
"Class": ["PURPOSE"],
|
||||
"Store": ["PURPOSE"]
|
||||
}
|
||||
}
|
||||
|
||||
ALLOWED_RELATION_PREDICATES = {
|
||||
"DEPENDS_ON", "CALLS", "INHERITS", "IMPLEMENTS", "DISPATCHES", "BINDS_TO"
|
||||
}
|
||||
|
||||
# Tier-based belief state requirements
|
||||
TIER_BELIEF_REQUIRED = {
|
||||
Tier.CRITICAL: True,
|
||||
@@ -252,7 +259,17 @@ class SemanticEntity:
|
||||
self.start_line
|
||||
))
|
||||
|
||||
# 3. Check for Belief State Logging based on TIER
|
||||
# 3. Validate relation predicates against GRACE-Poly allowlist
|
||||
for rel in self.relations:
|
||||
rel_type = rel.get("type", "").upper()
|
||||
if rel_type and rel_type not in ALLOWED_RELATION_PREDICATES:
|
||||
self.compliance_issues.append(ComplianceIssue(
|
||||
f"Invalid @RELATION predicate: {rel_type}. Allowed: {', '.join(sorted(ALLOWED_RELATION_PREDICATES))}",
|
||||
Severity.ERROR if tier == Tier.CRITICAL else Severity.WARNING,
|
||||
self.start_line
|
||||
))
|
||||
|
||||
# 4. Check for Belief State Logging based on TIER
|
||||
if self.type == "Function":
|
||||
belief_required = TIER_BELIEF_REQUIRED.get(tier, False)
|
||||
if belief_required:
|
||||
@@ -270,7 +287,7 @@ class SemanticEntity:
|
||||
self.start_line
|
||||
))
|
||||
|
||||
# 4. Check for @INVARIANT in CRITICAL tier
|
||||
# 5. Check for @INVARIANT in CRITICAL tier
|
||||
if tier == Tier.CRITICAL and self.type in ["Module", "Component", "Class"]:
|
||||
if "INVARIANT" not in [k.upper() for k in self.tags.keys()]:
|
||||
self.compliance_issues.append(ComplianceIssue(
|
||||
@@ -338,7 +355,7 @@ def get_patterns(lang: str) -> Dict[str, Pattern]:
|
||||
if lang == "python":
|
||||
return {
|
||||
"anchor_start": re.compile(r"#\s*\[DEF:(?P<name>[\w\.]+):(?P<type>\w+)\]"),
|
||||
"anchor_end": re.compile(r"#\s*\[/DEF:(?P<name>[\w\.]+)(?::\w+)?\]"),
|
||||
"anchor_end": re.compile(r"#\s*\[/DEF:(?P<name>[\w\.]+):(?P<type>\w+)\]"),
|
||||
"tag": re.compile(r"#\s*@(?P<tag>[A-Z_]+):\s*(?P<value>.*)"),
|
||||
"relation": re.compile(r"#\s*@RELATION:\s*(?P<type>\w+)\s*->\s*(?P<target>.*)"),
|
||||
"func_def": re.compile(r"^\s*(async\s+)?def\s+(?P<name>\w+)"),
|
||||
@@ -348,11 +365,11 @@ def get_patterns(lang: str) -> Dict[str, Pattern]:
|
||||
else:
|
||||
return {
|
||||
"html_anchor_start": re.compile(r"<!--\s*\[DEF:(?P<name>[\w\.]+):(?P<type>\w+)\]\s*-->"),
|
||||
"html_anchor_end": re.compile(r"<!--\s*\[/DEF:(?P<name>[\w\.]+)(?::\w+)?\]\s*-->"),
|
||||
"html_anchor_end": re.compile(r"<!--\s*\[/DEF:(?P<name>[\w\.]+):(?P<type>\w+)\]\s*-->"),
|
||||
"js_anchor_start": re.compile(r"//\s*\[DEF:(?P<name>[\w\.]+):(?P<type>\w+)\]"),
|
||||
"js_anchor_end": re.compile(r"//\s*\[/DEF:(?P<name>[\w\.]+)(?::\w+)?\]"),
|
||||
"js_anchor_end": re.compile(r"//\s*\[/DEF:(?P<name>[\w\.]+):(?P<type>\w+)\]"),
|
||||
"html_tag": re.compile(r"@(?P<tag>[A-Z_]+):\s*(?P<value>.*)"),
|
||||
"jsdoc_tag": re.compile(r"\*\s*@(?P<tag>[a-zA-Z]+)\s+(?P<value>.*)"),
|
||||
"jsdoc_tag": re.compile(r"\*\s*@(?P<tag>[A-Za-z_]+)\s*:?\s*(?P<value>.*)"),
|
||||
"relation": re.compile(r"//\s*@RELATION:\s*(?P<type>\w+)\s*->\s*(?P<target>.*)"),
|
||||
"func_def": re.compile(r"^\s*(export\s+)?(async\s+)?function\s+(?P<name>\w+)"),
|
||||
"console_log": re.compile(r"console\.log\s*\(\s*['\"`]\[[\w_]+\]\[[A-Za-z0-9_:]+\]"),
|
||||
@@ -550,22 +567,23 @@ def parse_file(full_path: str, rel_path: str, lang: str) -> Tuple[List[SemanticE
|
||||
|
||||
if match_end:
|
||||
name = match_end.group("name")
|
||||
type_ = match_end.group("type")
|
||||
|
||||
if not stack:
|
||||
issues.append(ComplianceIssue(
|
||||
f"{rel_path}:{lineno} Found closing anchor [/DEF:{name}] without opening anchor.",
|
||||
f"{rel_path}:{lineno} Found closing anchor [/DEF:{name}:{type_}] without opening anchor.",
|
||||
Severity.ERROR,
|
||||
lineno
|
||||
))
|
||||
continue
|
||||
|
||||
top = stack[-1]
|
||||
if top.name == name:
|
||||
if top.name == name and top.type == type_:
|
||||
top.end_line = lineno
|
||||
stack.pop()
|
||||
else:
|
||||
issues.append(ComplianceIssue(
|
||||
f"{rel_path}:{lineno} Mismatched closing anchor. Expected [/DEF:{top.name}], found [/DEF:{name}].",
|
||||
f"{rel_path}:{lineno} Mismatched closing anchor. Expected [/DEF:{top.name}:{top.type}], found [/DEF:{name}:{type_}].",
|
||||
Severity.ERROR,
|
||||
lineno
|
||||
))
|
||||
@@ -1039,7 +1057,7 @@ class SemanticMapGenerator:
|
||||
|
||||
# Write Relations
|
||||
for rel in entity.relations:
|
||||
if rel['type'] in ['DEPENDS_ON', 'CALLS', 'INHERITS', 'IMPLEMENTS', 'DISPATCHES']:
|
||||
if rel['type'] in ['DEPENDS_ON', 'CALLS', 'INHERITS', 'IMPLEMENTS', 'DISPATCHES', 'BINDS_TO']:
|
||||
f.write(f"{indent} - 🔗 {rel['type']} -> `{rel['target']}`\n")
|
||||
|
||||
if level < 3:
|
||||
|
||||
Reference in New Issue
Block a user