← Back to Pack Library
Jurisdictionslibraryuncertifiedv2026.12.0

us-ma

Massachusetts employment compliance library pack (RFC 0004): Temporary Workers Right to Know Law job order notice (M.G.L. c. 149, §159C) and Form M-4 Employee's Withholding Exemption Certificate (M.G.L. c. 62B (confirm)).

Verify locally with CLI
Validate schema & rules
pnpm ir check packs/us-ma/pack.json
Run pack scenarios
pnpm ir test packs/us-ma/pack.json
2Requirements
1Concepts
7Scenarios

Requirements (2)

Compliance and operational rules declared in this pack's policies, with authority classification, legal citations, and due/renewal schedules.

Massachusetts Temporary Worker Job Order Notice

ma_temp_worker_job_order
statutedocumentma_notices
Dueemployer: engagement/start_date (on day) · employee: engagement/start_date (on day)
Citations
  • M.G.L. c. 149, §159C

Massachusetts Form M-4 — Employee's Withholding Exemption Certificate (confirm statutory subsection)

ma_m4
statutedocumentma_tax
Dueemployee: engagement/start_date (on day)
Citations
  • M.G.L. c. 62B (confirm)

Concepts (1)

Typed domain facts introduced by this pack that policies evaluate against.

ConceptTypeChoices / Description
engagement/is_temporary_workerboolean

Whether the engagement is a temporary worker placement through a staffing agency

Scenarios (7)

Executable compliance test cases verified against this pack by pnpm ir test.

ma-w2-temp-worker-applies
as of 2026-12-01

US W-2 temporary worker placed in Massachusetts requires both the Temporary Worker Job Order Notice and Form M-4.

Given facts
work/location_country=USwork/location_state=MAengagement/classification=w2engagement/is_temporary_worker=trueengagement/start_date=2026-12-07engagement/reviewer=usr_hr_01engagement/employer_id=emp_bay_01
Expected outcomes
+ ma_temp_worker_job_order+ ma_m4ma_temp_worker_job_order: availablema_m4: available
ma-w2-direct-hire-no-job-order
as of 2026-12-01

US W-2 direct hire (non-temporary) working in Massachusetts requires Form M-4 but not the Temporary Worker Job Order Notice.

Given facts
work/location_country=USwork/location_state=MAengagement/classification=w2engagement/is_temporary_worker=falseengagement/start_date=2026-12-07engagement/reviewer=usr_hr_01engagement/employer_id=emp_bay_01
Expected outcomes
+ ma_m4− ma_temp_worker_job_orderma_m4: available
non-ma-worker-exempt
as of 2026-12-01

US W-2 temporary worker placed in New Hampshire does not trigger Massachusetts requirements.

Given facts
work/location_country=USwork/location_state=NHengagement/classification=w2engagement/is_temporary_worker=trueengagement/start_date=2026-12-07engagement/reviewer=usr_hr_01engagement/employer_id=emp_bay_01
Expected outcomes
− ma_temp_worker_job_order− ma_m4
ma-1099-non-temp-exempt
as of 2026-12-01

1099 independent contractor who is not a temporary worker placed in Massachusetts does not trigger Form M-4 or the Temporary Worker Job Order Notice.

Given facts
work/location_country=USwork/location_state=MAengagement/classification=1099engagement/is_temporary_worker=falseengagement/start_date=2026-12-07engagement/reviewer=usr_hr_01engagement/employer_id=emp_bay_01
Expected outcomes
− ma_temp_worker_job_order− ma_m4
missing-facts-tentative
as of 2026-12-012 steps

When engagement/is_temporary_worker and engagement/classification are unknown for a Massachusetts placement, both requirements are tentative and blocked on those facts until supplied.

Given facts
work/location_country=USwork/location_state=MAengagement/start_date=2026-12-07engagement/reviewer=usr_hr_01engagement/employer_id=emp_bay_01
Expected outcomes
+ ma_temp_worker_job_order+ ma_m4ma_temp_worker_job_order: blocked_on_factsma_m4: blocked_on_facts
due-date-and-overdue
as of 2026-12-012 steps

Both Massachusetts requirements are due on engagement/start_date: missing start_date blocks them, setting start_date makes them available, and advancing past start_date marks them overdue.

Given facts
work/location_country=USwork/location_state=MAengagement/classification=w2engagement/is_temporary_worker=trueengagement/reviewer=usr_hr_01engagement/employer_id=emp_bay_01
Expected outcomes
+ ma_temp_worker_job_order+ ma_m4ma_temp_worker_job_order: blocked_on_factsma_m4: blocked_on_facts
rehire-reuses-m4-not-job-order
as of 2026-12-01

