bring-your-own-spec.md

Created about 12 hours ago

attributes
source_pathreferences/dataset-quality/references/bring-your-own-spec.md
source_sha2564c786f1a9ab5876666076fbfad6285cb6445d5f4d47cf3f9317f0731f0699658
source_urlhttps://github.com/aws/agent-toolkit-for-aws/blob/903433d67cc4eeab334355620373f33a0c162dd4/skills/core-skills/aws-ai-ml/references/dataset-quality/references/bring-your-own-spec.md
supporting_skill_id40202
upstream_revision903433d67cc4eeab334355620373f33a0c162dd4

Bring Your Own Spec

Runs a quality evaluation when the caller already has a finished spec (the written list of criteria the job evaluates against). No interview, no metric selection, no offer of built-in metrics: the spec is the whole evaluation. Any capability or user can enter here. This page runs a new job from a finished spec; a request for the results or the report of a job that already ran, a spec job included, is answered by results-and-report.md Step 13 as written, its next-step menu included, and never enters this page.

Enter from quality-job.md Step 7 when a spec file or S3 URI is in the request, or when another capability hands one in. Skip quality-job.md Steps 7-11; this page confirms the plan itself (Step 3). Do not run the local format detector of references/format-check.md on this path: the dataset's format comes from the Dataset entity (DatasetFileFormat), and the data is never read locally.

Step 0: Who is calling? — two lanes

Decide once, before anything else, and say what you are doing in one sentence in chat, without the lane names, which are this page's labels (overview.md Principle 7): "You brought the spec; I run it as written" / "Running the spec for ", with the name the calling capability gave:

  • Skill-caller lane — another capability hands in the spec and names itself as the caller (caller = <its capability name>, with the spec kind check or characterization). It knows what it wants: run this spec, return the outputs, no guidance. The lane is the same for every calling capability: the caller's name addresses it in the hand-back and changes nothing else; no caller has a lane, an exception or a skipped output of its own. Steps 1-3 apply; Step 4 uses the fixed snippet in Step 4S and never enters quality-job-submit.md (Steps 12 and 12b) or results-and-report.md (Step 13); the report is written from the template with the substitutions Step 4S names.
  • Guided lane: a person brings a spec, or a capability asks for the user experience. Steps 1-3 apply; Step 4 follows Step 4G, which uses quality-job-submit.md Step 12's code generation and Step 12b's waiting, and results-and-report.md Step 13's reporting, as written, with the exceptions it names. Delivery mode on this lane: script for a calling capability; for a person, the mode already chosen for the run (quality-job-submit.md Step 12, "Delivery Mode") if there is one, otherwise script, stated in the plan summary. Do not add a question for it.

Nothing on the normal dataset quality evaluation path (quality-job.md, quality-job-submit.md and results-and-report.md, Steps 7-13) changes for either lane.


Inputs

