Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ evaluations/results/
# Installed locally from an exact source lock. Upstream redistribution permission is unresolved.
skills/alibabacloud-resourcecenter-search/
venv/
.venv/
18 changes: 12 additions & 6 deletions src/titmas_action_gate/contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ def schema_directory() -> Path:
)


@functools.cache
def _schema_registry() -> Registry:
Comment on lines +50 to +51

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Update the recommendation gate before development

This commit changes the contract-validation implementation without updating governance/agent-recommendation-gate.json; the retained gate still describes an unrelated August 13 security-fix scope and base commit, so it does not record the recommendation, correction evidence, remaining gaps, or stop conditions for this optimization. Refresh the development gate for this task before merging.

AGENTS.md reference: AGENTS.md:L23-L25

Useful? React with 👍 / 👎.

directory = schema_directory()
resources = []
for path in directory.glob("*.schema.json"):
candidate = json.loads(path.read_text(encoding="utf-8"))
if isinstance(candidate.get("$id"), str):
resources.append((candidate["$id"], Resource.from_contents(candidate)))
return Registry().with_resources(resources)


@functools.cache
def _validator(contract: str) -> Draft202012Validator:
try:
Expand All @@ -55,12 +66,7 @@ def _validator(contract: str) -> Draft202012Validator:
raise ContractValidationError("SCHEMA_UNKNOWN", f"Unknown contract: {contract}") from exc
directory = schema_directory()
schema = json.loads((directory / filename).read_text(encoding="utf-8"))
resources = []
for path in directory.glob("*.schema.json"):
candidate = json.loads(path.read_text(encoding="utf-8"))
if isinstance(candidate.get("$id"), str):
resources.append((candidate["$id"], Resource.from_contents(candidate)))
registry = Registry().with_resources(resources)
registry = _schema_registry()
return Draft202012Validator(schema, registry=registry, format_checker=FormatChecker())


Expand Down
2 changes: 1 addition & 1 deletion src/titmas_action_gate/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import hashlib
import hmac
import json
from dataclasses import dataclass
from datetime import datetime, timedelta
from pathlib import Path
from typing import Any
Expand All @@ -20,7 +21,6 @@
from .provider import GitHubProvider
from .signing import HmacRecordSigner
from .store import AppendOnlyStore
from dataclasses import dataclass


@dataclass(frozen=True)
Expand Down
5 changes: 2 additions & 3 deletions tests/test_security_argument_injection.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import unittest
import subprocess
from unittest.mock import patch, MagicMock
from unittest.mock import MagicMock, patch

from titmas_action_gate.provider import GhCliProvider
from titmas_action_gate.errors import ActionGateError


class ProviderSecurityTests(unittest.TestCase):
@patch("subprocess.run")
Expand Down
6 changes: 3 additions & 3 deletions tests/test_workflow.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import json
import tempfile
import unittest
from pathlib import Path

import json
from titmas_action_gate.workflow import validate_agentteams_template, write_demo_report


Expand Down Expand Up @@ -83,7 +83,7 @@ def test_write_demo_report(self):
self.assertEqual(result_path, output_file)
self.assertTrue(output_file.exists())

with open(output_file, "r", encoding="utf-8") as f:
with open(output_file, encoding="utf-8") as f:
content = json.load(f)

self.assertEqual(content, report_data)
Expand All @@ -95,7 +95,7 @@ def test_write_demo_report_creates_directories(self):
write_demo_report(report_data, output_file)

self.assertTrue(output_file.exists())
with open(output_file, "r", encoding="utf-8") as f:
with open(output_file, encoding="utf-8") as f:
content = json.load(f)

self.assertEqual(content, report_data)
Loading