Massachusetts W-2 temporary worker rehire with a prior Form M-4 for the same employer reuses Form M-4 while requiring a fresh Temporary Worker Job Order Notice for the new assignment.

Given facts
work/location_country=USwork/location_state=MAengagement/classification=w2engagement/is_temporary_worker=trueengagement/start_date=2026-12-07engagement/reviewer=usr_hr_01engagement/employer_id=emp_bay_01
Expected outcomes
+ ma_temp_worker_job_order+ ma_m4ma_temp_worker_job_order: availablema_m4: complete

Pack JSON

Show raw packs/us-ma/pack.json
{
  "format": 1,
  "name": "us-ma",
  "version": "2026.12.0",
  "kind": "library",
  "description": "Massachusetts employment compliance library pack (RFC 0004): Temporary Workers Right to Know Law job order notice (M.G.L. c. 149, §159C) and Form M-4 Employee's Withholding Exemption Certificate (M.G.L. c. 62B (confirm)).",
  "requires": [
    {
      "name": "staffing-core",
      "range": "^2026.12"
    }
  ],
  "concepts": [
    {
      "key": "engagement/is_temporary_worker",
      "type": "boolean",
      "description": "Whether the engagement is a temporary worker placement through a staffing agency"
    }
  ],
  "templates": [
    {
      "key": "us_ma_temp_worker_job_order",
      "version": "2026.1.0",
      "title": "Massachusetts Temporary Worker Job Order Notice (M.G.L. c. 149, §159C)",
      "roles": [
        {
          "name": "employer",
          "kind": "user",
          "label": "Staffing Agency Representative"
        },
        {
          "name": "employee",
          "kind": "person",
          "label": "Temporary Worker",
          "after": [
            "employer"
          ]
        }
      ],
      "sections": [
        {
          "id": "job_order_details",
          "role": "employer",
          "title": "Assignment and Wage Disclosures",
          "fields": [
            {
              "id": "staffing_agency_name",
              "type": "text",
              "label": "Staffing Agency Name and Contact Information",
              "required": true
            },
            {
              "id": "worksite_employer_name",
              "type": "text",
              "label": "Worksite Employer Name",
              "required": true
            },
            {
              "id": "worksite_address",
              "type": "text",
              "label": "Worksite Address",
              "required": true
            },
            {
              "id": "job_description",
              "type": "text",
              "label": "Description of Work and Required Equipment",
              "required": true
            },
            {
              "id": "pay_rate_and_payday",
              "type": "text",
              "label": "Hourly Pay Rate, Overtime Rate, and Designated Payday",
              "required": true
            },
            {
              "id": "workers_comp_carrier",
              "type": "text",
              "label": "Workers' Compensation Insurance Carrier",
              "required": true
            },
            {
              "id": "assignment_start_date",
              "type": "date",
              "label": "Assignment Start Date",
              "required": true
            }
          ]
        },
        {
          "id": "acknowledgment",
          "role": "employee",
          "title": "Temporary Worker Acknowledgment",
          "readable": [
            "job_order_details"
          ],
          "fields": [
            {
              "id": "received_date",
              "type": "date",
              "label": "Date Received",
              "required": true
            }
          ],
          "signature": {
            "id": "employee_signature",
            "attestation": "I acknowledge receipt of this Massachusetts Temporary Worker Job Order Notice pursuant to M.G.L. c. 149, §159C.",
            "covers": [
              "job_order_details",
              "acknowledgment"
            ]
          }
        }
      ]
    },
    {
      "key": "us_ma_m4",
      "version": "2026.1.0",
      "title": "Massachusetts Form M-4 — Employee's Withholding Exemption Certificate",
      "roles": [
        {
          "name": "employee",
          "kind": "person",
          "label": "Employee"
        }
      ],
      "sections": [
        {
          "id": "withholding_certificate",
          "role": "employee",
          "title": "Massachusetts Withholding Exemptions",
          "fields": [
            {
              "id": "personal_exemptions",
              "type": "text",
              "label": "Total Number of Exemptions Claimed",
              "required": true
            },
            {
              "id": "head_of_household",
              "type": "choice",
              "label": "Filing as Head of Household",
              "options": [
                "yes",
                "no"
              ],
              "required": true
            },
            {
              "id": "additional_withholding",
              "type": "text",
              "label": "Additional Dollar Amount Withheld Per Pay Period",
              "required": false
            },
            {
              "id": "claim_exempt",
              "type": "choice",
              "label": "Claim Exempt from Massachusetts Withholding",
              "options": [
                "yes",
                "no"
              ],
              "required": true
            }
          ],
          "signature": {
            "id": "employee_signature",
            "attestation": "I certify under penalties of perjury that the number of withholding exemptions claimed on this Massachusetts Form M-4 does not exceed the number to which I am entitled.",
            "covers": [
              "withholding_certificate"
            ]
          }
        }
      ]
    }
  ],
  "policies": [
    {
      "key": "us-ma",
      "version": "2026.12.0",
      "facts": {
        "work/location_country": {
          "type": "choice",
          "options": [
            "US",
            "CA",
            "GB",
            "MX",
            "OTHER"
          ]
        },
        "work/location_state": {
          "type": "choice",
          "options": [
            "AL",
            "AK",
            "AZ",
            "AR",
            "CA",
            "CO",
            "CT",
            "DE",
            "DC",
            "FL",
            "GA",
            "HI",
            "ID",
            "IL",
            "IN",
            "IA",
            "KS",
            "KY",
            "LA",
            "ME",
            "MD",
            "MA",
            "MI",
            "MN",
            "MS",
            "MO",
            "MT",
            "NE",
            "NV",
            "NH",
            "NJ",
            "NM",
            "NY",
            "NC",
            "ND",
            "OH",
            "OK",
            "OR",
            "PA",
            "PR",
            "RI",
            "SC",
            "SD",
            "TN",
            "TX",
            "UT",
            "VT",
            "VA",
            "WA",
            "WV",
            "WI",
            "WY"
          ]
        },
        "engagement/classification": {
          "type": "choice",
          "options": [
            "w2",
            "1099"
          ]
        },
        "engagement/is_temporary_worker": {
          "type": "boolean"
        },
        "engagement/start_date": {
          "type": "date"
        },
        "engagement/reviewer": {
          "type": "string"
        },
        "engagement/employer_id": {
          "type": "string"
        }
      },
      "stages": [
        {
          "id": "ma_tax",
          "title": "Massachusetts Tax Withholding"
        },
        {
          "id": "ma_notices",
          "title": "Massachusetts Statutory Notices"
        }
      ],
      "requirements": {
        "ma_temp_worker_job_order": {
          "title": "Massachusetts Temporary Worker Job Order Notice",
          "kind": "document",
          "template": "us_ma_temp_worker_job_order",
          "stage": "ma_notices",
          "parties": {
            "employer": "engagement/reviewer",
            "employee": "subject"
          },
          "due": {
            "employer": {
              "relative_to": "engagement/start_date",
              "days": 0
            },
            "employee": {
              "relative_to": "engagement/start_date",
              "days": 0
            }
          },
          "on_unknown": "wait",
          "cites": [
            "M.G.L. c. 149, §159C"
          ],
          "authority": "statute"
        },
        "ma_m4": {
          "title": "Massachusetts Form M-4 — Employee's Withholding Exemption Certificate (confirm statutory subsection)",
          "kind": "document",
          "template": "us_ma_m4",
          "stage": "ma_tax",
          "parties": {
            "employee": "subject"
          },
          "due": {
            "employee": {
              "relative_to": "engagement/start_date",
              "days": 0
            }
          },
          "reuse": {
            "same": [
              "engagement/employer_id"
            ],
            "outcome": "satisfies"
          },
          "on_unknown": "wait",
          "cites": [
            "M.G.L. c. 62B (confirm)"
          ],
          "authority": "statute"
        }
      },
      "policies": [
        {
          "id": "us-ma-temp-worker-job-order",
          "title": "Massachusetts Temporary Worker Job Order Notice for temporary workers placed in Massachusetts",
          "when": {
            "all": [
              {
                "fact": "work/location_country",
                "operator": "equal",
                "value": "US"
              },
              {
                "fact": "work/location_state",
                "operator": "equal",
                "value": "MA"
              },
              {
                "fact": "engagement/is_temporary_worker",
                "operator": "equal",
                "value": true
              }
            ]
          },
          "require": [
            "ma_temp_worker_job_order"
          ],
          "optional": false,
          "cites": [
            "M.G.L. c. 149, §159C"
          ]
        },
        {
          "id": "us-ma-m4-w2",
          "title": "Massachusetts Form M-4 for W-2 employees working in Massachusetts",
          "when": {
            "all": [
              {
                "fact": "work/location_country",
                "operator": "equal",
                "value": "US"
              },
              {
                "fact": "work/location_state",
                "operator": "equal",
                "value": "MA"
              },
              {
                "fact": "engagement/classification",
                "operator": "equal",
                "value": "w2"
              }
            ]
          },
          "require": [
            "ma_m4"
          ],
          "optional": false,
          "cites": [
            "M.G.L. c. 62B (confirm)"
          ]
        }
      ]
    }
  ],
  "scenarios": [
    {
      "name": "ma-w2-temp-worker-applies",
      "description": "US W-2 temporary worker placed in Massachusetts requires both the Temporary Worker Job Order Notice and Form M-4.",
      "policy_set": "us-ma",
      "as_of": "2026-12-01",
      "facts": {
        "work/location_country": "US",
        "work/location_state": "MA",
        "engagement/classification": "w2",
        "engagement/is_temporary_worker": true,
        "engagement/start_date": "2026-12-07",
        "engagement/reviewer": "usr_hr_01",
        "engagement/employer_id": "emp_bay_01"
      },
      "expect": {
        "required": [
          "ma_temp_worker_job_order",
          "ma_m4"
        ],
        "not_required": [],
        "states": {
          "ma_temp_worker_job_order": "available",
          "ma_m4": "available"
        },
        "missing_facts": []
      }
    },
    {
      "name": "ma-w2-direct-hire-no-job-order",
      "description": "US W-2 direct hire (non-temporary) working in Massachusetts requires Form M-4 but not the Temporary Worker Job Order Notice.",
      "policy_set": "us-ma",
      "as_of": "2026-12-01",
      "facts": {
        "work/location_country": "US",
        "work/location_state": "MA",
        "engagement/classification": "w2",
        "engagement/is_temporary_worker": false,
        "engagement/start_date": "2026-12-07",
        "engagement/reviewer": "usr_hr_01",
        "engagement/employer_id": "emp_bay_01"
      },
      "expect": {
        "required": [
          "ma_m4"
        ],
        "not_required": [
          "ma_temp_worker_job_order"
        ],
        "states": {
          "ma_m4": "available"
        },
        "missing_facts": []
      }
    },
    {
      "name": "non-ma-worker-exempt",
      "description": "US W-2 temporary worker placed in New Hampshire does not trigger Massachusetts requirements.",
      "policy_set": "us-ma",
      "as_of": "2026-12-01",
      "facts": {
        "work/location_country": "US",
        "work/location_state": "NH",
        "engagement/classification": "w2",
        "engagement/is_temporary_worker": true,
        "engagement/start_date": "2026-12-07",
        "engagement/reviewer": "usr_hr_01",
        "engagement/employer_id": "emp_bay_01"
      },
      "expect": {
        "required": [],
        "not_required": [
          "ma_temp_worker_job_order",
          "ma_m4"
        ],
        "missing_facts": []
      }
    },
    {
      "name": "ma-1099-non-temp-exempt",
      "description": "1099 independent contractor who is not a temporary worker placed in Massachusetts does not trigger Form M-4 or the Temporary Worker Job Order Notice.",
      "policy_set": "us-ma",
      "as_of": "2026-12-01",
      "facts": {
        "work/location_country": "US",
        "work/location_state": "MA",
        "engagement/classification": "1099",
        "engagement/is_temporary_worker": false,
        "engagement/start_date": "2026-12-07",
        "engagement/reviewer": "usr_hr_01",
        "engagement/employer_id": "emp_bay_01"
      },
      "expect": {
        "required": [],
        "not_required": [
          "ma_temp_worker_job_order",
          "ma_m4"
        ],
        "missing_facts": []
      }
    },
    {
      "name": "missing-facts-tentative",
      "description": "When engagement/is_temporary_worker and engagement/classification are unknown for a Massachusetts placement, both requirements are tentative and blocked on those facts until supplied.",
      "policy_set": "us-ma",
      "as_of": "2026-12-01",
      "facts": {
        "work/location_country": "US",
        "work/location_state": "MA",
        "engagement/start_date": "2026-12-07",
        "engagement/reviewer": "usr_hr_01",
        "engagement/employer_id": "emp_bay_01"
      },
      "expect": {
        "required": [
          "ma_temp_worker_job_order",
          "ma_m4"
        ],
        "not_required": [],
        "states": {
          "ma_temp_worker_job_order": "blocked_on_facts",
          "ma_m4": "blocked_on_facts"
        },
        "missing_facts": [
          "engagement/classification",
          "engagement/is_temporary_worker"
        ]
      },
      "steps": [
        {
          "name": "confirm-temporary-worker",
          "set_facts": {
            "engagement/is_temporary_worker": true
          },
          "expect": {
            "required": [
              "ma_temp_worker_job_order",
              "ma_m4"
            ],
            "states": {
              "ma_temp_worker_job_order": "available",
              "ma_m4": "blocked_on_facts"
            },
            "missing_facts": [
              "engagement/classification"
            ]
          }
        },
        {
          "name": "confirm-w2-classification",
          "set_facts": {
            "engagement/classification": "w2"
          },
          "expect": {
            "required": [
              "ma_temp_worker_job_order",
              "ma_m4"
            ],
            "states": {
              "ma_temp_worker_job_order": "available",
              "ma_m4": "available"
            },
            "missing_facts": []
          }
        }
      ]
    },
    {
      "name": "due-date-and-overdue",
      "description": "Both Massachusetts requirements are due on engagement/start_date: missing start_date blocks them, setting start_date makes them available, and advancing past start_date marks them overdue.",
      "policy_set": "us-ma",
      "as_of": "2026-12-01",
      "facts": {
        "work/location_country": "US",
        "work/location_state": "MA",
        "engagement/classification": "w2",
        "engagement/is_temporary_worker": true,
        "engagement/reviewer": "usr_hr_01",
        "engagement/employer_id": "emp_bay_01"
      },
      "expect": {
        "required": [
          "ma_temp_worker_job_order",
          "ma_m4"
        ],
        "not_required": [],
        "states": {
          "ma_temp_worker_job_order": "blocked_on_facts",
          "ma_m4": "blocked_on_facts"
        },
        "missing_facts": [
          "engagement/start_date"
        ]
      },
      "steps": [
        {
          "name": "set-assignment-start-date",
          "set_facts": {
            "engagement/start_date": "2026-12-07"
          },
          "expect": {
            "required": [
              "ma_temp_worker_job_order",
              "ma_m4"
            ],
            "states": {
              "ma_temp_worker_job_order": "available",
              "ma_m4": "available"
            },
            "missing_facts": []
          }
        },
        {
          "name": "advance-past-start-date-due",
          "as_of": "2026-12-08",
          "expect": {
            "required": [
              "ma_temp_worker_job_order",
              "ma_m4"
            ],
            "states": {
              "ma_temp_worker_job_order": "overdue",
              "ma_m4": "overdue"
            },
            "missing_facts": []
          }
        }
      ]
    },
    {
      "name": "rehire-reuses-m4-not-job-order",
      "description": "Massachusetts W-2 temporary worker rehire with a prior Form M-4 for the same employer reuses Form M-4 while requiring a fresh Temporary Worker Job Order Notice for the new assignment.",
      "policy_set": "us-ma",
      "as_of": "2026-12-01",
      "facts": {
        "work/location_country": "US",
        "work/location_state": "MA",
        "engagement/classification": "w2",
        "engagement/is_temporary_worker": true,
        "engagement/start_date": "2026-12-07",
        "engagement/reviewer": "usr_hr_01",
        "engagement/employer_id": "emp_bay_01"
      },
      "evidence": [
        {
          "id": "doc_prior_ma_m4",
          "template": "us_ma_m4",
          "template_version": "2026.1.0",
          "status": "completed",
          "completed_at": "2025-09-15",
          "facts": {
            "engagement/employer_id": "emp_bay_01"
          }
        }
      ],
      "expect": {
        "required": [
          "ma_temp_worker_job_order",
          "ma_m4"
        ],
        "not_required": [],
        "states": {
          "ma_temp_worker_job_order": "available",
          "ma_m4": "complete"
        },
        "missing_facts": []
      }
    }
  ]
}

