added
This commit is contained in:
commit
8313c5c6b5
84 files changed
+4337
No files matched your search
@@ -0,0 +1,11 @@
|
||||
# Scripts
|
||||
|
||||
Scripts are development helpers and integration examples, not a deployment system. Read each script before running it.
|
||||
|
||||
- `start-local.ps1` and `start-mcp.ps1` launch local development interfaces.
|
||||
- `send-*.ps1` require explicit confirmation and caller-supplied credentials, sender, recipient, and content.
|
||||
- `record-*.ps1` record caller-supplied non-production evidence in an isolated local ledger.
|
||||
- Host-specific tunnel, startup-task, and token-file helpers are disabled in this public distribution.
|
||||
- `verify-postmark-readonly.ps1` and its Python module demonstrate a read-only provider check when separately configured.
|
||||
|
||||
No script should be run against a real account without reviewing its exact effects and configuration.
|
||||
@@ -0,0 +1,370 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Read-only structural audit for an AI-ready repository."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
||||
PROFILES = {
|
||||
"documentation-guide": {
|
||||
"README.md",
|
||||
"AUTHOR.md",
|
||||
"repository-variables.json",
|
||||
"repository.json",
|
||||
"LICENSE",
|
||||
"CHANGELOG.md",
|
||||
"UPDATES.md",
|
||||
"VERSION",
|
||||
"CITATION.cff",
|
||||
"docs",
|
||||
},
|
||||
"skill-workflow": {
|
||||
"README.md",
|
||||
"AUTHOR.md",
|
||||
"repository-variables.json",
|
||||
"repository.json",
|
||||
"LICENSE",
|
||||
"CHANGELOG.md",
|
||||
"UPDATES.md",
|
||||
"VERSION",
|
||||
"AGENTS.md",
|
||||
"skills.md",
|
||||
"skills",
|
||||
"templates",
|
||||
"examples",
|
||||
},
|
||||
"software-automation": {
|
||||
"README.md",
|
||||
"AUTHOR.md",
|
||||
"repository-variables.json",
|
||||
"repository.json",
|
||||
"LICENSE",
|
||||
"CHANGELOG.md",
|
||||
"UPDATES.md",
|
||||
"VERSION",
|
||||
"CONTRIBUTING.md",
|
||||
"SECURITY.md",
|
||||
"AGENTS.md",
|
||||
"docs",
|
||||
"scripts",
|
||||
"tests",
|
||||
},
|
||||
"dataset": {
|
||||
"README.md",
|
||||
"AUTHOR.md",
|
||||
"repository-variables.json",
|
||||
"repository.json",
|
||||
"LICENSE",
|
||||
"CHANGELOG.md",
|
||||
"UPDATES.md",
|
||||
"VERSION",
|
||||
"CITATION.cff",
|
||||
"data",
|
||||
"schemas",
|
||||
"docs",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def parse_args() -> argparse.Namespace:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("repository", type=Path, help="Repository root to inspect")
|
||||
parser.add_argument(
|
||||
"--profile",
|
||||
choices=sorted(PROFILES),
|
||||
required=True,
|
||||
help="Approved repository profile",
|
||||
)
|
||||
parser.add_argument("--json", action="store_true", help="Emit JSON")
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def read_version_from_citation(path: Path) -> str | None:
|
||||
if not path.is_file():
|
||||
return None
|
||||
match = re.search(
|
||||
r"(?m)^version:\s*[\"']?([^\"'\s#]+)",
|
||||
path.read_text(encoding="utf-8-sig"),
|
||||
)
|
||||
return match.group(1) if match else None
|
||||
|
||||
|
||||
def audit_content_index(root: Path, findings: list[dict[str, str]]) -> None:
|
||||
path = root / "content-index.json"
|
||||
if not path.is_file():
|
||||
return
|
||||
try:
|
||||
index = json.loads(path.read_text(encoding="utf-8-sig"))
|
||||
except (OSError, UnicodeError, json.JSONDecodeError) as exc:
|
||||
findings.append({"level": "error", "message": f"content-index.json is invalid: {exc}"})
|
||||
return
|
||||
|
||||
items = index.get("items")
|
||||
if not isinstance(items, list):
|
||||
findings.append(
|
||||
{"level": "error", "message": "content-index.json items must be an array"}
|
||||
)
|
||||
return
|
||||
|
||||
content_ids: set[str] = set()
|
||||
paths: set[str] = set()
|
||||
for position, item in enumerate(items):
|
||||
if not isinstance(item, dict):
|
||||
findings.append(
|
||||
{
|
||||
"level": "error",
|
||||
"message": f"content-index.json item {position + 1} must be an object",
|
||||
}
|
||||
)
|
||||
continue
|
||||
content_id = item.get("content_id")
|
||||
declared = item.get("path")
|
||||
if not content_id:
|
||||
findings.append(
|
||||
{
|
||||
"level": "error",
|
||||
"message": f"content-index.json item {position + 1} lacks content_id",
|
||||
}
|
||||
)
|
||||
elif content_id in content_ids:
|
||||
findings.append(
|
||||
{
|
||||
"level": "error",
|
||||
"message": f"Duplicate content_id in content-index.json: {content_id}",
|
||||
}
|
||||
)
|
||||
else:
|
||||
content_ids.add(content_id)
|
||||
if not declared:
|
||||
findings.append(
|
||||
{
|
||||
"level": "error",
|
||||
"message": f"content-index.json item {position + 1} lacks path",
|
||||
}
|
||||
)
|
||||
elif declared in paths:
|
||||
findings.append(
|
||||
{
|
||||
"level": "error",
|
||||
"message": f"Duplicate path in content-index.json: {declared}",
|
||||
}
|
||||
)
|
||||
else:
|
||||
paths.add(declared)
|
||||
declared_path = Path(declared)
|
||||
if (
|
||||
declared_path.is_absolute()
|
||||
or ".." in declared_path.parts
|
||||
or not (root / declared_path).is_file()
|
||||
):
|
||||
findings.append(
|
||||
{
|
||||
"level": "error",
|
||||
"message": f"Indexed content path does not exist or is unsafe: {declared}",
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def audit(root: Path, profile: str) -> dict:
|
||||
findings: list[dict[str, str]] = []
|
||||
if not root.is_dir():
|
||||
return {
|
||||
"repository": str(root),
|
||||
"profile": profile,
|
||||
"passed": False,
|
||||
"findings": [{"level": "error", "message": "Repository path is not a directory"}],
|
||||
}
|
||||
|
||||
for relative in sorted(PROFILES[profile]):
|
||||
if not (root / relative).exists():
|
||||
findings.append({"level": "error", "message": f"Missing required path: {relative}"})
|
||||
|
||||
manifest_path = root / "repository.json"
|
||||
manifest = None
|
||||
if manifest_path.is_file():
|
||||
try:
|
||||
manifest = json.loads(manifest_path.read_text(encoding="utf-8-sig"))
|
||||
except (OSError, UnicodeError, json.JSONDecodeError) as exc:
|
||||
findings.append({"level": "error", "message": f"repository.json is invalid: {exc}"})
|
||||
else:
|
||||
for key in ("schema_version", "repository_id", "title", "description", "version", "entrypoints"):
|
||||
if key not in manifest:
|
||||
findings.append({"level": "error", "message": f"repository.json lacks key: {key}"})
|
||||
entrypoints = manifest.get("entrypoints", {})
|
||||
if isinstance(entrypoints, dict):
|
||||
for audience in ("human", "ai"):
|
||||
declared = entrypoints.get(audience)
|
||||
if not declared:
|
||||
findings.append(
|
||||
{"level": "error", "message": f"Missing {audience} entrypoint declaration"}
|
||||
)
|
||||
elif not (root / declared).exists():
|
||||
findings.append(
|
||||
{
|
||||
"level": "error",
|
||||
"message": f"Declared {audience} entrypoint does not exist: {declared}",
|
||||
}
|
||||
)
|
||||
else:
|
||||
findings.append({"level": "error", "message": "entrypoints must be an object"})
|
||||
|
||||
variables_path = root / "repository-variables.json"
|
||||
variables = None
|
||||
if variables_path.is_file():
|
||||
try:
|
||||
variables = json.loads(variables_path.read_text(encoding="utf-8-sig"))
|
||||
except (OSError, UnicodeError, json.JSONDecodeError) as exc:
|
||||
findings.append(
|
||||
{"level": "error", "message": f"repository-variables.json is invalid: {exc}"}
|
||||
)
|
||||
else:
|
||||
for key in (
|
||||
"schema_version",
|
||||
"repository_profile",
|
||||
"identity",
|
||||
"repository",
|
||||
"rights",
|
||||
"skill_defaults",
|
||||
"verified_by",
|
||||
"verified_at",
|
||||
):
|
||||
if key not in variables:
|
||||
findings.append(
|
||||
{
|
||||
"level": "error",
|
||||
"message": f"repository-variables.json lacks key: {key}",
|
||||
}
|
||||
)
|
||||
|
||||
if manifest and variables:
|
||||
identity = variables.get("identity", {})
|
||||
variable_authors = [
|
||||
item.get("name")
|
||||
for item in identity.get("authors", [])
|
||||
if isinstance(item, dict)
|
||||
]
|
||||
manifest_authors = [
|
||||
item.get("name")
|
||||
for item in manifest.get("authors", [])
|
||||
if isinstance(item, dict)
|
||||
]
|
||||
comparisons = (
|
||||
("authors", variable_authors, manifest_authors),
|
||||
(
|
||||
"publisher",
|
||||
identity.get("publisher", {}).get("name"),
|
||||
manifest.get("publisher", {}).get("name"),
|
||||
),
|
||||
(
|
||||
"maintainer",
|
||||
identity.get("maintainer", {}).get("name"),
|
||||
manifest.get("maintenance", {}).get("maintainer"),
|
||||
),
|
||||
(
|
||||
"repository",
|
||||
variables.get("repository"),
|
||||
{
|
||||
key: manifest.get(key)
|
||||
for key in (
|
||||
"repository_id",
|
||||
"name",
|
||||
"title",
|
||||
"canonical_url",
|
||||
"organization",
|
||||
)
|
||||
},
|
||||
),
|
||||
(
|
||||
"rights",
|
||||
variables.get("rights"),
|
||||
{
|
||||
key: manifest.get("rights", {}).get(key)
|
||||
for key in ("license", "license_file")
|
||||
},
|
||||
),
|
||||
)
|
||||
for label, variable_value, manifest_value in comparisons:
|
||||
if variable_value != manifest_value:
|
||||
findings.append(
|
||||
{
|
||||
"level": "error",
|
||||
"message": (
|
||||
f"{label} differs between repository-variables.json "
|
||||
"and repository.json"
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
if variables and variables.get("repository_profile") != profile:
|
||||
findings.append(
|
||||
{
|
||||
"level": "error",
|
||||
"message": (
|
||||
"repository_profile differs between repository-variables.json "
|
||||
f"({variables.get('repository_profile')}) and requested audit ({profile})"
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
audit_content_index(root, findings)
|
||||
|
||||
version_path = root / "VERSION"
|
||||
version = version_path.read_text(encoding="utf-8-sig").strip() if version_path.is_file() else None
|
||||
if version and manifest and manifest.get("version") != version:
|
||||
findings.append(
|
||||
{
|
||||
"level": "error",
|
||||
"message": f"VERSION ({version}) differs from repository.json ({manifest.get('version')})",
|
||||
}
|
||||
)
|
||||
|
||||
citation_version = read_version_from_citation(root / "CITATION.cff")
|
||||
if version and citation_version and citation_version != version:
|
||||
findings.append(
|
||||
{
|
||||
"level": "error",
|
||||
"message": f"VERSION ({version}) differs from CITATION.cff ({citation_version})",
|
||||
}
|
||||
)
|
||||
|
||||
readme = root / "README.md"
|
||||
if readme.is_file() and not readme.read_text(encoding="utf-8-sig").strip():
|
||||
findings.append({"level": "error", "message": "README.md is empty"})
|
||||
|
||||
return {
|
||||
"repository": str(root.resolve()),
|
||||
"profile": profile,
|
||||
"passed": not any(item["level"] == "error" for item in findings),
|
||||
"findings": findings,
|
||||
}
|
||||
|
||||
|
||||
def emit_markdown(result: dict) -> None:
|
||||
print(f"# Repository Audit\n\n- Repository: `{result['repository']}`")
|
||||
print(f"- Profile: `{result['profile']}`")
|
||||
print(f"- Result: `{'PASS' if result['passed'] else 'FAIL'}`")
|
||||
print("\n## Findings")
|
||||
if not result["findings"]:
|
||||
print("\n- No structural errors found.")
|
||||
else:
|
||||
for finding in result["findings"]:
|
||||
print(f"\n- {finding['level'].upper()}: {finding['message']}")
|
||||
|
||||
|
||||
def main() -> int:
|
||||
args = parse_args()
|
||||
result = audit(args.repository, args.profile)
|
||||
if args.json:
|
||||
print(json.dumps(result, indent=2))
|
||||
else:
|
||||
emit_markdown(result)
|
||||
return 0 if result["passed"] else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,6 @@
|
||||
[CmdletBinding()]
|
||||
param()
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
Write-Error "This historical host-specific helper is disabled in the public distribution. Configure and review your own infrastructure; no tunnel or host profile is created by this script."
|
||||
exit 2
|
||||
@@ -0,0 +1,9 @@
|
||||
[CmdletBinding()]
|
||||
param()
|
||||
$ErrorActionPreference = "Stop"
|
||||
if ([string]::IsNullOrWhiteSpace($env:SCHEDULING_TEST_DATABASE)) { throw "Set SCHEDULING_TEST_DATABASE to an isolated test ledger." }
|
||||
$projectRoot = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
|
||||
$pythonCommand = Get-Command python -ErrorAction SilentlyContinue
|
||||
if (-not $pythonCommand) { throw "Python 3.11 or newer must be available on PATH." }
|
||||
$env:PYTHONPATH = Join-Path $projectRoot "src"
|
||||
try { & $pythonCommand.Source (Join-Path $PSScriptRoot "record_authorized_gmail_reply_test.py"); exit $LASTEXITCODE } finally { Remove-Item Env:\PYTHONPATH -ErrorAction SilentlyContinue }
|
||||
@@ -0,0 +1,9 @@
|
||||
[CmdletBinding()]
|
||||
param()
|
||||
$ErrorActionPreference = "Stop"
|
||||
if ([string]::IsNullOrWhiteSpace($env:SCHEDULING_TEST_DATABASE)) { throw "Set SCHEDULING_TEST_DATABASE to an isolated test ledger." }
|
||||
$projectRoot = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
|
||||
$pythonCommand = Get-Command python -ErrorAction SilentlyContinue
|
||||
if (-not $pythonCommand) { throw "Python 3.11 or newer must be available on PATH." }
|
||||
$env:PYTHONPATH = Join-Path $projectRoot "src"
|
||||
try { & $pythonCommand.Source (Join-Path $PSScriptRoot "record_authorized_postmark_test_delivery.py"); exit $LASTEXITCODE } finally { Remove-Item Env:\PYTHONPATH -ErrorAction SilentlyContinue }
|
||||
@@ -0,0 +1,16 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][string]$CalendarEventId,
|
||||
[Parameter(Mandatory=$true)][string]$MeetingId,
|
||||
[Parameter(Mandatory=$true)][string]$MessageId
|
||||
)
|
||||
$ErrorActionPreference = "Stop"
|
||||
foreach ($name in @('SCHEDULING_TEST_DATABASE')) { if ([string]::IsNullOrWhiteSpace([Environment]::GetEnvironmentVariable($name))) { throw "Required isolated test configuration is missing: $name" } }
|
||||
$projectRoot = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
|
||||
$pythonCommand = Get-Command python -ErrorAction SilentlyContinue
|
||||
if (-not $pythonCommand) { throw "Python 3.11 or newer must be available on PATH." }
|
||||
$env:PYTHONPATH = Join-Path $projectRoot "src"
|
||||
$env:SCHEDULING_TEST_CALENDAR_EVENT_ID = $CalendarEventId
|
||||
$env:SCHEDULING_TEST_MEETING_ID = $MeetingId
|
||||
$env:SCHEDULING_TEST_MESSAGE_ID = $MessageId
|
||||
try { & $pythonCommand.Source (Join-Path $PSScriptRoot "record_supervised_calendar_invite_delivery.py"); exit $LASTEXITCODE } finally { Remove-Item Env:\PYTHONPATH,Env:\SCHEDULING_TEST_CALENDAR_EVENT_ID,Env:\SCHEDULING_TEST_MEETING_ID,Env:\SCHEDULING_TEST_MESSAGE_ID -ErrorAction SilentlyContinue }
|
||||
@@ -0,0 +1,14 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][string]$MessageId,
|
||||
[Parameter(Mandatory=$true)][string]$Recipient
|
||||
)
|
||||
$ErrorActionPreference = "Stop"
|
||||
if ([string]::IsNullOrWhiteSpace($env:SCHEDULING_TEST_DATABASE)) { throw "Set SCHEDULING_TEST_DATABASE to an isolated test ledger." }
|
||||
$projectRoot = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
|
||||
$pythonCommand = Get-Command python -ErrorAction SilentlyContinue
|
||||
if (-not $pythonCommand) { throw "Python 3.11 or newer must be available on PATH." }
|
||||
$env:PYTHONPATH = Join-Path $projectRoot "src"
|
||||
$env:SCHEDULING_TEST_MESSAGE_ID = $MessageId
|
||||
$env:SCHEDULING_TEST_RECIPIENT = $Recipient
|
||||
try { & $pythonCommand.Source (Join-Path $PSScriptRoot "record_supervised_postmark_confirmation_delivery.py"); exit $LASTEXITCODE } finally { Remove-Item Env:\PYTHONPATH,Env:\SCHEDULING_TEST_MESSAGE_ID,Env:\SCHEDULING_TEST_RECIPIENT -ErrorAction SilentlyContinue }
|
||||
@@ -0,0 +1,30 @@
|
||||
"""Record caller-supplied, non-production reply-routing evidence in an isolated ledger."""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
from scheduling_core.ledger import Ledger
|
||||
|
||||
|
||||
def main() -> int:
|
||||
required = {
|
||||
"database": os.environ.get("SCHEDULING_TEST_DATABASE", ""),
|
||||
"message_id": os.environ.get("SCHEDULING_TEST_MESSAGE_ID", ""),
|
||||
"thread_id": os.environ.get("SCHEDULING_TEST_THREAD_ID", ""),
|
||||
"sender": os.environ.get("SCHEDULING_TEST_SENDER", ""),
|
||||
"recipient": os.environ.get("SCHEDULING_TEST_RECIPIENT", ""),
|
||||
"observed_at": os.environ.get("SCHEDULING_TEST_OBSERVED_AT", ""),
|
||||
}
|
||||
if not all(required.values()):
|
||||
print("FAIL isolated database and evidence fields are required")
|
||||
return 1
|
||||
evidence = {key: value for key, value in required.items() if key != "database"}
|
||||
Ledger(Path(required["database"])).record_owner_transport_evidence(
|
||||
"authorized-owner-delivery-test-gmail-reply-v1", evidence
|
||||
)
|
||||
print("recorded_nonproduction_transport_evidence")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
@@ -0,0 +1,33 @@
|
||||
"""Record a caller-verified message ID for a non-production delivery test."""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
from scheduling_core.ledger import Ledger, OperationState
|
||||
|
||||
|
||||
def main() -> int:
|
||||
database = os.environ.get("SCHEDULING_TEST_DATABASE", "")
|
||||
operation_key = os.environ.get("SCHEDULING_TEST_OPERATION_KEY", "")
|
||||
message_id = os.environ.get("SCHEDULING_TEST_MESSAGE_ID", "")
|
||||
if not all((database, operation_key, message_id)):
|
||||
print("FAIL isolated database, operation key, and message ID are required")
|
||||
return 1
|
||||
ledger = Ledger(Path(database))
|
||||
operation = ledger.operation_for_key(operation_key)
|
||||
if operation is None or operation["provider_id"] != message_id:
|
||||
print("FAIL operation does not match the supplied provider message ID")
|
||||
return 1
|
||||
if operation["state"] == OperationState.COMPLETED:
|
||||
print("completed")
|
||||
return 0
|
||||
if operation["state"] != OperationState.ACCEPTED:
|
||||
print(f"FAIL operation is {operation['state']}")
|
||||
return 1
|
||||
ledger.transition_operation(operation_key, OperationState.COMPLETED, message_id)
|
||||
print("completed")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
@@ -0,0 +1,31 @@
|
||||
"""Record caller-supplied sample evidence for an isolated calendar/meeting test."""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
from scheduling_core.ledger import Ledger
|
||||
|
||||
|
||||
def main() -> int:
|
||||
database = os.environ.get("SCHEDULING_TEST_DATABASE", "")
|
||||
event_id = os.environ.get("SCHEDULING_TEST_CALENDAR_EVENT_ID", "")
|
||||
meeting_id = os.environ.get("SCHEDULING_TEST_MEETING_ID", "")
|
||||
message_id = os.environ.get("SCHEDULING_TEST_MESSAGE_ID", "")
|
||||
if not all((database, event_id, meeting_id, message_id)):
|
||||
print("FAIL isolated database and sample provider IDs are required")
|
||||
return 1
|
||||
Ledger(Path(database)).record_supervised_test_evidence(
|
||||
"authorized-supervised-calendar-invite-delivery-v1",
|
||||
{
|
||||
"calendar_event_id": event_id,
|
||||
"meeting_id": meeting_id,
|
||||
"provider_message_id": message_id,
|
||||
"confirmation": "caller-confirmed-test-only",
|
||||
},
|
||||
)
|
||||
print("recorded_nonproduction_supervised_evidence")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
@@ -0,0 +1,29 @@
|
||||
"""Record caller-supplied sample evidence for a non-production delivery test."""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
from scheduling_core.ledger import Ledger
|
||||
|
||||
|
||||
def main() -> int:
|
||||
database = os.environ.get("SCHEDULING_TEST_DATABASE", "")
|
||||
message_id = os.environ.get("SCHEDULING_TEST_MESSAGE_ID", "")
|
||||
recipient = os.environ.get("SCHEDULING_TEST_RECIPIENT", "")
|
||||
if not all((database, message_id, recipient)):
|
||||
print("FAIL isolated database, sample message ID, and recipient are required")
|
||||
return 1
|
||||
Ledger(Path(database)).record_supervised_test_evidence(
|
||||
"authorized-supervised-postmark-confirmation-delivery-v1",
|
||||
{
|
||||
"provider_message_id": message_id,
|
||||
"recipient": recipient,
|
||||
"confirmation": "caller-confirmed-test-only",
|
||||
},
|
||||
)
|
||||
print("recorded_nonproduction_supervised_evidence")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
@@ -0,0 +1,6 @@
|
||||
[CmdletBinding()]
|
||||
param()
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
Write-Error "This historical host-specific helper is disabled in the public distribution. Configure and review your own infrastructure; no tunnel or host profile is created by this script."
|
||||
exit 2
|
||||
@@ -0,0 +1,6 @@
|
||||
[CmdletBinding()]
|
||||
param()
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
Write-Error "This historical host-specific helper is disabled in the public distribution. Configure and review your own infrastructure; no tunnel or host profile is created by this script."
|
||||
exit 2
|
||||
@@ -0,0 +1,6 @@
|
||||
[CmdletBinding()]
|
||||
param()
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
Write-Error "This historical host-specific helper is disabled in the public distribution. Configure and review your own infrastructure; no tunnel or host profile is created by this script."
|
||||
exit 2
|
||||
@@ -0,0 +1,6 @@
|
||||
[CmdletBinding()]
|
||||
param()
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
Write-Error "This historical host-specific helper is disabled in the public distribution. Configure and review your own infrastructure; no tunnel or host profile is created by this script."
|
||||
exit 2
|
||||
@@ -0,0 +1,6 @@
|
||||
[CmdletBinding()]
|
||||
param()
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
Write-Error "This historical host-specific helper is disabled in the public distribution. Configure and review your own infrastructure; no tunnel or host profile is created by this script."
|
||||
exit 2
|
||||
@@ -0,0 +1,21 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][switch]$ConfirmExternalSend
|
||||
)
|
||||
$ErrorActionPreference = "Stop"
|
||||
foreach ($name in @('POSTMARK_SERVER_TOKEN','SCHEDULING_TEST_DATABASE','SCHEDULING_TEST_SENDER','SCHEDULING_TEST_RECIPIENT')) {
|
||||
if ([string]::IsNullOrWhiteSpace([Environment]::GetEnvironmentVariable($name))) { throw "Required environment configuration is missing: $name" }
|
||||
}
|
||||
$projectRoot = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
|
||||
$pythonCommand = Get-Command python -ErrorAction SilentlyContinue
|
||||
if (-not $pythonCommand) { throw "Python 3.11 or newer must be available on PATH." }
|
||||
$prior = $env:SCHEDULING_AUTHORIZED_POSTMARK_TEST
|
||||
try {
|
||||
$env:SCHEDULING_AUTHORIZED_POSTMARK_TEST = "1"
|
||||
$env:PYTHONPATH = Join-Path $projectRoot "src"
|
||||
& $pythonCommand.Source (Join-Path $PSScriptRoot "send_authorized_postmark_test.py")
|
||||
exit $LASTEXITCODE
|
||||
} finally {
|
||||
$env:SCHEDULING_AUTHORIZED_POSTMARK_TEST = $prior
|
||||
Remove-Item Env:\PYTHONPATH -ErrorAction SilentlyContinue
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
[CmdletBinding()]
|
||||
param([Parameter(Mandatory=$true)][switch]$ConfirmExternalSend)
|
||||
$ErrorActionPreference = "Stop"
|
||||
foreach ($name in @('POSTMARK_SERVER_TOKEN','SCHEDULING_TEST_DATABASE','SCHEDULING_TEST_SENDER','SCHEDULING_TEST_RECIPIENT','SCHEDULING_TEST_SUBJECT','SCHEDULING_TEST_MESSAGE_BODY')) {
|
||||
if ([string]::IsNullOrWhiteSpace([Environment]::GetEnvironmentVariable($name))) { throw "Required environment configuration is missing: $name" }
|
||||
}
|
||||
$projectRoot = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
|
||||
$pythonCommand = Get-Command python -ErrorAction SilentlyContinue
|
||||
if (-not $pythonCommand) { throw "Python 3.11 or newer must be available on PATH." }
|
||||
$prior = $env:SCHEDULING_AUTHORIZED_SUPERVISED_TEST
|
||||
try {
|
||||
$env:SCHEDULING_AUTHORIZED_SUPERVISED_TEST = "1"
|
||||
$env:PYTHONPATH = Join-Path $projectRoot "src"
|
||||
& $pythonCommand.Source (Join-Path $PSScriptRoot "send_supervised_invite_confirmation.py")
|
||||
exit $LASTEXITCODE
|
||||
} finally {
|
||||
$env:SCHEDULING_AUTHORIZED_SUPERVISED_TEST = $prior
|
||||
Remove-Item Env:\PYTHONPATH -ErrorAction SilentlyContinue
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
"""One explicitly authorized, one-shot provider delivery test; never part of normal scheduling."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import urllib.error
|
||||
from datetime import UTC, datetime, timedelta
|
||||
from pathlib import Path
|
||||
|
||||
from scheduling_core.ledger import Ledger, OperationState
|
||||
from scheduling_core.postmark import BoundMessage, PostmarkAdapter, PostmarkHttpsClient
|
||||
|
||||
TRANSACTION_ID = "public-sample-provider-delivery-test-v1"
|
||||
OPERATION_KEY = "public-sample-provider-delivery-test-send-v1"
|
||||
SUBJECT = "Scheduling integration test"
|
||||
BODY = "This is an explicitly authorized integration test. No meeting is being booked."
|
||||
|
||||
|
||||
def delivery_status(client: PostmarkHttpsClient, message_id: str) -> str:
|
||||
"""Read status after acceptance; never resends when status is unavailable."""
|
||||
try:
|
||||
details = client.status(message_id)
|
||||
except urllib.error.HTTPError as error:
|
||||
return f"accepted; delivery_status_unavailable_http_{error.code}"
|
||||
except (TimeoutError, urllib.error.URLError, ValueError):
|
||||
return "accepted; delivery_status_unavailable"
|
||||
events = details.get("MessageEvents", []) if isinstance(details, dict) else []
|
||||
kinds = {event.get("Type", "").casefold() for event in events if isinstance(event, dict)}
|
||||
return "delivered" if "delivered" in kinds else "accepted; delivery_pending"
|
||||
|
||||
|
||||
def main() -> int:
|
||||
if os.environ.get("SCHEDULING_AUTHORIZED_POSTMARK_TEST") != "1":
|
||||
print("FAIL one-shot authorization gate is not enabled")
|
||||
return 1
|
||||
token = os.environ.get("POSTMARK_SERVER_TOKEN", "")
|
||||
sender = os.environ.get("SCHEDULING_TEST_SENDER", "")
|
||||
recipient = os.environ.get("SCHEDULING_TEST_RECIPIENT", "")
|
||||
database = os.environ.get("SCHEDULING_TEST_DATABASE", "")
|
||||
if not token or not sender or not recipient or not database:
|
||||
print("FAIL token, test sender, test recipient, and database configuration are required")
|
||||
return 1
|
||||
|
||||
ledger = Ledger(Path(database))
|
||||
expires_at = datetime.now(UTC) + timedelta(minutes=15)
|
||||
ledger.create_authorized_owner_delivery_test(
|
||||
transaction_id=TRANSACTION_ID,
|
||||
sender=sender,
|
||||
recipient=recipient,
|
||||
expires_at=expires_at,
|
||||
)
|
||||
existing = ledger.operation_for_key(OPERATION_KEY)
|
||||
if existing is not None and existing["state"] in {OperationState.UNCERTAIN, OperationState.PENDING}:
|
||||
print(f"NO_SEND state={existing['state']} reconciliation_required")
|
||||
return 2
|
||||
|
||||
client = PostmarkHttpsClient(secret_provider=lambda: token, enabled=True)
|
||||
adapter = PostmarkAdapter(ledger, client)
|
||||
try:
|
||||
message_id = adapter.send_bound_message(
|
||||
TRANSACTION_ID,
|
||||
OPERATION_KEY,
|
||||
sender,
|
||||
recipient,
|
||||
BoundMessage(SUBJECT, BODY),
|
||||
)
|
||||
except urllib.error.HTTPError as error:
|
||||
print(f"FAIL provider HTTP {error.code}")
|
||||
return 1
|
||||
except Exception:
|
||||
operation = ledger.operation_for_key(OPERATION_KEY)
|
||||
print(f"NO_SEND state={operation['state'] if operation else 'unknown'} reconciliation_required")
|
||||
return 2
|
||||
|
||||
operation = ledger.operation_for_key(OPERATION_KEY)
|
||||
if message_id is None or operation is None or operation["state"] != OperationState.ACCEPTED:
|
||||
print("NO_SEND state=uncertain reconciliation_required")
|
||||
return 2
|
||||
status = delivery_status(client, message_id)
|
||||
print(json.dumps({"message_id": message_id, "accepted_at": operation["updated_at"], "status": status}, sort_keys=True))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
@@ -0,0 +1,68 @@
|
||||
"""One explicitly authorized provider confirmation example with caller-supplied content."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
import urllib.error
|
||||
from datetime import UTC, datetime, timedelta
|
||||
from pathlib import Path
|
||||
|
||||
from scheduling_core.ledger import Ledger, OperationState
|
||||
from scheduling_core.postmark import BoundMessage, PostmarkAdapter, PostmarkHttpsClient
|
||||
|
||||
TRANSACTION_ID = "public-sample-confirmation-test-v1"
|
||||
OPERATION_KEY = "public-sample-confirmation-test-send-v1"
|
||||
|
||||
|
||||
def main() -> int:
|
||||
if os.environ.get("SCHEDULING_AUTHORIZED_SUPERVISED_TEST") != "1":
|
||||
print("FAIL one-shot authorization gate is not enabled")
|
||||
return 1
|
||||
token = os.environ.get("POSTMARK_SERVER_TOKEN", "")
|
||||
sender = os.environ.get("SCHEDULING_TEST_SENDER", "")
|
||||
recipient = os.environ.get("SCHEDULING_TEST_RECIPIENT", "")
|
||||
subject = os.environ.get("SCHEDULING_TEST_SUBJECT", "")
|
||||
body = os.environ.get("SCHEDULING_TEST_MESSAGE_BODY", "")
|
||||
database = os.environ.get("SCHEDULING_TEST_DATABASE", "")
|
||||
if not all((token, sender, recipient, subject, body, database)):
|
||||
print("FAIL token, test sender, recipient, subject, message body, and database configuration are required")
|
||||
return 1
|
||||
|
||||
ledger = Ledger(Path(database))
|
||||
ledger.create_authorized_owner_delivery_test(
|
||||
transaction_id=TRANSACTION_ID,
|
||||
sender=sender,
|
||||
recipient=recipient,
|
||||
expires_at=datetime.now(UTC) + timedelta(minutes=15),
|
||||
)
|
||||
existing = ledger.operation_for_key(OPERATION_KEY)
|
||||
if existing is not None and existing["state"] in {OperationState.PENDING, OperationState.UNCERTAIN}:
|
||||
print(f"NO_SEND state={existing['state']} reconciliation_required")
|
||||
return 2
|
||||
|
||||
client = PostmarkHttpsClient(secret_provider=lambda: token, enabled=True)
|
||||
try:
|
||||
message_id = PostmarkAdapter(ledger, client).send_bound_message(
|
||||
TRANSACTION_ID,
|
||||
OPERATION_KEY,
|
||||
sender,
|
||||
recipient,
|
||||
BoundMessage(subject, body),
|
||||
)
|
||||
except urllib.error.HTTPError as error:
|
||||
print(f"FAIL provider HTTP {error.code}")
|
||||
return 1
|
||||
except Exception:
|
||||
operation = ledger.operation_for_key(OPERATION_KEY)
|
||||
print(f"NO_SEND state={operation['state'] if operation else 'unknown'} reconciliation_required")
|
||||
return 2
|
||||
operation = ledger.operation_for_key(OPERATION_KEY)
|
||||
if message_id is None or operation is None or operation["state"] != OperationState.ACCEPTED:
|
||||
print("NO_SEND state=uncertain reconciliation_required")
|
||||
return 2
|
||||
print(json.dumps({"message_id": message_id, "accepted_at": operation["updated_at"], "status": "accepted"}, sort_keys=True))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
@@ -0,0 +1,10 @@
|
||||
[CmdletBinding()]
|
||||
param([string]$DatabasePath)
|
||||
$ErrorActionPreference = "Stop"
|
||||
$projectRoot = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
|
||||
if (-not $DatabasePath) { $DatabasePath = Join-Path $projectRoot "state\scheduling-ledger.sqlite3" }
|
||||
$pythonCommand = Get-Command python -ErrorAction SilentlyContinue
|
||||
if (-not $pythonCommand) { throw "Python 3.11 or newer must be available on PATH." }
|
||||
$env:PYTHONPATH = Join-Path $projectRoot "src"
|
||||
$env:SCHEDULING_DB = $DatabasePath
|
||||
try { & $pythonCommand.Source -m scheduling_core.api } finally { Remove-Item Env:\PYTHONPATH,Env:\SCHEDULING_DB -ErrorAction SilentlyContinue }
|
||||
@@ -0,0 +1,38 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][string]$FixedSender,
|
||||
[string]$DatabasePath,
|
||||
[switch]$EnablePostmarkSend,
|
||||
[switch]$ConfirmExternalSend,
|
||||
[string]$SupervisedTransactionId,
|
||||
[string]$SupervisedRequester,
|
||||
[string]$SupervisedOwner
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
if ($EnablePostmarkSend -and -not $ConfirmExternalSend) { throw "External sending requires -ConfirmExternalSend." }
|
||||
if ($EnablePostmarkSend -and [string]::IsNullOrWhiteSpace($env:POSTMARK_SERVER_TOKEN)) { throw "Set POSTMARK_SERVER_TOKEN using your approved secret manager." }
|
||||
$priorPostmarkEnable = $env:SCHEDULING_POSTMARK_ENABLE
|
||||
$priorSupervisedScope = $env:SCHEDULING_SUPERVISED_SEND_SCOPE
|
||||
Remove-Item Env:\SCHEDULING_POSTMARK_ENABLE,Env:\SCHEDULING_SUPERVISED_SEND_SCOPE -ErrorAction SilentlyContinue
|
||||
if ($SupervisedTransactionId -or $SupervisedRequester -or $SupervisedOwner) {
|
||||
if (-not $EnablePostmarkSend -or -not $SupervisedTransactionId -or -not $SupervisedRequester -or -not $SupervisedOwner) { throw "Supervised send requires explicit enablement, transaction, requester, and owner." }
|
||||
$env:SCHEDULING_SUPERVISED_SEND_SCOPE = @{ transaction_id=$SupervisedTransactionId; requester=$SupervisedRequester; owner=$SupervisedOwner } | ConvertTo-Json -Compress
|
||||
}
|
||||
$scriptRoot = Split-Path -Parent $PSCommandPath
|
||||
$projectRoot = (Resolve-Path (Join-Path $scriptRoot "..")).Path
|
||||
if (-not $DatabasePath) { $DatabasePath = Join-Path $projectRoot "state\scheduling-ledger.sqlite3" }
|
||||
$pythonCommand = Get-Command python -ErrorAction SilentlyContinue
|
||||
if (-not $pythonCommand) { throw "Python 3.11 or newer must be available on PATH." }
|
||||
$env:PYTHONPATH = Join-Path $projectRoot "src"
|
||||
$env:SCHEDULING_DB = $DatabasePath
|
||||
$env:SCHEDULING_MCP_ENABLE = "1"
|
||||
$env:SCHEDULING_FIXED_SENDER = $FixedSender
|
||||
if ($EnablePostmarkSend) { $env:SCHEDULING_POSTMARK_ENABLE = "1" }
|
||||
try { & $pythonCommand.Source -m scheduling_core.mcp_stdio } finally {
|
||||
if ($null -ne $priorPostmarkEnable) { $env:SCHEDULING_POSTMARK_ENABLE = $priorPostmarkEnable }
|
||||
else { Remove-Item Env:\SCHEDULING_POSTMARK_ENABLE -ErrorAction SilentlyContinue }
|
||||
if ($null -ne $priorSupervisedScope) { $env:SCHEDULING_SUPERVISED_SEND_SCOPE = $priorSupervisedScope }
|
||||
else { Remove-Item Env:\SCHEDULING_SUPERVISED_SEND_SCOPE -ErrorAction SilentlyContinue }
|
||||
Remove-Item Env:\SCHEDULING_DB,Env:\SCHEDULING_MCP_ENABLE,Env:\SCHEDULING_FIXED_SENDER,Env:\PYTHONPATH -ErrorAction SilentlyContinue
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
[CmdletBinding()]
|
||||
param()
|
||||
$ErrorActionPreference = "Stop"
|
||||
if ([string]::IsNullOrWhiteSpace($env:POSTMARK_SERVER_TOKEN)) { throw "Set POSTMARK_SERVER_TOKEN using your approved secret manager." }
|
||||
$projectRoot = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
|
||||
$pythonCommand = Get-Command python -ErrorAction SilentlyContinue
|
||||
if (-not $pythonCommand) { throw "Python 3.11 or newer must be available on PATH." }
|
||||
$env:PYTHONPATH = Join-Path $projectRoot "src"
|
||||
try { & $pythonCommand.Source (Join-Path $PSScriptRoot "verify_postmark_readonly.py"); exit $LASTEXITCODE } finally { Remove-Item Env:\PYTHONPATH -ErrorAction SilentlyContinue }
|
||||
@@ -0,0 +1,79 @@
|
||||
"""Read-only Postmark prerequisite verifier. Never prints tokens or response bodies."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
|
||||
|
||||
BASE = "https://api.postmarkapp.com"
|
||||
|
||||
|
||||
def build_readonly_request(path: str, token: str) -> urllib.request.Request:
|
||||
"""Construct a server-token GET request without logging credential material."""
|
||||
return urllib.request.Request(
|
||||
f"{BASE}{path}",
|
||||
headers={
|
||||
"Accept": "application/json",
|
||||
"X-Postmark-Server-Token": token,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def get(path: str, token: str) -> object:
|
||||
request = build_readonly_request(path, token)
|
||||
with urllib.request.urlopen(request, timeout=15) as response:
|
||||
return json.loads(response.read())
|
||||
|
||||
|
||||
def safe_http_failure(error: urllib.error.HTTPError, path: str) -> str:
|
||||
"""Return only documented Postmark error fields; never emit request data."""
|
||||
error_code = None
|
||||
message = None
|
||||
try:
|
||||
body = json.loads(error.read())
|
||||
if isinstance(body, dict):
|
||||
raw_code = body.get("ErrorCode")
|
||||
raw_message = body.get("Message")
|
||||
error_code = raw_code if isinstance(raw_code, int) else None
|
||||
message = raw_message if isinstance(raw_message, str) else None
|
||||
except (OSError, UnicodeDecodeError, json.JSONDecodeError):
|
||||
pass
|
||||
detail = f" endpoint={path}"
|
||||
if error_code is not None:
|
||||
detail += f" postmark_error_code={error_code}"
|
||||
if message:
|
||||
detail += f" postmark_message={message!r}"
|
||||
return f"FAIL Postmark HTTP {error.code}{detail}"
|
||||
|
||||
|
||||
def main() -> int:
|
||||
token = os.environ.get("POSTMARK_SERVER_TOKEN", "")
|
||||
if not token:
|
||||
print("FAIL token unavailable")
|
||||
return 1
|
||||
for path in ("/server", "/message-streams/outbound"):
|
||||
try:
|
||||
response = get(path, token)
|
||||
except urllib.error.HTTPError as error:
|
||||
print(safe_http_failure(error, path))
|
||||
return 1
|
||||
except (urllib.error.URLError, TimeoutError, json.JSONDecodeError):
|
||||
print(f"FAIL Postmark read-only request unavailable endpoint={path}")
|
||||
return 1
|
||||
if path == "/server":
|
||||
server = response
|
||||
else:
|
||||
stream = response
|
||||
server_ok = isinstance(server, dict) and bool(server.get("Name"))
|
||||
stream_ok = isinstance(stream, dict) and stream.get("ID") == "outbound" and stream.get("MessageStreamType") == "Transactional"
|
||||
# Sender-signature inspection is deliberately excluded: /senders requires
|
||||
# an account token, while this component is restricted to a server token.
|
||||
print(f"server={'ok' if server_ok else 'fail'} stream={'ok' if stream_ok else 'fail'}")
|
||||
return 0 if server_ok and stream_ok else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in new issue
Block a user