master-task-sync — planning skill (Phase 8 Wave 2)
10-step protocol. Steps map 1:1 to workflow_runner invocations + the
spec §8.5 master_task SSoT discipline. No MCP, no DFS, no
budget pre-flight — this is purely a local aggregation skill that
reads existing master.xlsx sheets and emits new master_task rows OR
merges the related_sources (D) column on existing rows.
This skill follows the convention authority established by
skills/planning/internal-links/SKILL.md (Phase 8 Wave 1 — master_task
writer pattern) and skills/discovery/cannibalization/SKILL.md (Phase 7
Wave 1 — 10-step protocol shape). The protocol shape, raw envelope
discipline, DURUR + flag rule, and provenance event format are reused
verbatim — only the source (8 local master.xlsx sheets instead of GSC
or SF CSV) and the writer scope (append + D-only merge instead of
full-row write) change. Deviate only with an ADR.
Unlike Phase 7 / Wave 1 skills that produce their own master writer
sheets, master-task-sync aggregates them into the master_task SSoT.
Per master-excel.schema.json#/sheets/master_task/allowed_writers
the writer name master_task_sync is whitelisted; per
#/sheets/master_task/writer_scope this writer is restricted verbatim to:
"append new auto-generated rows AND merge related_sources (D); forbidden to touch protected_columns"
protected_columns (#/sheets/master_task/protected_columns) are 7 columns
[B, F, G, H, I, M, N] = [task, category, priority, impact,
duration_est_min, assignee, note]. The transform raises
ProtectedColumnsWriteAttempt if a payload ever tries to populate any
of those — this is the schema-first defensive guard that keeps the
human / done_protocol writers' authority intact.
Inputs (frontmatter contract)
| Name | Type | Default | Notes |
|---|---|---|---|
project_slug | string | — | Required. Resolves projects/{slug}/master.xlsx. |
default_status | string | "TODO" | statusEnum seed for new appended rows. |
require_all_sheets | boolean | false | DURUR #1: raise if any of 8 upstream sheets is absent. |
workspace_root is resolved via PSEO_WORKSPACE_ROOT env or explicit
test override (mirrors workflow_runner / events_writer).
Outputs (artifacts produced)
projects/{slug}/master.xlsx#master_task— auto_generated rows appended (new) +related_sources(D) merged (existing). Protected columns (B/F/G/H/I/M/N) are LEFT BLANK on append; the human + done_protocol writers populate them later.projects/{slug}/outputs/reports/{date}-master-task-sync.md— human-readable summary (total tasks, append/merge stats, per-source breakdown, primary_source distribution).projects/{slug}/_state/events.jsonl—event_kind=provenanceentries (source.kind=tool_computed,target_excel_sheet=master_task).projects/{slug}/inbox/local/{date}-master_task_sync-{slug}.json— drift-recovery snapshot of the full aggregation result.
Upstream sheets consumed (8)
| # | Sheet | Producer skill | Phase | primary_source emitted |
|---|---|---|---|---|
| 1 | cannibalization | cannibalization | 7 W1 | cannibalization |
| 2 | content_decay | content-decay | 7 W1 | content_decay |
| 3 | tech_seo | tech-audit | 7 W1 | tech_fix |
| 4 | on_page_audit | on-page-audit | 7 W1 | per-row (tech_fix/schema/manual) |
| 5 | schema | schema-audit | 7 W2 | schema |
| 6 | cluster_keywords | cluster-map | 8 W1 | pillar |
| 7 | topical_map | topical-map | 8 W1 | pillar |
| 8 | new_content_plan | new-content-plan | 8 W1 | pillar |
The internal-links planning skill (Phase 8 W-C4) writes its own
master_task entries directly with primary_source="tech_fix" (Q-IL-1
substitute — the master_task primary_source enum has no
internal_links value). master-task-sync reads master_task itself when
detecting existing rows and treats those entries normally.
10-Step Body Protocol
Each step name must match the
steps[*].namepassed toworkflow_runner.create_run. Names are stable identifiers across runs.
Step 1 — create_run
Open a workflow run shell. The state file lives at
projects/{slug}/_state/workflows/{run_id}.json (ADR-021, ADR-019).
pythonfrom scripts.state import workflow_runner handle = workflow_runner.create_run( skill="master-task-sync", project_slug=project_slug, steps=[ {"name": "read_upstream_sheets"}, {"name": "aggregate"}, {"name": "request_approval"}, {"name": "write_excel"}, {"name": "render_report"}, ], )
Step 2 — read_upstream_sheets (master.xlsx → row dicts)
Read the 8 upstream master writer sheets + the existing master_task
into row-dict form. No MCP call. The skill body uses
openpyxl.load_workbook(read_only=True) and converts each row into a
dict keyed by the schema column names.
pythonworkflow_runner.start_step(handle.run_id, 0, project_slug=project_slug) sources = read_master_xlsx_sheets( workbook_path=workspace_root/"projects"/project_slug/"master.xlsx", sheets=[s.sheet for s in SOURCE_DEFS], ) existing_master_task = read_master_xlsx_sheets( workbook_path=..., sheets=["master_task"], )["master_task"] workflow_runner.finish_step(handle.run_id, 0, project_slug=project_slug, output_ref="memory://upstream-rows")
Step 3 — aggregate
Pure compute via scripts/planning/master_task_sync.aggregate():
pythonfrom scripts.planning import master_task_sync as mts batch = mts.aggregate( sources=sources, existing_master_task=existing_master_task, run_date=today_iso, default_status=default_status, expected_sheets=[s.sheet for s in mts.SOURCE_DEFS] if require_all_sheets else None, )
Returns an AggregateBatch describing what to change:
appends— list of new master_task rows (full 19-col dicts, protected columns blank-seeded);merges— list of(task_id, new_related_sources)pairs to apply to existing auto_generated rows (D-column only);skipped_manuel— count of auto_generated=false rows left untouched;no_op_count— count of auto rows where the related_source_key was already in D.
The transform is idempotent: same input → byte-identical output.
If len(batch.appends) == 0 and len(batch.merges) == 0, the skill
SKIPS write_excel and emits a "master_task already in sync" notice
(DURUR #4 vehicle inverted — it's a clean exit, not an error).
Drift-recovery snapshot is written immediately:
pythonsnapshot = mts.build_snapshot(batch=batch, run_date=today_iso, project_slug=project_slug) inbox_path = ( workspace_root/"projects"/project_slug/"inbox"/"local" / f"{today_iso}-master_task_sync-{project_slug}.json" ) inbox_path.parent.mkdir(parents=True, exist_ok=True) inbox_path.write_text(json.dumps(snapshot, ensure_ascii=False, indent=2, sort_keys=True))
Noise gate (O-02 / O-18 / O-19)
aggregate drops a NEW task (never touches existing rows) when
scripts/planning/task_noise.NoiseGate names a reason, counted in
dropped_stats[sheet][reason] and shown in the report:
| reason | rule |
|---|---|
cooldown_60d | the url had a task DONE in the last 60 days — wait for the O-01 outcome |
low_acceptance | the source has ≥ 20 cancellations and < 10 % of its closed tasks were done |
previously_canceled | the same url + source was canceled before |
After the write, refresh projects/{slug}/seo-standartlari.md with
task_noise.cancel_standards(master_task_rows, project=slug) (plain write —
it is a generated reading file, not state). A cancel reason seen 3+ times is
marked KALICI KURAL; when canceling a task, write the reason in note as
iptal: <gerekçe>.
Step 4 — request_approval (skill EXIT awaiting_approval)
pythonworkflow_runner.request_approval( handle.run_id, project_slug=project_slug, approver="user", subject=( f"{len(batch.appends)} yeni task + {len(batch.merges)} D-merge " f"master_task'a yazılacak (manuel rows korunur, protected_columns blank). " "Onaylıyor musun?" ), step_index=2, ) # Skill exits here. The user replies in a fresh session; resume below.
Step 5 — Resume (approve → continue)
pythonworkflow_runner.approve(handle.run_id, project_slug=project_slug, approver="user")
Step 6 — write_excel (atomic, schema-validated, writer=master_task_sync)
Single transaction.append for new rows + per-row transaction.update
for D-merges. The writer name is the schema-allowed value
master_task_sync. The transaction layer enforces _check_writer_scope
(allowed_writers gate).
pythonfrom scripts.excel import transaction # Appends — new auto_generated rows. if batch.appends: transaction.append( workbook_path=workspace_root/"projects"/project_slug/"master.xlsx", sheet="master_task", rows=batch.appends, project_slug=project_slug, writer="master_task_sync", ) # D-only merges — per task_id update of related_sources column ONLY. for task_id, new_d in batch.merges: transaction.update( workbook_path=workspace_root/"projects"/project_slug/"master.xlsx", sheet="master_task", where={"task_id": task_id}, set_={"related_sources": new_d}, project_slug=project_slug, writer="master_task_sync", )
A defensive guard inside master_task_sync._build_master_task_row
ensures every row passes through _ensure_no_protected_writes BEFORE
the transaction layer ever sees it — protected_columns violations are
surfaced as ProtectedColumnsWriteAttempt (DURUR #6) at build time, not
at write time.
Step 7 — render_report
build_report_markdown(batch=...) →
outputs/reports/{date}-master-task-sync.md. Variables auto-derived
from the batch: append/merge totals, per-source emit counts,
primary_source distribution.
Step 8 — Provenance event
pythonfrom scripts.state import events_writer events_writer.append_provenance( project_id=project_slug, # source.kind MUST be a valid events.schema source.kind enum value. # Local aggregation is an in-process, non-external-ingest action → # "tool_computed" (the same kind init-project uses for bootstrap). # The events.schema `source` object is additionalProperties:false, # so `module` / `sheets_aggregated` are NOT valid keys and are # dropped (aggregation detail belongs in `notes`, not `source`). source={"kind": "tool_computed"}, operation="project_excel", target_excel_sheet="master_task", rows_written=len(batch.appends) + len(batch.merges), )
Step 9 — complete
pythonworkflow_runner.complete(handle.run_id, project_slug=project_slug, outputs={ # F5: outputs.* must be STRING-TYPED "appends_count": str(len(batch.appends)), "merges_count": str(len(batch.merges)), "skipped_manuel": str(batch.skipped_manuel), "report_path": str(report_path), "snapshot_path": str(inbox_path), })
Step 10 — Done
Workflow status flips running → done (workflow-run schema) and a
workflow_action=done event lands in events.jsonl (ADR-020).
task_id — kanonik T-NNNNN + kalıcı registry (v2, 2026-07-23)
DEĞİŞİKLİK: Görünür
task_idartık kanonikT-NNNNN(authorityrules/master-task-id.md, schema^T-[0-9]{4,}$). Eski sha256[:16] hex ID write-layer schema-validate'i geçemiyordu (BLOCKED); artık yalnızca idempotency content-signature'ı olarak kullanılır, görünür ID değil.
content_signature = sha256("{primary_source}|{url}|{task_signature}")[:16] # idempotency anahtarı (görünmez) task_id = registry[content_signature] ya da yeni "T-NNNNN" tahsis # görünür, kanonik
- Kalıcı registry:
projects/{slug}/_state/master_task_id_map.json={content_signature → "T-NNNNN"}.load_id_map/save_id_map; bozuk dosya →MasterTaskSyncError(sessizce re-allocate ETME). - Allocation: taban
TASK_ID_BASE=10001; yeni id = max(mevcut kanonik T-id, registry) + 1 (çakışma yok).aggregate()id_mapalır;AggregateBatchid_map+new_allocations+dropped_statsdöner. - İdempotency: aynı signature → registry'den aynı T-id (re-run 0 append).
TaskIdCollisionError(DURUR #3) hâlâ farklı payload aynı signature'a düşerse fırlar. - Hacim guardrail:
cluster_keywordskaynağırow_filter=_cluster_keywords_actionable— yalnızassigned_urlboş vemonthly_volume>=CLUSTER_KEYWORDS_MIN_VOLUME (500); gerisialready_assigned/low_volumereason ile DÜŞÜRÜLÜR + LOG'lanır (no silent truncate). - Blank seed: protected
duration_est_min+priorityblank seed'i""DEĞİLNone(schemainteger|null/severityEnum|null).
The per-source task_signature is declared in SOURCE_DEFS
(scripts/planning/master_task_sync.py):
| Sheet | url_col | signature_cols |
|---|---|---|
cannibalization | (none) | (conflict_pair,) |
content_decay | url | (url,) |
tech_seo | (none) | (issue_category, detail) |
on_page_audit | url | (url, target_query) |
schema | (none) | (schema_type, location) |
cluster_keywords | assigned_url | (cluster, keyword) |
topical_map | assigned_url | (pillar, cluster, primary_keyword) |
new_content_plan | (none) | (url_slug, primary_keyword) |
Each tuple entry is _safe_str()-coerced and joined with | before
being fed into the sha256 input. Empty signature columns produce empty
fingerprint segments — the row is skipped (None signature) only when
ALL signature columns are blank.
Aggregation logic (revised semantic)
1. Read upstream sheets + existing master_task. 2. For each upstream row of each sheet: - extract (primary_source, url, signature) → task_id (sha256[:16]). - lookup task_id in existing_master_task index. - new task_id (no match): APPEND full row (19 cols), protected cols blank-seeded. - existing task_id, auto_generated=true: MERGE related_sources (D) ONLY. Other cols UNTOUCHED. (split-by-pipe → append source-key → dedupe → sort → rejoin.) - existing task_id, auto_generated=false: SKIP entirely. Manuel entries are sacrosanct. 3. Schema validate every appended row (19-col tuple + primary_source enum + protected_columns sentinel). 4. Sort appends deterministically by (primary_source, url, task_id) and merges by task_id, so re-runs produce byte-stable output order.
Idempotency contract
Re-run with identical Phase 7+8 state → identical master_task state. Re-run after new sheet rows → new task appends OR D-merges only.
Mechanically:
task_idderivation is deterministic (sha256 with no salt / clock dependency / slug dependency). Same input → same output.- After the first run, the second run finds every task_id already in
existing_master_taskwithauto_generated=true. The merge step resolves to a no-op because the related_source_key is already present in D (merge_related_sourcesis itself idempotent). - The smoke test
test_master_task_sync_idempotent_rerun_state_identicalasserts: 2× consecutive aggregate() runs produce identical AggregateBatch shapes (0 appends + 0 actual merges on the second pass).
assert_idempotent_state(first_state, second_state) is the public
helper that wraps this assertion (used by the test + can be invoked
defensively by the skill body).
protected_columns guard (#/sheets/master_task/protected_columns)
The 7 protected columns are owned by the human + done_protocol writers:
| Col | Name | Owner |
|---|---|---|
| B | task | human (free-text task description) |
| F | category | human (e.g. "internal-links") |
| G | priority | human (severityEnum) |
| H | impact | human |
| I | duration_est_min | human (integer) |
| M | assignee | human |
| N | note | human |
master_task_sync is FORBIDDEN from writing to any of those. The
defensive guard _ensure_no_protected_writes(payload) raises
ProtectedColumnsWriteAttempt (DURUR #6) if a payload ever populates
one of these columns with a non-blank value. Empty-string seeds (used
to pad a new row to its full 19-col shape) are tolerated — the Excel
write layer treats blank seeds as no-ops at the cell level.
writer_scope semantic (#/sheets/master_task/writer_scope — verbatim)
"append new auto-generated rows AND merge related_sources (D); forbidden to touch protected_columns"
The merge_column(column_name, ...) helper enforces D-only merges:
calling it with any other column raises WriterScopeViolation
(DURUR #7).
DURUR conditions (≥9)
Stop and flag the manager — do not patch, do not fall back.
- SheetMissingError —
require_all_sheets=trueand one of the 8 expected sheets (cannibalization,content_decay,tech_seo,on_page_audit,schema,cluster_keywords,topical_map,new_content_plan) is absent frommaster.xlsx. STOP, run the prior skill first. - ColumnTupleDriftError — emitted master_task row column tuple drifts from the schema 19-col tuple. STOP, schema-first violation.
- TaskIdCollisionError — two distinct (primary_source, url,
signature) payloads produced the same sha256[:16] task_id. STOP,
bump
TASK_ID_PREFIX_LENand rebuild. - IdempotencyDriftError —
assert_idempotent_statedetected divergence between two consecutiveaggregate()runs. STOP, the transform is not deterministic. - PrimarySourceEnumViolation — aggregator emitted a
primary_sourcevalue not in the closed schema enum. STOP. - ProtectedColumnsWriteAttempt — payload row tries to populate a
protected_columns field (B/F/G/H/I/M/N). STOP, schema-first violation
per writer_scope + protected_columns
(
#/sheets/master_task/writer_scope+#/sheets/master_task/protected_columns). - WriterScopeViolation — merge attempted on a column other than
related_sources(D). STOP, only D is mergeable for master_task_sync. - WorkflowRunnerSchemaError —
workflow_runner.create_runfailed schema validation. STOP, state init drift. - WorkspaceRootUnsetError —
PSEO_WORKSPACE_ROOTenv var unset AND no explicitworkspace_rootarg passed; cannot resolveprojects/{slug}/. STOP, surface to manager.
Cross-references
- Schemas:
schemas/master-excel.schema.json#/sheets/master_task(required_columns19 cols +#/sheets/master_task/allowed_writers+#/sheets/master_task/writer_scope+#/sheets/master_task/protected_columns+#/definitions/statusEnum+#/definitions/severityEnum),schemas/events.schema.json(source.kind=tool_computed,target_excel_sheet=master_task),schemas/skill-frontmatter.schema.json(this frontmatter),schemas/cross-sheet-invariants.json(D-01 is topical_map.pillar — not a master_task invariant; master_task authority is intra-sheet via allowed_writers + writer_scope + protected_columns). - Cross-modules (IMPORT-only):
scripts/state/workflow_runner.py,scripts/excel/transaction.py,scripts/state/events_writer.py,scripts/reporting/render_template.py(ormaster_task_sync.build_report_markdowndirectly). - Transform:
scripts/planning/master_task_sync.py. - Tests:
tests/skills/test_master_task_sync.py(≥10 cases incl. smoke + idempotency + protected_columns guard + writer_scope guard). - Pattern reference:
scripts/planning/internal_links_transform.py(Phase 8 W-C4 master_task writer pattern).
Discipline checklist
- TODO/fallback YASAK — every DURUR raises, none silently downgrade.
- Schema-first — frontmatter validates against
schemas/skill-frontmatter.schema.jsonDraft 7. Everyprimary_sourcewrite checked against the closed enum. Every appended row checked againstprotected_columns. - Plugin-agnostik — no slug literals;
project_slugflows through every path; transform has 0 hardcoded slug words. - ADR-013:
Use when/Also use when/Do not use whenare STRING content insidedescription, not separate fields. - Cross-module IMPORT discipline —
transaction/workflow_runner/events_writerare imported, never modified from this skill. The transform module has 0 imports fromscripts.excel.transaction(skill body does the writes). - D-003 helper IMPORT NOT applicable — local aggregation, no DFS payload is consumed (intentionally absent — documented in module docstring).
- F1: write target is
master.xlsx(lowercase, schema-shaped). - F5:
outputs.*values are STRING-TYPED (artifact paths or stringified counts), never raw ints. - Append-only state —
events.jsonlonly grows; no in-place rewrite. master_task itself is mutated only viatransaction.append(new rows) +transaction.update(D-only merge); no row deletions. - Idempotency contract: re-run with identical state → byte-stable output (asserted by smoke test).
- Q-IL-1 substitute: internal-links rows live as
primary_source="tech_fix"per W-C4; this skill reads them through the master_task index and merges D normally.