Forma Lisp

Show Forma Lisp source us-ma.forma
(pack us-ma
  :format 1
  :version "2026.12.0"
  :kind "library"
  :description "Massachusetts employment compliance library pack (RFC 0004): Temporary Workers Right to Know Law job order notice (M.G.L. c. 149, §159C) and Form M-4 Employee's Withholding Exemption Certificate (M.G.L. c. 62B (confirm)).")

;; ── Pack Dependencies ──────────────────────────────────────────────────────

(require-pack staffing-core :range "^2026.12")

;; ── Concepts ───────────────────────────────────────────────────────────────

(concept "engagement/is_temporary_worker"
  :type "boolean"
  :description "Whether the engagement is a temporary worker placement through a staffing agency")

;; ── Document Templates ─────────────────────────────────────────────────────

(template us_ma_temp_worker_job_order
  :version "2026.1.0"
  :title "Massachusetts Temporary Worker Job Order Notice (M.G.L. c. 149, §159C)"
  :roles
    [{:name "employer" :kind "user" :label "Staffing Agency Representative"}
     {:name "employee" :kind "person" :label "Temporary Worker" :after ["employer"]}]
  :sections
    [{:id "job_order_details"
       :role "employer"
       :title "Assignment and Wage Disclosures"
       :fields
        [{:id "staffing_agency_name"
           :type "text"
           :label "Staffing Agency Name and Contact Information"
           :required true}
         {:id "worksite_employer_name"
           :type "text"
           :label "Worksite Employer Name"
           :required true}
         {:id "worksite_address" :type "text" :label "Worksite Address" :required true}
         {:id "job_description"
           :type "text"
           :label "Description of Work and Required Equipment"
           :required true}
         {:id "pay_rate_and_payday"
           :type "text"
           :label "Hourly Pay Rate, Overtime Rate, and Designated Payday"
           :required true}
         {:id "workers_comp_carrier"
           :type "text"
           :label "Workers' Compensation Insurance Carrier"
           :required true}
         {:id "assignment_start_date"
           :type "date"
           :label "Assignment Start Date"
           :required true}]}
     {:id "acknowledgment"
       :role "employee"
       :title "Temporary Worker Acknowledgment"
       :readable ["job_order_details"]
       :fields [{:id "received_date" :type "date" :label "Date Received" :required true}]
       :signature
        {:id "employee_signature"
         :attestation "I acknowledge receipt of this Massachusetts Temporary Worker Job Order Notice pursuant to M.G.L. c. 149, §159C."
         :covers ["job_order_details" "acknowledgment"]}}])