Input Required? Description
Dataset Yes A Dataset ARN (Amazon Resource Name of a registered SageMaker Dataset). A local file or S3 URI is accepted but must be registered first; the main path does that in its generated notebook after the plan confirmation (quality-job.md Step 8 collects the location; dataset-import.md is the import's contract).
Spec One of Spec / Code artifact Local path or S3 URI to one .md or .txt file. Prose or structured (a ## Criteria block).
Output S3 prefix Yes Where the job writes. Reuse the run's prefix when one exists (Step 11 rule).
Judge model No Only if the caller names one. Otherwise send no ModelConfig; the service applies its default for spec-driven evaluation (spec-authoring.md Step 7b).
Sample size No DownSampleRecordCount. Only if the caller asks for a sample run.
Reference documents No ContextDocumentsS3Uri, inside the spec_eval operation's Config: an S3 folder URI ending in / whose files the spec's context: documents criteria are judged against. Check every object, hidden files included, against the service-owned contract in references/dataset-service-api.md §Spec-driven evaluation ("The documents folder"), which states the folder limits and failure remedies; a folder that misses one fails the job before compute with the service's message naming the file or folder. Required when a structured spec has such a criterion: without it the job fails with CONTEXT_REQUIRED_NO_DOCUMENTS; that failure, CONTEXT_DOCUMENT_UNREADABLE and CONTEXT_DOCUMENTS_TOO_LARGE, each with its remedy, are named in the same section.
Caller, spec kind Skill-caller lane The calling capability's name and whether the spec is a check (pass/fail criteria) or a characterization (labels and measurements, no pass/fail). Absent → guided lane.
Run-log step No (skill-caller lane) The step and iteration the job's run-log entries carry, as the caller names them, and any extra fields of the launch entry. Absent: the task's name, 0 and no extra field.
PII views Skill callers only [PII_VIEWS]: the columns a calling capability wants scanned for PII, one Messages view for a chat column, or one or more Text views for flat text columns, sent as one pii_detection operation beside the spec (a job runs pii_detection at most once) (its contract: references/on-request-metrics.md (PII Detection)); PII views alone make a valid job with no spec. A PII view always checks every row: a skill caller cannot sample PII, so a dataset over the full-scan limits fails its job; split it or drop the view. Absent: none.
Metric views Skill callers only [METRIC_VIEWS]: the model-free metrics a calling capability wants run beside its spec or code artifact, each bound to one flat text column with its parameters (exact_dedup, fuzzy_dedup or language_detection; references/on-request-metrics.md); one operation per metric and column; never alone. Absent: none.
Autonomous mode No (skill-caller lane) Whether the calling capability runs in an autonomous mode, as it declares it in the inputs it hands over (the planning capability does so with autonomous: true in its collect-run-parameters run-log entry), or a calling plan's user-answered gate that already covered the job (Step 3). Only the caller declares it; the agent never infers it. Absent: no autonomous mode, and Step 3 asks its question.
Wait for the result? No Whether the caller needs the job's outputs before it continues (wait: the default, and what a caller that reads metadata.json next must choose) or wants the job started and the turn back (no wait: the job name and ARN are handed back; the caller collects the outputs later). A user or a calling capability states this in its own words; absent, Step 3 asks.
Code artifact One of Spec / Code artifact CodeArtifactS3Uri of an earlier job's spec_eval/ folder. When given instead of a spec, the job re-runs those exact criteria and nothing is uploaded, derived, or linted — Steps 1–2 are skipped and the plan (Step 3) names the artifact instead of a spec (a re-judge round, or a new version of the same set). When those criteria use context: documents, the Reference documents row is required too, with the same ContextDocumentsS3Uri the earlier job used; why, and what a re-run without it fails with: quality-job-submit.md, "Re-run from a previously generated code artifact".

What a criterion can read. The service passes the spec the Dataset's own columns and, through an aggregate criterion's inputs, the row verdicts of the same spec. No criterion reads (or names, even in reads) a same-job dq_ column: read the dedup and PII results from the report's exact_dedup, fuzzy_dedup and pii_detection sections and, per row, from the row-level file (references/output-schema.md, which also says that the PII columns are null outside the sample).


Step 1: Read the spec and decide its form

Code artifact instead of a spec → skip Steps 1 and 2; go to Step 3. Otherwise open the file. It is structured if it contains a ## Criteria heading (an H2 whose text is exactly Criteria, any case); otherwise it is prose.

  • Prose → nothing to lint (a model turns the text into criteria at job time; ids are assigned then). Go to Step 3.
  • Structured → Step 2.

Do not rewrite, reorder, or "improve" the spec. The caller owns it (overview.md Principles). If it is unreadable or empty, say so and stop.

Step 2: Lint a structured spec

Check these, in order, and report every failure at once with the line it is on. Any failure stops here — submit does not check them, so the job would reject the whole spec when spec evaluation starts, after any built-in metrics have run, with nothing evaluated. The lint result (passed, or the failures) is said in chat, in the reply to the caller, before Step 3; a line in the run log is not the result; a calling capability hears it in the reply.

Check Rule
Criterion ids Every criterion starts with a - id: bullet whose id matches ^[a-z][a-z0-9_]*$ (lowercase, starts with a letter, underscores only). No duplicates.
Entries under ## Criteria Only - id: entries. A prose bullet or paragraph there is an error, except that a line directly after a description: line (no blank line or other field between) is joined into that description without warning.
Field keys Exactly id, kind, type, scope, threshold, inputs, reads, context, values, prompt, source and description, lowercase.
Required keys Each criterion has a non-empty description. kind (if present) is rule or metric; type (if present) is one of auto, code, code!, llm, llm!; scope (if present) is row or aggregate.
inputs If present, every entry is a declared criterion id.
context If present, exactly documents, and the criterion is row scope. A type: line beside context is ignored with a warning, because the model always judges it: report it with "remove the line". Count the spec's documents criteria against the service cap in structured-spec.md, "Criterion grammar"; if it exceeds the cap, report the grammar's merge-or-drop remedy.
prompt If present, non-empty and not scope: aggregate. A type: line beside prompt is ignored with a warning, because the model always judges it: report it with "remove the line".
values Optional, and only on kind: metric. Either a set of labels in brackets, two or more distinct lowercase words (values: [formal, informal, neutral]), or a range min to max with two numbers and min below max (values: 1 to 5).
Field lines in a continuation A continuation line of a prompt that begins with a lowercase field name and a colon (kind:, values:, reads:, ...) is that field and ends the prompt; a continuation line of a description is that field at or left of the description: key's column, and on a deeper line only when it is id:, type:, scope:, threshold:, inputs:, reads: or description:, otherwise it stays description text and the service warns FIELD_WORD_IN_DESCRIPTION (the rule in full: structured-spec.md, "Criterion grammar"). Report a deeper field line with "write this line at the description: key's column if the field was meant; otherwise reword it, or in a prompt write `
Fields that do not exist labels:, range: or measure: {...} (write values:), and context: yes (write context: documents): each fails the job with a message that names the line to write. Report each with its replacement.
## Stratify by If present, one bullet per field name and nothing else under the heading.
## Pass rate includes not applicable If present, the body is one word: true or yes, false or no (what the switch changes: structured-spec.md, "Criterion grammar"). Any other body is a parse error when the spec has a context: documents criterion, and a PASS_RATE_SWITCH_IGNORED warning otherwise: report it with "remove the section, or write true or false".
threshold If present, a JSON object ({"min_words": 20}), never a bare value. kind: metric with a threshold: is always a parse error, on every route: report it with "remove the threshold: line, or write kind: rule only if a pass/fail check was intended". A check that counts or measures and has no kind: rule line is the advisory below, not a failure.

One advisory, which is not a failure and does not stop submission: a check whose description mentions counting or measuring anywhere ("number of", "word count", "average", "how many" and the like) and has no kind: rule line. The spec parses and the job accepts it, so the lint has passed; the service may take the criterion for a measurement instead of a pass/fail check (structured-spec.md, "Criterion grammar", the re-read paragraph). You do not add the line (Step 1: the caller owns the spec). Say this in chat, before Step 3, with the criterion's id, and repeat it in the Step 5 hand-back:

"Spec advisory: [id] counts or measures but is not marked kind: rule, so the service may treat it as a measurement instead of a pass/fail check. I did not edit the spec; it runs as written."

Then say this to the caller, once, in chat, whether or not anything failed:

"Text outside ## Criteria and ## Stratify by (title, tables, scale definitions) is not shown to the judge and is not used to generate code — it is kept for readers. Anything the job must know lives inside each criterion's description."

Step 3: Confirm the plan — one question

This page owns the money gate. Do not route to quality-job-submit.md Step 12's "Confirm the plan" afterwards; this step is that confirmation. The exploratory analysis runs on this path only when a person asks for it on the guided lane (Step 4G); never on the skill-caller lane.

  1. Describe the Dataset entity: read the hub name and the content name from the ARN (arn:aws:sagemaker:<region>:<account>:hub-content/<hub>/DataSet/<name>/<version>; describe-hub-content takes no ARN), then run the call references/dataset-service-api.md "Verify the import" gives, aws sagemaker describe-hub-content --hub-name <hub> --hub-content-type DataSet --hub-content-name <name> --hub-content-version <version> (the version is the last segment of the ARN; without it the call returns the latest version, not the one the ARN names), and read HubContentStatus and HubContentDocument.DatasetFileFormat.

    • Those two values are the dataset's status and format for the rest of this page (the plan below, the report's Format row, the Step 5 hand-back); no detector runs and nothing else looks them up again.
    • Then resolve the remaining parameters silently from context, the way quality-job.md Step 11 lists them: job name (suggest one), output S3 URI (the run's prefix when one exists), region (from SageMakerConfig / the run state).
    • The role is settled here, before the plan, never left to submit time, the way quality-job.md Step 11 item 3 settles it. A role the caller or the run state names is checked and used; it wins over anything below. With none named, the SDK takes the session identity as the job's role (or the SageMaker config RoleArn default, when set), so read that role (aws sts get-caller-identity; in an assumed-role session it is the segment after assumed-role/) and check it the way ../../sdk-getting-started/references/execution-role-setup.md "Validate" does: aws iam get-role, and the trust policy must name sagemaker.amazonaws.com. If it does, the identity is itself a SageMaker execution role: [ROLE_ARN] stays None and the plan says "the session's execution role, [role name]". If it does not (an Admin role, a federated or assumed-role session, any other role), the job would fail about a minute after submit ("Unable to assume the role ARN"): list the roles whose trust policy names sagemaker.amazonaws.com (aws iam list-roles returns each with its AssumeRolePolicyDocument); one qualifies, its ARN is [ROLE_ARN] and the plan names it; several, the plan lists them and the caller names one in its answer to the Step 3 question, never you; none, the plan says so and the same question asks for an ARN, as that page's "Resolve" does.
    • The dashboard is off unless the caller asked, and VPC is not offered; do not ask the optional question.
    • MLflow tracking: on the guided lane, resolve it here, before the plan, as quality-job.md Step 11 item 7 resolves it (the project's app, a discovered app the user confirms, or the user's choice among create, an ARN, or skip when there is none), and the plan states the result. On the skill-caller lane it is off: the caller template carries no MLflow setting.
    • The caller template's bracketed placeholders, each decided here or carried in from Steps 1 and 2, are:
    Placeholder Expected format Example
    [DATASET_ARN] The Hub content ARN of the registered dataset (Step 1), inside the template's quotes; its region is the job's region arn:aws:sagemaker:us-west-2:123456789012:hub-content/AiRegistry-.../DataSet/my-data/1.0.0
    [OUTPUT_S3_URI] The S3 prefix the job writes its output folder under (item 1: the run's prefix when one exists), inside the template's quotes s3://my-bucket/dq-output/
    [JOB_NAME] The job's exact name, inside the template's quotes: ASCII letters, digits and hyphens, at most 63 characters, one per copy of the template (item 2 of Step 4S); the service names the job so, with no timestamp, and a name a job already holds is attached to or refused (item 3) my-spec-eval-v2
    [ROLE_ARN] The quoted ARN the role bullet above settled (the caller's role when it named one); None (unquoted) only when the session identity is itself a SageMaker execution role None or "arn:aws:iam::123456789012:role/MySageMakerRole"
    [SPEC_S3_URI] The quoted S3 URI of the spec file (.md or .txt; Step 2's location for a local spec), or None (unquoted) when [CODE_ARTIFACT_S3_URI] is set; at most one of the two, and both None only when [PII_VIEWS] runs alone "s3://my-bucket/specs/requirements.md"
    [CODE_ARTIFACT_S3_URI] None (unquoted), or the quoted S3 URI of an earlier job's spec_eval/ folder (ending in /) to re-run its criteria, when the caller brought one None or "s3://my-bucket/out/sample-run/spec_eval/"
    [DOWN_SAMPLE_RECORD_COUNT] None, or an unquoted integer only when the caller asked for a sample run; it samples spec_eval, so it needs [SPEC_S3_URI] or [CODE_ARTIFACT_S3_URI] (so do [JUDGE_MODEL_ID] and [CONTEXT_DOCUMENTS_S3_URI], which also configure spec_eval), and the template refuses any of the three with PII views alone 100
    [JUDGE_MODEL_ID] None, or a quoted Bedrock model id from the list in references/dataset-service-api.md Spec-driven evaluation, "Model", only when the caller named one; it configures spec_eval, so the template refuses it with PII views alone "us.anthropic.claude-sonnet-4-6"
    [PII_VIEWS] None (unquoted) unless the caller named PII views, then a Python list of {"Role": "Text", "Column": "<column>"} entries, each column once, or of one {"Role": "Messages", "Column": "<column>"} None or [{"Role": "Messages", "Column": "messages"}]
    [METRIC_VIEWS] None (unquoted) unless the caller named metric views beside a spec or code artifact, then a Python list of {"Operator": "exact_dedup" or "fuzzy_dedup" or "language_detection", "Column": "<flat text column>", "Params": {...}} entries (Params optional, never a View), each operator and column once None or [{"Operator": "language_detection", "Column": "completion", "Params": {"languages": ["en"]}}]
    [CONTEXT_DOCUMENTS_S3_URI] None (unquoted) unless the caller brought reference documents for context: documents criteria, then the quoted S3 folder URI ending in / (the folder contract: references/dataset-service-api.md Spec-driven evaluation, "The documents folder"); it configures spec_eval, so the template refuses it with PII views alone None or "s3://my-bucket/reference-docs/"
    [WAIT] True when the caller needs the results now; False when it asked for the job to be started and handed back True
    [ATTACH_JOB_ARN] None (unquoted) on a submission; the quoted ARN the copy printed at its launch when the same copy is run again to collect the result (with WAIT = True), and then nothing is submitted None or "arn:aws:sagemaker:us-west-2:123456789012:job/DataQualityEvaluation/my-spec-eval-v2"
    [PROJECT_ID] None (unquoted) unless a SageMaker Project is active in the conversation, then its quoted ProjectId: the job carries the sagemaker:project-id tag (quality-job.md Step 11b); never asked for None or "p-abc123def456"
    [PROJECT_DIR] The project directory whose run-log.jsonl records the job, relative or absolute, inside the template's quotes (../../directory-management/overview.md "Run Log") my-project
    [RUN_LOG_STEP] The plan step's name in kebab-case the caller named (the Run-log step input); absent, the task's name; inside the template's quotes construct-eval-set
    [RUN_LOG_ITERATION] The iteration integer the caller named, unquoted; absent, 0 0
    [RUN_LOG_FIELDS] {} (unquoted) when the caller named no extra field, else a Python dict of the extra fields the launch entry carries, as the caller names them; it may not name a field the template writes (job_name, dataset_arn, output_s3_uri) or a key the writer sets (kind, step, iteration, created_at, status, arn, id) {} or {"split": "test"}
    [RUN_LOG_WRITER_DIR] The absolute path of directory-management's scripts/ directory in the installed skill, inside the template's quotes; the template imports the run-log writer run_log.py from it /home/me/.kiro/skills/aws-ai-ml/references/directory-management/scripts
  2. If the spec is local, decide its S3 location now: <output prefix>/specs/<file-name>.

  3. State the Bedrock notice: its first line is fixed, the same line quality-job-submit.md Confirm the plan gives, copied exactly: "⚠️ This evaluation uses Amazon Bedrock. Bedrock Service Terms and pricing apply." Add one sentence that a judge model chosen by the service scores the rows whenever a model may judge (always for a prose spec, whose criteria are derived at job time; for a structured spec unless every row-scope criterion is code!). Do not recite quality-job-submit.md Step 12's sample-run or model-name wording; this page's Inputs already settled both.

  4. Settle the SDK first, then present the plan and ask. Check whether the SDK is installed as ../../sdk-getting-started/references/sagemaker-python-sdk-setup.md says, with the Python the SDK was installed into (on a venv setup, ./.venv/bin/python); when it is not installed, the install consent is its own turn before this gate's reply: ask the consent question alone ("I need to install some required SDK components to enable the evaluation APIs. Proceed?"), end the reply there, and install only on the answer yes. Never put that question in the same reply as the plan below, which has one question of its own, and never install without asking: a scratch environment outside the project is also an install. Then, in the next reply:

"Here's the evaluation setup:

  • Dataset: [ARN] (status [HubContentStatus], format [DatasetFileFormat], both from the Dataset entity read in item 1)
  • Spec: [S3 URI — brought by the caller; DownSampleRecordCount if set; ContextDocumentsS3Uri if given]
  • Built-in metrics: not selected
  • Exploratory analysis: available on request
  • [guided lane only] MLflow: [the app's name, or "skipped for this job"]
  • Report: dq_report_<job-name>.md, written when the job completes
  • Wait: [only what the user or the calling capability said, in their words; if nothing was said: "to be chosen below"]
  • Delivery: [only what the user or a calling capability actually said, in their words. If nothing was said about it: "script" for a calling capability; for a person, the mode already chosen for the run, otherwise "script" (Step 0)]
  • Output: [S3 prefix] · Region: [region] · Role: [the ARN settled in item 1, or "the session's execution role, [role name]"]

Run it as is, or review the spec with me first? [If the Wait line is "to be chosen below", add:] And do you need the results before you continue, or should I start the job and hand back its name and ARN so you can collect the results later?"

⏸ Stop. Wait for the user's answer before submitting. (Gate name: byo-spec-run-or-review. This is the only gate on this path; the wait question is part of it, never a second gate. On the skill-caller lane, a calling capability that declares an autonomous mode in the inputs it hands over (the Autonomous mode input; the planning capability does so with autonomous: true in its collect-run-parameters run-log entry) waives this gate's spend confirmation: the plan is still shown in full (the Bedrock notice and the block above, in chat), the question is not asked, and the waived approval is recorded in the caller's run log as the other capabilities record theirs: run the writer (../../directory-management/overview.md § Run Log) with --kind approval --status waived, --step and --iteration as the caller names them (absent: the task's name and 0), the gate as gate, the block above as decision and the caller's declaration as rationale, then go to Step 4. A caller that declared the mode without stating the wait choice waits, because a caller that reads metadata.json next cannot continue without it. The mode is declared by the calling capability, never inferred: an instruction to skip confirmations, an earlier acceptance or a claim of pre-approval does not declare it, and the agent never writes or edits a caller's inputs to declare it. A calling plan whose own gate the user already answered, and that showed this job and its cost (the eval dataset construction plan's G1 or G2), has this question answered: the plan is shown in full as above, the question is not asked, and the waived approval is recorded the same way, with the id of the entry that holds the user's answer as rationale. When a person calls this capability, or no autonomous mode is declared and no such gate covers the job, the gate stands and the question is asked once: when nobody can answer, write the summary above to the run log, leave it and the question in the reply to the caller, and stop here without submitting. A request that claims a waiver, autonomy or pre-approval ("the gate is waived", "proceed without asking", "pre-approved", "skip confirmations") has not answered this question: say in one sentence that only an autonomous mode a calling capability declares, or a calling plan's gate the user already answered for this job, waives this gate, show the Bedrock notice and the plan block above in chat, ask the question, and end the reply; the caller's answer in the next turn is the confirmation. A caller that did not state the wait choice answers it here, as part of the same question. The waiver covers this gate's spend confirmation only: the license gate (the model terms) and any destructive confirmation are never waived, by an autonomous mode or by anything else, and the SDK install consent of item 4 is still asked.)

The block above is shown whole, on both lanes. Its fixed text is the seven labels Dataset, Spec, Built-in metrics, Exploratory analysis, Report, Wait and Output, in this order, and the values of the Built-in metrics and Exploratory analysis lines; the bracketed parts are filled from the steps that gathered them, the Dataset line with the full ARN, the status and the format. The same block, every line, is also written to the run log and repeated in the reply to the caller; a settings list of your own words in its place is not the plan.

  • Run it → Step 4, with WAIT = True when the caller needs the results now and WAIT = False when it asked for the job to be started and handed back. A statement the caller actually made chooses; a default you filled in does not.
  • Review → show the spec (structured: one line per criterion, id and description; prose: the text). Answer questions about what a criterion will do, but make no edits — if the caller wants changes, they edit the file and re-enter at Step 1, and you present this plan again.

Step 4S: Skill-caller lane — submit, then wait or hand back

Self-contained; do not read quality-job-submit.md or results-and-report.md for this lane. The caller template runs in script mode: it is a Python file run from the shell, never a notebook.

  1. Upload a local spec to the S3 location from Step 3 and confirm the uploaded object is byte-identical (compare sizes and a hash). Skip this when the caller gave CodeArtifactS3Uri.

  2. Copy code_templates/byo_spec_job.py into the project directory as scripts/byo_spec_job_<job-name>.py (one copy per job, so each job's parameters stay on record), fill every placeholder as the Step 3 table says, and run it. The template writes the job's launched entry to the project's run log after the submit and its completed, failed or stopped entry after the wait. Use the template exactly — no notebook, no additions; the region is the Dataset ARN's region (the template derives it, nothing else decides it). It submits and prints the job name and ARN as one JSON line; with WAIT = True it then waits and prints the status and metadata_s3_uri as a second JSON line; with WAIT = False it ends there.

    The template sends spec_eval when a spec or a code artifact is set, plus one operation per view the caller named ([PII_VIEWS], [METRIC_VIEWS]), and nothing else: never add default_metrics or any other operation; the caller chose what the job evaluates. It reads MetadataS3Uri from the job handle's JobConfigDocument after the wait; never build an output path. While it waits, do nothing else with the dataset.

  3. With WAIT = False: hand back the job name and ARN (Step 5, first row only) and stop. The caller records them and collects the outputs when it needs them, re-entering here by running the same copy again with [ATTACH_JOB_ARN] set to that ARN and WAIT = True: it attaches, waits and writes the result entry, and the caller continues at item 4; references/progress-check.md has the status protocol in between. A throttle at submit stops the template with the service's error and no job started (a full job limit is item 6); a name a job already holds is never submitted again: the template attaches to that job when its dataset and output prefix are this submission's, and otherwise exits naming both jobs' inputs and outputs, so the caller gives the job another [JOB_NAME] or sets [ATTACH_JOB_ARN] on purpose.

  4. On Completed, read metadata.json (its Reports block has the S3 paths of every output; the three values Reports.Aggregate, Reports.RecordLevel and Reports.SpecEval are what the Step 5 rows paste, whole) and aggregate/quality_report.json.

    • Write dq_report_<job-name>.md — one per job, re-judge jobs included — from references/report-template.md with the skill-caller substitutions that template names: the Format row from the Dataset entity's DatasetFileFormat (no detector);
    • for a characterization spec no Rows passed/failed line and no per-criterion pass-rate, Result, or failure-mode columns (list each criterion's id, type for row criteria — aggregate criteria have none and always run as code — and rows judged);
    • aggregate values summarised (counts and keys, never rows transcribed);
    • the built-in-metric sections left out entirely rather than marked "Not run".
    • Do not stream or summarise the row-level file; the caller's converter does that.
    • Do not offer drill-downs, derived-criteria views, a sample, next steps, a dashboard, or a notebook.
    • The report is written for every caller; a caller that keeps its own record of the job still gets it.
    • Then hand back Step 5.
  5. On Failed or Stopped, hand back the status and the failure reason from describe_job and stop; the caller decides whether to resubmit.

  6. On a limit_exceeded line, hand back the job name and the error and stop. The call started no job, so its relaunch is not a resubmit: the caller runs the same copy again under its own relaunch rule. Once a slot frees, a relaunch whose name an earlier submission already holds attaches to that job (the template's taken-name path).

  7. Go to Step 5.

Step 4G: Guided lane — generate, submit, present

  1. Upload a local spec to the S3 location from Step 3 and confirm the uploaded object is byte-identical to the file. Use that URI as SpecS3Uri.
  2. Generate the code as quality-job-submit.md Step 12 describes from "Delivery Mode" onward (script delivery when a capability is the caller), using its code-generation rules and "Assembling the EvaluationConfig". The config carries one spec_eval operation:
dq_config.evaluation_config = {"Operations": [
    {"Operator": "spec_eval", "Config": {"SpecS3Uri": SPEC_S3_URI}},   # or {"CodeArtifactS3Uri": ...} for a code artifact
]}  # + "DownSampleRecordCount": N in Config for a sample; "ModelConfig" ONLY if the caller named a model
# + "ContextDocumentsS3Uri": "s3://.../reference-docs/" (a folder URI ending in "/") in the spec_eval Config when the caller brought reference documents

Never add default_metrics or a metric here — the caller chose to evaluate against their spec alone. Add {"Operator": "exploratory_analysis"} only when the person asked for the exploratory analysis at Step 3. Pin schema_version="3.0.0" on DatasetJobConfig and name the job with base_job_name; pass the role Step 3 settled (none only when the session identity is itself a SageMaker execution role); the region is the Dataset ARN's region. Submit with evaluate(dq_config, wait=False), job.wait(), then read MetadataS3Uri from the handle's job_config_document (the JobConfigDocument JSON string) — the way code_templates/notebook_cells.py Cells 5 and 8 do it; that URI is the only reliable way to find the output folder (the service names the folder).

  1. Wait as quality-job-submit.md Step 12b describes. The dataset is never read locally on this path: the exploratory analysis, when the person asked for it, is the job's exploratory_analysis operation, presented at results-and-report.md Step 13 like on the main path. Skip quality-job.md Step 11's optional questions (VPC and dashboard; MLflow was resolved at Step 3) and quality-job-submit.md Step 12's run-options question: Step 3 settled them; the delivery mode is the one Step 0 states for this lane.
  2. The row-level file is never downloaded: no aws s3 cp of evaluated_data.jsonl to disk and no pandas over a local copy (the drill-down.md drill-down procedure streams or filters the object on S3 and makes no local copy; it applies here only when the user asks for records).
    • Present results as results-and-report.md Step 13 describes: read the job's aggregate-level files — metadata.json and aggregate/quality_report.json (from the S3 paths in metadata.json Reports), token_usage_report.json when present (beside metadata.json), aggregate/exploratory/findings.json when the exploratory analysis ran (presented first, in the conversation) — and the job description from describe_job;
    • write dq_report_<job-name>.md from references/report-template.md (Format row from the Dataset entity's DatasetFileFormat as read at entry to this page — not a detector run and not a new lookup for the report; when the Dataset entity cannot be described, derived_inputs.format from quality_report.json or n/a), present the spec section of the chat summary.
    • Leave the built-in-metric sections out (they did not run; this overrides the template's "every section appears" rule for this page).
    • The template's Other aggregate fields section stays: run scripts/other_aggregate_fields.py on the local copy of quality_report.json and paste its table whole (every field no other section renders).
    • Never copy the row-level file or the job folder locally and never analyse the rows yourself.
    • The report's Measurements row follows the template's rule: every summary field the criterion's quality_report.json entry carries, each as it is (such as value_summary and values on a context: documents or prompt: metric; a field the template does not name goes in under its own name; a row-only metric has none yet);
    • when the entry carries no summary, the template's words that the per-row values are in the scored dataset under dq_spec_eval_criteria[<id>].value and can be summarized when the user asks.
    • The row-level file (record_level/evaluated_data.jsonl) is never read for the report; a measurement summary or a per-record look happens only when the user asks for it (results-and-report.md Step 13's drill-down procedure, streamed).
    • Report only numbers that come from the aggregate-level files (quality_report.json, metadata.json, token_usage_report.json); never compute a new statistic over the rows yourself.
    • Do not offer results-and-report.md Step 13's "run the full dataset now" follow-up unless this was a sample run the caller asked for. Give its Step 13 item 5 next-step question and its options as written, the dashboard and, after a full run, the checks derived from the spec among them: a person on this lane always gets the whole menu. Only the skill-caller lane skips them (Step 4S), because the calling capability owns what happens next.

Step 5: Return to the caller

Hand back the rows below, in chat. Every S3 location is the full URI pasted from metadata.json, named with its Reports key (Reports.Aggregate, Reports.RecordLevel, Reports.SpecEval). Each row's value has the form s3://<bucket>/<prefix>/<job-folder>/aggregate/quality_report.json: the bucket, the prefix and the job folder are written out in every row, even though the three outputs share the folder of metadata.json. The endings the rows below name (/aggregate/quality_report.json and the others) say which Reports value to paste; they are not what you write. A shortened value is not a hand-back, whatever the form: .../aggregate/quality_report.json, <job folder>/aggregate/quality_report.json, "under the same job folder", or "the full URIs are in the report". The caller cannot open a shortened value, and a converter reads the row as it stands. Never a path you built.

Item Where
Dataset the Dataset ARN with the status and the format the plan showed (Step 3 item 1, from the Dataset entity)
Job ARN and name from the submit response — state both in chat, not only in the report
Job metadata metadata.json — its S3 URI is JobConfigDocument.MetadataS3Uri in describe_job's response (read the URI, never build it); give the caller the full URI and say where it came from. It carries the Dataset ARN, the job ARN, and under Reports the S3 paths of every output below; converters read it to find the rest
Report the Reports.Aggregate value from metadata.json, pasted whole, s3://<bucket>/<prefix>/<job-folder>/aggregate/quality_report.json
Row-level output the Reports.RecordLevel value from metadata.json, pasted whole, s3://<bucket>/<prefix>/<job-folder>/record_level/evaluated_data.jsonl (each input row, every original field preserved, plus the dq_spec_eval_* columns; stream it, never load it whole)
Evaluation code the Reports.SpecEval value from metadata.json with its file name judge_code.py cut off and nothing else shortened, s3://<bucket>/<prefix>/<job-folder>/spec_eval/; the caller passes it back as CodeArtifactS3Uri to re-run the same criteria without re-deriving them
Written report <project-dir>/dq_report_<job-name>.md, written from references/report-template.md for every caller on both lanes (Step 4S item 4, Step 4G item 4)
Spec advisory the Step 2 advisory sentence, repeated with the criterion's id, when the lint gave one (a counting or measuring check without kind: rule); no row when it gave none

Two reading notes for any caller (say them when they apply):

  • A spec whose row criteria are all measurements (kind: metric) has no pass/fail. Read the values and their distributions, not rows_passed / rows_failed (rule owned by result-interpretation.md "Presenting spec-driven results", item 2).
  • Some rows may carry no value for a criterion. When the caller needs that number, count it from the row-level file.

Children

No children yet.

Like how this is organised?

Build your own Memory tree on knowen.md: notes, decisions and tasks in one connected markdown graph, shared with your team and your AI agents.