It is easy for a neophyte to get caught by surprise on this one.
Green/Rainbow candidates must have been an un-enrolled voter (meaning not a registered Democrat, Replican, or Libertarian) for at least the 90 days before the deadline for submitting nomination papers (that deadline is the last Tuesday of May, for state representative or state senator). Hence, it’s desirable to have become unenrolled, if the candidate is presently a Democrat or Republican, by mid-February. Earlier is better.
The Secretary of the Commonwealth describes the standards that apply to “non-party” candidates. The Green/Rainbow party is a “designation” and not a party, under present law and regulations. Here are the details: How to Run as a Non-Party Candidate
And in comprehensive PDF form: A Candidate’s Guide to the 2006 State Election (Secretary of the Commonwealth. January 2006.)
Deadlines (certified signatures and certificate from Office Campaign & Political Contributions)
Chapter 53: Section 10. Certificates of nomination and nomination papers; time for filing
Section 10. All certificates of nomination and nomination papers of candidates for the office of state representative, state senator, executive council, or county office shall be filed with the state secretary on or before the last Tuesday in May of the year in which a state election is to be held.
Residency Requirements and signature gathering
State Senator – 5 years residency in Massachusetts; 300 signatures; must be an inhabitant of district when elected.
State Representative – one year residency in district; 150 signatures.