CtrlK
BlogDocsLog inGet started
Tessl Logo
PluginPublic

jbaruch/herdr-policy

Herdr team coordination policy for AI coding agents

Quality

93%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide
SecuritybySnyk

Low

Low-risk findings worth noting

Overview
Quality
Evals
Security
Files

chronology.pyskills/herdr-foreman/foreman/

"""Compare assignment event times without moving append-only audit rows.

Assignment ``at`` is the actual event time, including for historical imports;
recovery receipt times and list offsets are not event chronology. Missing,
naive or tied times cannot prove which relevant event came last. Earlier ties
are harmless when a strictly newer event establishes the latest assignment.
"""

from datetime import datetime

from .errors import UsageError


def timestamp(value, label):
    if not isinstance(value, str) or not value.strip() or value != value.strip():
        raise UsageError("{} needs its original ISO-8601 timestamp with timezone; recover the event evidence without rewriting assignment history.".format(label), {})
    try:
        parsed = datetime.fromisoformat(value.replace("Z", "+00:00"))
    except ValueError:
        raise UsageError("{} must be an ISO-8601 timestamp with timezone; recover the original event evidence.".format(label), {}) from None
    if parsed.tzinfo is None:
        raise UsageError("{} needs an explicit timezone; preserve the original event time.".format(label), {})
    return parsed


def assignment_after(assignments, later_index, earlier_index):
    """Prove ordering between original rows; an equal instant is uncertain."""
    later = timestamp(assignments[later_index].get("at"), "Assignment {} chronology".format(later_index))
    earlier = timestamp(assignments[earlier_index].get("at"), "Assignment {} chronology".format(earlier_index))
    if later == earlier:
        raise UsageError("Assignment chronology is uncertain at indices {} and {}: their event times are tied. Recover the original ordering evidence; do not reorder the audit or dispatch on a guess.".format(earlier_index, later_index), {})
    return later > earlier


def latest_assignment(assignments, *, agent=None, task=None, role=None, status=None, before=None):
    """Return ``(original_index, original_row)`` or None, never a sorted audit.

    Filters narrow the relevant history. ``before`` is an original assignment
    index whose event must follow every candidate; later rows are excluded by
    time, not by append position. Unknown relevant chronology raises UsageError.
    """
    filters = {"agent": agent, "task": task, "role": role, "status": status}
    candidates = []
    for index, row in enumerate(assignments):
        if index == before or any(value is not None and row.get(key) != value for key, value in filters.items()):
            continue
        at = timestamp(row.get("at"), "Assignment {} chronology".format(index))
        if before is not None and not assignment_after(assignments, before, index):
            continue
        candidates.append((at, index, row))
    if not candidates:
        return None
    latest_time = max(candidate[0] for candidate in candidates)
    latest = [(index, row) for at, index, row in candidates if at == latest_time]
    if len(latest) != 1:
        raise UsageError("Latest assignment chronology is uncertain at indices {}: their event times are tied. Recover the original ordering evidence; do not reorder the audit or dispatch on a guess.".format(
            ", ".join(str(index) for index, _row in latest)), {})
    return latest[0]

skills

herdr-foreman

foreman

__init__.py

__main__.py

antigravity_native.py

assign.py

attention_view.py

attention.py

billing.py

bootstrap_recovery.py

brief_inputs.py

capabilities.py

chronology.py

churn.py

claude_native.py

cli.py

codex_goals.py

command_context.py

composer.py

composition.py

config.py

context_evidence.py

context_output.py

coordination_metrics.py

cost_report.py

delivery_collection.py

diagnostics.py

engagement.py

errors.py

foreman_queue.py

foreman_reset.py

github_context.py

herdr.py

historical.py

home.py

host_goals.py

launch.py

lifecycle.py

load_set.py

measure.py

measurement_capture.py

measurement_retry.py

members.py

memory.py

model_unavailability.py

native_permissions.py

native_policy.py

no_work_recovery.py

observer_projection.py

observer_role.py

oracle.py

parsers.py

partition.py

plan_explanation.py

planner.py

policy_paths.py

probe_recovery.py

probe.py

process_lease.py

progression_owner.py

progression_runtime.py

progression_service.py

provision.py

recovery.py

release_activation.py

release_checkout.py

release_flight.py

release_rebind.py

remote_owner.py

remote_service.py

renderable.py

report_contract.py

report_delivery.py

report_gates.py

reset_input_hook.py

restoration.py

retrospective_runtime.py

retrospective.py

role_clear.py

role_context.py

runnable.py

selection.py

session_start_hook.py

state.py

successors.py

supervision_gate.py

supervision_hook.py

supervision_runtime.py

supervision.py

task_evidence.py

tier_routing.py

tiers.py

triggers.py

workflow_adoption.py

workflow_artifacts.py

workflow_batch.py

workflow_capacity.py

workflow_contract.py

workflow_dispatch.py

workflow_native.py

workflow_planning.py

workflow_profiles.py

workflow_readiness.py

workflow_recovery.py

workflow_release.py

workflow_rename.py

workflow_review.py

workflow_service.py

workflow_upgrade.py

workflow_workspace.py

antigravity.example.json

bootstrap-repository.py

compose-briefs.sh

config.example.json

foreman-tier-check.py

foreman.sh

label-workspaces.sh

measurements.py

native-hook.sh

observer-view.py

policy-paths.py

prepare-briefs.py

provision-worktree.sh

prune-report-caches.py

resolve-gates.sh

resolve-policy-paths.sh

review-package.sh

roster.sh

round-preflight.sh

SKILL.md

start-judge-worker.sh

state-schema.md

sweep-worktrees.sh

verify-authority.sh

wait-report.sh

workflow-review.py

README.md

tile.json