(template us_ma_m4
  :version "2026.1.0"
  :title "Massachusetts Form M-4 — Employee's Withholding Exemption Certificate"
  :roles [{:name "employee" :kind "person" :label "Employee"}]
  :sections
    [{:id "withholding_certificate"
       :role "employee"
       :title "Massachusetts Withholding Exemptions"
       :fields
        [{:id "personal_exemptions"
           :type "text"
           :label "Total Number of Exemptions Claimed"
           :required true}
         {:id "head_of_household"
           :type "choice"
           :label "Filing as Head of Household"
           :options ["yes" "no"]
           :required true}
         {:id "additional_withholding"
           :type "text"
           :label "Additional Dollar Amount Withheld Per Pay Period"
           :required false}
         {:id "claim_exempt"
           :type "choice"
           :label "Claim Exempt from Massachusetts Withholding"
           :options ["yes" "no"]
           :required true}]
       :signature
        {:id "employee_signature"
         :attestation "I certify under penalties of perjury that the number of withholding exemptions claimed on this Massachusetts Form M-4 does not exceed the number to which I am entitled."
         :covers ["withholding_certificate"]}}])

;; ── Compliance Policy Sets ─────────────────────────────────────────────────

(policy-set us-ma
  :version "2026.12.0"
  :facts
    {"work/location_country" {:type "choice" :options ["US" "CA" "GB" "MX" "OTHER"]}
     "work/location_state"
      {:type "choice"
       :options
        ["AL"
         "AK"
         "AZ"
         "AR"
         "CA"
         "CO"
         "CT"
         "DE"
         "DC"
         "FL"
         "GA"
         "HI"
         "ID"
         "IL"
         "IN"
         "IA"
         "KS"
         "KY"
         "LA"
         "ME"
         "MD"
         "MA"
         "MI"
         "MN"
         "MS"
         "MO"
         "MT"
         "NE"
         "NV"
         "NH"
         "NJ"
         "NM"
         "NY"
         "NC"
         "ND"
         "OH"
         "OK"
         "OR"
         "PA"
         "PR"
         "RI"
         "SC"
         "SD"
         "TN"
         "TX"
         "UT"
         "VT"
         "VA"
         "WA"
         "WV"
         "WI"
         "WY"]}
     "engagement/classification" {:type "choice" :options ["w2" "1099"]}
     "engagement/is_temporary_worker" {:type "boolean"}
     "engagement/start_date" {:type "date"}
     "engagement/reviewer" {:type "string"}
     "engagement/employer_id" {:type "string"}}
  :stages
    [{:id "ma_tax" :title "Massachusetts Tax Withholding"}
     {:id "ma_notices" :title "Massachusetts Statutory Notices"}]
  :requirements
    {:ma_temp_worker_job_order
      {:title "Massachusetts Temporary Worker Job Order Notice"
       :kind "document"
       :template "us_ma_temp_worker_job_order"
       :stage "ma_notices"
       :parties {:employer "engagement/reviewer" :employee "subject"}
       :due
        {:employer {:relative_to "engagement/start_date" :days 0}
         :employee {:relative_to "engagement/start_date" :days 0}}
       :on_unknown "wait"
       :cites ["M.G.L. c. 149, §159C"]
       :authority "statute"}
     :ma_m4
      {:title "Massachusetts Form M-4 — Employee's Withholding Exemption Certificate (confirm statutory subsection)"
       :kind "document"
       :template "us_ma_m4"
       :stage "ma_tax"
       :parties {:employee "subject"}
       :due {:employee {:relative_to "engagement/start_date" :days 0}}
       :reuse {:same ["engagement/employer_id"] :outcome "satisfies"}
       :on_unknown "wait"
       :cites ["M.G.L. c. 62B (confirm)"]
       :authority "statute"}}
  :policies
    [{:id "us-ma-temp-worker-job-order"
       :title "Massachusetts Temporary Worker Job Order Notice for temporary workers placed in Massachusetts"
       :when
        {:all
          [{:fact "work/location_country" :operator "equal" :value "US"}
           {:fact "work/location_state" :operator "equal" :value "MA"}
           {:fact "engagement/is_temporary_worker" :operator "equal" :value true}]}
       :require ["ma_temp_worker_job_order"]
       :optional false
       :cites ["M.G.L. c. 149, §159C"]}
     {:id "us-ma-m4-w2"
       :title "Massachusetts Form M-4 for W-2 employees working in Massachusetts"
       :when
        {:all
          [{:fact "work/location_country" :operator "equal" :value "US"}
           {:fact "work/location_state" :operator "equal" :value "MA"}
           {:fact "engagement/classification" :operator "equal" :value "w2"}]}
       :require ["ma_m4"]
       :optional false
       :cites ["M.G.L. c. 62B (confirm)"]}])

