Wiki · Workflow companion

Spec deviation during bid

AI detects a spec mismatch during a bid response — pack size, format, ingredient, or attribute drift between our spec and the bid's requirement. Per Mike's standing rule: submit price anyway with a vague note, log the deviation, and flag for post-award discussion.

Mixed · Some steps live, others stubbed
What this is

Spec deviation during bid

Spec deviation is the canonical "let the buyer evaluate, don't self-disqualify" workflow. Per Mike's standing rule (memory: feedback_bid_spec_deviation_notes), the right move when our spec doesn't exactly match the bid spec is to submit the price anyway with a vague submission note, let the buyer evaluate, and queue the conversation for post-award.

The workflow exists to make that rule deterministic — when the AI detects a deviation during the bid response build, it doesn't halt; it logs and flags.

Risk level 2 (low). No NS writes, no customer-facing changes. The submission note is the only externally-visible artifact.

When to use it

Trigger conditions

Heuristic

Severity classification (minor / material) drives the submission note tone. Minor (pack count off by 1) gets a one-liner. Material (different ingredient profile, different format) gets a more careful sentence — still vague, never self-disqualifying.

Step-by-step what happens

The 2 beats

  1. 01

    Log deviation on bid_line

    UPDATE bid_lines SET deviation_flagged=1, deviation_notes=? WHERE id=?. The bid response render reads deviation_notes to construct the submission note.

    Writes bid_lines
    Time ~50ms
    Kind d1_write
    Status stub
  2. 02

    Post-award discussion flag

    A proposed_actions row stages with action_type=bid_post_award_discussion. If we win, this becomes a kickoff talking point.

    Writes proposed_actions
    Time ~50ms
    Kind stage_proposed_action
    Status real
Outcomes

What's different after the workflow runs

Bid line
Flagged
deviation_flagged=1
Submission note
Vague
per standing rule
Post-award flag
Staged
in proposed_actions
NS writes
None
no NS impact
Failure modes

What can go wrong and how to recover

No-op when deviation is trivial

Sometimes the AI flags a non-deviation (e.g. trailing whitespace in pack size). The classifier marks it minor, the note is one word, post-award flag is informational only.

Deviation should have blocked submission

If a deviation is truly disqualifying (e.g. wrong allergen profile), the standing rule says still submit — but Mike should override and pull the line. Manual escalation path: POST /admin/bid_lines/?id/remove.

Bid amendment resolves the deviation

Sometimes an amendment changes the bid spec to match ours. The deviation_flagged remains as historical context but no longer affects submission.

Related

Adjacent workflows + diagrams

For developers

Code paths + invariants

ConcernWhere
Workflow contractworkflow_definitions WHERE workflow_type='spec_deviation_flagged'
Standing rulefeedback_bid_spec_deviation_notes (memory)
Deviation fieldbid_lines.deviation_flagged + deviation_notes
Post-award markerproposed_actions.action_type='bid_post_award_discussion'
Reflexion tagspec_deviation
Risk level2
Expected duration~5 min
Triggerevent · sources=bid_response_workflow_step
// Standing rule: submit anyway, vague note const note = severity === 'minor' ? 'pack format may vary' : 'product configuration may vary; full spec on request'; await db.run( "UPDATE bid_lines SET deviation_flagged=1, deviation_notes=? WHERE id=?", [note, bid_line_id] );
Changelog

Dated trail · spot stale claims

Dated trail of when this doc was last touched, what changed, and what to look at if it feels stale.

DateRoundChangeTouched by
2026-05-26R586Added CHANGELOG · SCHEMA · RUNBOOK · BACKLOG sections — wiki became best-in-class operating documentation.Mike + Claude
2026-05-25R584/R585Wiki originally shipped — 8-section structure (hero / what / when / steps / outcomes / failure-modes / related / for-developers).Mike + Claude
If today is more than 60 days past the latest changelog row, treat live system behavior as the source of truth. The doc may have drifted — verify against the workflow contract in workflow_definitions WHERE workflow_type='spec_deviation_flagged' before acting on these claims.
Schema · data contract

The machine-readable spec

Canonical fields, table names, endpoint signatures. What code should match, what tests should assert. workflow_type · spec_deviation_flagged · risk_level · 3.

Inputs (required + optional)

FieldTypeDescription
item_idintegerRequired.
bid_idinteger?Optional context.
deviation_typestring'pack' | 'format' | 'ingredient' | 'cert'
deviation_detailstringDescription.

D1 tables written

TableOperationTrigger
spec_deviationsINSERTDeviation record
proposed_actionsINSERTResolution (accept, reprice, reject)
spec_itemsUPDATE (post-HITL)If deviation accepted, update spec
eventsINSERT (spec.deviated)downstream alert

Endpoints called

MethodPathPurpose
POST/api/workflow/executeRunner entrypoint
GET/api/spec-deviations/openOpen deviations dashboard

Events fired

event_typeWhenSubscribers
spec.deviatedOn flagdownstream — could block bid award
spec.deviation.resolvedOn resolveaudit
Runbook · when it breaks

It broke at 2am — what now

Different from "how do I use this." This is the page Mike pulls up when something is wrong: logs to check, recovery steps, who to escalate to.

Scenario · Deviation flagged but spec_items wasn't updated

Update is post-HITL only. Stay open until Mike decides.

  1. Check: SELECT * FROM spec_deviations WHERE id=<id>
  2. Mike decides: Approve in /proposed-actions.html with intent (accept/reprice/reject).

Scenario · Same deviation flagged repeatedly

No dedupe per (item_id, deviation_type).

  1. Find dupes: SELECT item_id, deviation_type, COUNT(*) FROM spec_deviations WHERE status='open' GROUP BY 1,2 HAVING COUNT(*) > 1
  2. Merge or close: Keep oldest open; close newer with status=duplicate.

Scenario · Bid submitted despite open deviation

Deviation doesn't block bid response today.

  1. Check submission: If bid is already in flight, communicate to buyer ASAP.
  2. Decide: Accept deviation pricing impact or pull line.
  3. Long-term: Bid submission should check open deviations.

Logs to check

Kill switch · emergency stop

If this workflow is misbehaving in a high-impact way (creating bad proposed_actions in volume, pushing wrong things to NS), flip a kill switch:

See kill-switches-state-machine.html for the full state machine + recovery procedure.

Escalation

Primary: Mike Levine (single-admin) · mikelevine@globalfoodsolutions.co. For prolonged outage during business hours, notify warehouse lead + accounting lead so they can defer dependent work.

Backlog · open questions

What's not done · what's uncertain

What's not done, what's uncertain, what we punted. Captured so it survives context switches and doesn't die in someone's head.