perago.check_guardrails#

perago.check_guardrails(root, guardrails, phase)[源代码]#

Evaluate workspace guardrails against a local attempt workspace.

This function is used by the runtime before and after a workspace task body executes. phase is included in error messages so callers can map pre and post failures to the correct runtime result classification.

Parameters:
rootpathlib.Path

Local attempt workspace directory to inspect.

guardrailslist of workspace guardrails

Guardrails produced by require_file(), require_dir(), require_glob(), or forbid_glob().

phasestr

Human-readable phase label, usually "pre" or "post".

Returns:
None

The function returns None when all guardrails pass.

Raises:
GuardrailViolation

If a required file or directory is missing, a required glob has too few or too many matches, or a forbidden glob has any matches.

参数:
  • root (Path)

  • guardrails (list[_WorkspaceGuardrail])

  • phase (str)

返回类型:

None

Examples

>>> check_guardrails(workspace_dir, [require_file("input/data.csv")], "pre")