;; ── Declarative Scenarios ──────────────────────────────────────────────────

(scenario ma-w2-temp-worker-applies
  :description "US W-2 temporary worker placed in Massachusetts requires both the Temporary Worker Job Order Notice and Form M-4."
  :policy-set "us-ma"
  :as-of "2026-12-01"
  :facts
    {"work/location_country" "US"
     "work/location_state" "MA"
     "engagement/classification" "w2"
     "engagement/is_temporary_worker" true
     "engagement/start_date" "2026-12-07"
     "engagement/reviewer" "usr_hr_01"
     "engagement/employer_id" "emp_bay_01"}
  :expect
    {:required ["ma_temp_worker_job_order" "ma_m4"]
     :not_required []
     :states {:ma_temp_worker_job_order "available" :ma_m4 "available"}
     :missing_facts []})

(scenario ma-w2-direct-hire-no-job-order
  :description "US W-2 direct hire (non-temporary) working in Massachusetts requires Form M-4 but not the Temporary Worker Job Order Notice."
  :policy-set "us-ma"
  :as-of "2026-12-01"
  :facts
    {"work/location_country" "US"
     "work/location_state" "MA"
     "engagement/classification" "w2"
     "engagement/is_temporary_worker" false
     "engagement/start_date" "2026-12-07"
     "engagement/reviewer" "usr_hr_01"
     "engagement/employer_id" "emp_bay_01"}
  :expect
    {:required ["ma_m4"]
     :not_required ["ma_temp_worker_job_order"]
     :states {:ma_m4 "available"}
     :missing_facts []})

