Basic rules of railroading and federal regulations should have prevented the Amtrak derailment near Philadelphia on Sunday that killed two maintenance workers and injured 31 people aboard the train, those guidelines indicate.

Just what went wrong that caused a southbound Amtrak train to collide with a backhoe doing work on the track is the province of investigators from the National Transportation Safety Board and the Federal Railroad Administration.

But in the 212 years since the steam locomotive was invented, railroads have established rules to keep trains from running down their own maintenance workers. Those rules have been cemented with federal regulation and law.

Among them:

• Workers are required to perform as teams, with one member keeping watch for approaching trains.

• Work crews are to notify a dispatcher when they prepare to undertake a task on the rail bed.

• Work crews can trip a red signal — halting an approaching train — by cutting off a low electrical current in the rail. (The track carries a simple electrical circuit that determines when there is no train on the track. That, in turn, controls the relevant signals that would allow an oncoming train to continue its progress.)

Even as they examined a data recorder and video from cameras aboard the train, investigators on Monday scrutinized whether the work crew followed those procedures.

Another mechanism that could have prevented Sunday’s crash is called positive train control, or PTC. Amtrak announced that its PTC system was fully operative on its tracks in the Northeast Corridor in December, seven months after a derailment in Philadelphia that the automatic braking system could have prevented. The May 12 wreck killed eight people and injured more than 200.

Amtrak confirmed Monday that the system was active and installed on the train involved in Sunday’s collision. But while the technology may have been working at the scene of Sunday’s crash, unless the PTC system was notified that workers were on the track, it would not have stopped the train, railroad experts said.

One of the dead workers was described by officials as the operator of a backhoe working on the rail bed. The other was said to be the worker’s supervisor. It was unclear whether there were other members of the work crew as the daily Amtrak Palmetto train bound for Washington and then on to Savannah, Ga., came barreling down the tracks.

The train departed Philadelphia’s 30th Street Station about 18 minutes earlier and had a straight run of more than two miles before it reached the site where it collided with the backhoe.

The FRA’s regulations on railroad work sites are unequivocal about being on the lookout for approaching trains.

“Watchmen/lookouts assigned to provide train approach warning shall devote full attention to detecting the approach of trains and communicating a warning thereof, and shall not be assigned any other duties while functioning as watchmen/lookouts,” Regulation 214.329 says.

It adds that workers should receive a warning “not less than 15 seconds” before a train passes the work location. And it says that all workers must maintain a position that allows them to hear that warning.

Another regulation requires work parties to orally or in writing notify the train dispatcher of the planned work zone. “The train dispatcher or control operator shall not permit the movement of trains or other on-track equipment onto the working limits . . . until the roadway worker . . . has reported clear of the track,” FRA Regulation 214.323 says.

Work crews also are permitted to shut off the electrical current running through the rail, an action “that precludes passage of trains or engines” into the work zone.

That rule stipulates that no one is permitted to allow trains back into the work area “until receiving permission to do so from the roadway worker who established the working limits.”