(scenario non-ma-worker-exempt
  :description "US W-2 temporary worker placed in New Hampshire does not trigger Massachusetts requirements."
  :policy-set "us-ma"
  :as-of "2026-12-01"
  :facts
    {"work/location_country" "US"
     "work/location_state" "NH"
     "engagement/classification" "w2"
     "engagement/is_temporary_worker" true
     "engagement/start_date" "2026-12-07"
     "engagement/reviewer" "usr_hr_01"
     "engagement/employer_id" "emp_bay_01"}
  :expect {:required [] :not_required ["ma_temp_worker_job_order" "ma_m4"] :missing_facts []})

(scenario ma-1099-non-temp-exempt
  :description "1099 independent contractor who is not a temporary worker placed in Massachusetts does not trigger Form M-4 or the Temporary Worker Job Order Notice."
  :policy-set "us-ma"
  :as-of "2026-12-01"
  :facts
    {"work/location_country" "US"
     "work/location_state" "MA"
     "engagement/classification" "1099"
     "engagement/is_temporary_worker" false
     "engagement/start_date" "2026-12-07"
     "engagement/reviewer" "usr_hr_01"
     "engagement/employer_id" "emp_bay_01"}
  :expect {:required [] :not_required ["ma_temp_worker_job_order" "ma_m4"] :missing_facts []})

(scenario missing-facts-tentative
  :description "When engagement/is_temporary_worker and engagement/classification are unknown for a Massachusetts placement, both requirements are tentative and blocked on those facts until supplied."
  :policy-set "us-ma"
  :as-of "2026-12-01"
  :facts
    {"work/location_country" "US"
     "work/location_state" "MA"
     "engagement/start_date" "2026-12-07"
     "engagement/reviewer" "usr_hr_01"
     "engagement/employer_id" "emp_bay_01"}
  :expect
    {:required ["ma_temp_worker_job_order" "ma_m4"]
     :not_required []
     :states {:ma_temp_worker_job_order "blocked_on_facts" :ma_m4 "blocked_on_facts"}
     :missing_facts ["engagement/classification" "engagement/is_temporary_worker"]}
  :steps
    [{:name "confirm-temporary-worker"
       :set_facts {"engagement/is_temporary_worker" true}
       :expect
        {:required ["ma_temp_worker_job_order" "ma_m4"]
         :states {:ma_temp_worker_job_order "available" :ma_m4 "blocked_on_facts"}
         :missing_facts ["engagement/classification"]}}
     {:name "confirm-w2-classification"
       :set_facts {"engagement/classification" "w2"}
       :expect
        {:required ["ma_temp_worker_job_order" "ma_m4"]
         :states {:ma_temp_worker_job_order "available" :ma_m4 "available"}
         :missing_facts []}}])

(scenario due-date-and-overdue
  :description "Both Massachusetts requirements are due on engagement/start_date: missing start_date blocks them, setting start_date makes them available, and advancing past start_date marks them overdue."
  :policy-set "us-ma"
  :as-of "2026-12-01"
  :facts
    {"work/location_country" "US"
     "work/location_state" "MA"
     "engagement/classification" "w2"
     "engagement/is_temporary_worker" true
     "engagement/reviewer" "usr_hr_01"
     "engagement/employer_id" "emp_bay_01"}
  :expect
    {:required ["ma_temp_worker_job_order" "ma_m4"]
     :not_required []
     :states {:ma_temp_worker_job_order "blocked_on_facts" :ma_m4 "blocked_on_facts"}
     :missing_facts ["engagement/start_date"]}
  :steps
    [{:name "set-assignment-start-date"
       :set_facts {"engagement/start_date" "2026-12-07"}
       :expect
        {:required ["ma_temp_worker_job_order" "ma_m4"]
         :states {:ma_temp_worker_job_order "available" :ma_m4 "available"}
         :missing_facts []}}
     {:name "advance-past-start-date-due"
       :as_of "2026-12-08"
       :expect
        {:required ["ma_temp_worker_job_order" "ma_m4"]
         :states {:ma_temp_worker_job_order "overdue" :ma_m4 "overdue"}
         :missing_facts []}}])

(scenario rehire-reuses-m4-not-job-order
  :description "Massachusetts W-2 temporary worker rehire with a prior Form M-4 for the same employer reuses Form M-4 while requiring a fresh Temporary Worker Job Order Notice for the new assignment."
  :policy-set "us-ma"
  :as-of "2026-12-01"
  :facts
    {"work/location_country" "US"
     "work/location_state" "MA"
     "engagement/classification" "w2"
     "engagement/is_temporary_worker" true
     "engagement/start_date" "2026-12-07"
     "engagement/reviewer" "usr_hr_01"
     "engagement/employer_id" "emp_bay_01"}
  :evidence
    [{:id "doc_prior_ma_m4"
       :template "us_ma_m4"
       :template_version "2026.1.0"
       :status "completed"
       :completed_at "2025-09-15"
       :facts {"engagement/employer_id" "emp_bay_01"}}]
  :expect
    {:required ["ma_temp_worker_job_order" "ma_m4"]
     :not_required []
     :states {:ma_temp_worker_job_order "available" :ma_m4 "complete"}
     :missing_facts []})